summaryrefslogtreecommitdiff
path: root/tiger-compiler/tests/testsuite
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
commit967be9e750221ab2ab783f95df79bb26d290a45e (patch)
tree6802900a5e975f9f68b169f0f503f040056d6952 /tiger-compiler/tests/testsuite
add: added projectsHEADmain
Diffstat (limited to 'tiger-compiler/tests/testsuite')
-rw-r--r--tiger-compiler/tests/testsuite/good/every_single_case.tig28
-rw-r--r--tiger-compiler/tests/testsuite/good/one_actual_test.tig4
-rw-r--r--tiger-compiler/tests/testsuite/good/one_empty_test.tig1
-rw-r--r--tiger-compiler/tests/testsuite/good/subtests.tig24
-rw-r--r--tiger-compiler/tests/testsuite/good/tested_function.tig18
-rw-r--r--tiger-compiler/tests/testsuite/good/three_actual_tests.tig14
-rw-r--r--tiger-compiler/tests/testsuite/good/three_actual_tests_natural.tig19
-rw-r--r--tiger-compiler/tests/testsuite/good/three_empty_tests.tig5
8 files changed, 113 insertions, 0 deletions
diff --git a/tiger-compiler/tests/testsuite/good/every_single_case.tig b/tiger-compiler/tests/testsuite/good/every_single_case.tig
new file mode 100644
index 0000000..a2fd923
--- /dev/null
+++ b/tiger-compiler/tests/testsuite/good/every_single_case.tig
@@ -0,0 +1,28 @@
+function test_valid_1() = assert 1 = 1
+
+function test_valid_2() = assert 2 = 2
+
+function test_assertion_failure() = assert 2 = 1
+
+function test_runtime_failure() =
+ (
+ substring("abc", 5, 2);
+ ()
+ )
+
+function test_segmentation_fault() =
+ let
+ type rectype = {name : string, age : int}
+ var nobody: rectype := nil
+ in
+ nobody.age := nobody.age + 1
+ end
+
+function test_invalid_operation() =
+ let
+ var i := 1
+ var j := 2
+ in
+ j := j - 2;
+ i := i / j
+ end
diff --git a/tiger-compiler/tests/testsuite/good/one_actual_test.tig b/tiger-compiler/tests/testsuite/good/one_actual_test.tig
new file mode 100644
index 0000000..3a5c35e
--- /dev/null
+++ b/tiger-compiler/tests/testsuite/good/one_actual_test.tig
@@ -0,0 +1,4 @@
+function test_1() =
+ (
+ assert 1 = 1
+ )
diff --git a/tiger-compiler/tests/testsuite/good/one_empty_test.tig b/tiger-compiler/tests/testsuite/good/one_empty_test.tig
new file mode 100644
index 0000000..ba4170a
--- /dev/null
+++ b/tiger-compiler/tests/testsuite/good/one_empty_test.tig
@@ -0,0 +1 @@
+function test_1() = ()
diff --git a/tiger-compiler/tests/testsuite/good/subtests.tig b/tiger-compiler/tests/testsuite/good/subtests.tig
new file mode 100644
index 0000000..87ff369
--- /dev/null
+++ b/tiger-compiler/tests/testsuite/good/subtests.tig
@@ -0,0 +1,24 @@
+// test_proceed should not be considered unit tests
+
+function test_letexp() =
+ let
+ var a := 10
+ var b := 20
+
+ function add(x: int, y: int): int = x + y
+ function sub(x: int, y: int): int = x - y
+ function mul(x: int, y: int): int = x * y
+
+ function test_proceed() =
+ let
+ function test_result(actual: int, expected: int) = assert actual = expected
+ in
+ (
+ test_result(add(a, b), 30);
+ test_result(sub(a, b), -10);
+ test_result(mul(a, b), 200)
+ )
+ end
+ in
+ test_proceed()
+ end
diff --git a/tiger-compiler/tests/testsuite/good/tested_function.tig b/tiger-compiler/tests/testsuite/good/tested_function.tig
new file mode 100644
index 0000000..e5cd6c2
--- /dev/null
+++ b/tiger-compiler/tests/testsuite/good/tested_function.tig
@@ -0,0 +1,18 @@
+// add_5 should not be considered a unit test
+
+function add_5(x: int): int = x + 5
+
+function test_1() =
+ (
+ assert add_5(1) = 6
+ )
+
+function test_2() =
+ (
+ assert add_5(-1) = 4
+ )
+
+function test_3() =
+ (
+ assert add_5(0) = 5
+ )
diff --git a/tiger-compiler/tests/testsuite/good/three_actual_tests.tig b/tiger-compiler/tests/testsuite/good/three_actual_tests.tig
new file mode 100644
index 0000000..00bcd31
--- /dev/null
+++ b/tiger-compiler/tests/testsuite/good/three_actual_tests.tig
@@ -0,0 +1,14 @@
+function test_1() =
+ (
+ assert 1 = 1
+ )
+
+function test_2() =
+ (
+ assert 2 = 2
+ )
+
+function test_3() =
+ (
+ assert 1 = 2
+ )
diff --git a/tiger-compiler/tests/testsuite/good/three_actual_tests_natural.tig b/tiger-compiler/tests/testsuite/good/three_actual_tests_natural.tig
new file mode 100644
index 0000000..ad41636
--- /dev/null
+++ b/tiger-compiler/tests/testsuite/good/three_actual_tests_natural.tig
@@ -0,0 +1,19 @@
+function test_1() = (3 = 3; () )
+
+function test_2() =
+ let
+ var i := 1
+ var j := 1
+ in
+ j := j + 1;
+ i := i * j
+ end
+
+function test_3() =
+ let
+ var i := 1
+ var j := 1
+ in
+ j := j - 1;
+ i := i / j
+ end
diff --git a/tiger-compiler/tests/testsuite/good/three_empty_tests.tig b/tiger-compiler/tests/testsuite/good/three_empty_tests.tig
new file mode 100644
index 0000000..d12db1a
--- /dev/null
+++ b/tiger-compiler/tests/testsuite/good/three_empty_tests.tig
@@ -0,0 +1,5 @@
+function test_1() = ()
+
+function test_2() = ()
+
+function test_3() = ()