From 14a754f9654b7d9e75dfcf4a6f9e1cabae1b3b11 Mon Sep 17 00:00:00 2001 From: Westsi <76999267+Westsi@users.noreply.github.com> Date: Tue, 2 Jul 2024 16:13:50 -0400 Subject: [PATCH] added more tests --- ci/test/arithmetic.dor | 3 ++- ci/test/define.dor | 6 ++++++ ci/test/fnargs.dor | 11 +++++++++++ ci/test/fncall.dor | 9 +++++++++ ci/test/if.dor | 8 ++++++++ ci/test/import.dor | 6 ++++++ ci/test/imported.dor | 5 +++++ ci/test/metadata.tests | 8 +++++++- ci/test/while.dor | 9 +++++++++ dormouse/armbasic.dor | 2 +- 10 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 ci/test/define.dor create mode 100644 ci/test/fnargs.dor create mode 100644 ci/test/fncall.dor create mode 100644 ci/test/if.dor create mode 100644 ci/test/import.dor create mode 100644 ci/test/imported.dor create mode 100644 ci/test/while.dor diff --git a/ci/test/arithmetic.dor b/ci/test/arithmetic.dor index ac80e16..517160c 100644 --- a/ci/test/arithmetic.dor +++ b/ci/test/arithmetic.dor @@ -2,5 +2,6 @@ int main() { int x = 3 int y = 8 int z = x * y + 2 - return z + int a = z / 2 + return a - 3 } \ No newline at end of file diff --git a/ci/test/define.dor b/ci/test/define.dor new file mode 100644 index 0000000..46c11f3 --- /dev/null +++ b/ci/test/define.dor @@ -0,0 +1,6 @@ +@define FOUR 4 + +int main() { + int x = FOUR * 2 + return x +} \ No newline at end of file diff --git a/ci/test/fnargs.dor b/ci/test/fnargs.dor new file mode 100644 index 0000000..c4c9937 --- /dev/null +++ b/ci/test/fnargs.dor @@ -0,0 +1,11 @@ +int mul(int x, int y) { + return x * y +} + +int main() { + int a = 2 + int b = 3 + int s = mul(a, b) + s = s + mul(7, 4) + return s +} \ No newline at end of file diff --git a/ci/test/fncall.dor b/ci/test/fncall.dor new file mode 100644 index 0000000..b13589d --- /dev/null +++ b/ci/test/fncall.dor @@ -0,0 +1,9 @@ +int test() { + int x = 27 + return x +} + +int main() { + int r = test() + return r +} \ No newline at end of file diff --git a/ci/test/if.dor b/ci/test/if.dor new file mode 100644 index 0000000..9b5f7e2 --- /dev/null +++ b/ci/test/if.dor @@ -0,0 +1,8 @@ +int main() { + int x = 8 + if (x > 6) { + return 1 + } else { + return 0 + } +} \ No newline at end of file diff --git a/ci/test/import.dor b/ci/test/import.dor new file mode 100644 index 0000000..8301f58 --- /dev/null +++ b/ci/test/import.dor @@ -0,0 +1,6 @@ +@import "imported" + +int main() { + int x = impfunc() + return x +} \ No newline at end of file diff --git a/ci/test/imported.dor b/ci/test/imported.dor new file mode 100644 index 0000000..dc0c132 --- /dev/null +++ b/ci/test/imported.dor @@ -0,0 +1,5 @@ +int impfunc() { + int x = 8 + int y = 6 + return x * y / 2 +} \ No newline at end of file diff --git a/ci/test/metadata.tests b/ci/test/metadata.tests index e8daa68..f5c70f6 100644 --- a/ci/test/metadata.tests +++ b/ci/test/metadata.tests @@ -1,3 +1,9 @@ return:0 varret:3 -arithmetic:26 +arithmetic:10 +if:1 +define:8 +import:24 +fncall:27 +fnargs:34 +while:3 diff --git a/ci/test/while.dor b/ci/test/while.dor new file mode 100644 index 0000000..b364f70 --- /dev/null +++ b/ci/test/while.dor @@ -0,0 +1,9 @@ +int main() { + int a = 2 + int s = 0 + while (a < 5) { + s = s + 1 + a = a + 1 + } + return s +} \ No newline at end of file diff --git a/dormouse/armbasic.dor b/dormouse/armbasic.dor index a34b913..f6672c3 100644 --- a/dormouse/armbasic.dor +++ b/dormouse/armbasic.dor @@ -3,6 +3,6 @@ int fn() { } int main() { - int x = fn() ^ 11 + int x = fn() * 3 return x } \ No newline at end of file