aboutsummaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-08-31 17:18:39 +0200
committerEugen Wissner <belka@caraus.de>2026-08-31 17:18:39 +0200
commit0f5e9f00b07606871a6289060fa904555d41ae7d (patch)
tree2699d0c10e5e1756bec8f6093796c7379ff95822 /testsuite
parentd905e48d6af0445c7941cd2e638461db2f4d9ee8 (diff)
downloadelna-0f5e9f00b07606871a6289060fa904555d41ae7d.tar.gz
Reject comparison of uncompatible types
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/fail_compilation/assign_void_call.elna9
-rw-r--r--testsuite/fail_compilation/compare_unrelated_records.elna17
-rw-r--r--testsuite/fail_compilation/proc_type_without_parameters.elna9
-rw-r--r--testsuite/fail_compilation/record-base-cycle-indirect.elna13
-rw-r--r--testsuite/runnable/case_constant_label.elna13
-rw-r--r--testsuite/runnable/exported_variable/helper.elna4
-rw-r--r--testsuite/runnable/exported_variable/sut.elna5
-rw-r--r--testsuite/runnable/generic_pointer_arithmetic.elna13
8 files changed, 83 insertions, 0 deletions
diff --git a/testsuite/fail_compilation/assign_void_call.elna b/testsuite/fail_compilation/assign_void_call.elna
new file mode 100644
index 0000000..d18b1c8
--- /dev/null
+++ b/testsuite/fail_compilation/assign_void_call.elna
@@ -0,0 +1,9 @@
+var
+ x: Int
+
+proc v()
+return
+
+begin
+ x := v() (* @Error Expected type 'Int', but the expression has no value *)
+end.
diff --git a/testsuite/fail_compilation/compare_unrelated_records.elna b/testsuite/fail_compilation/compare_unrelated_records.elna
new file mode 100644
index 0000000..71eaeda
--- /dev/null
+++ b/testsuite/fail_compilation/compare_unrelated_records.elna
@@ -0,0 +1,17 @@
+type
+ A = record
+ x: Int
+ end
+ B = record
+ y: Int;
+ z: Int
+ end
+
+var
+ a: A
+ b: B
+ ok: Bool
+
+begin
+ ok := b = a (* @Error Invalid operands of type 'B' and 'A' for operator = *)
+end.
diff --git a/testsuite/fail_compilation/proc_type_without_parameters.elna b/testsuite/fail_compilation/proc_type_without_parameters.elna
new file mode 100644
index 0000000..92514f6
--- /dev/null
+++ b/testsuite/fail_compilation/proc_type_without_parameters.elna
@@ -0,0 +1,9 @@
+var
+ x: Int
+
+proc f()
+return
+
+begin
+ x := f (* @Error Expected type 'Int', but got 'proc\(\)' *)
+end.
diff --git a/testsuite/fail_compilation/record-base-cycle-indirect.elna b/testsuite/fail_compilation/record-base-cycle-indirect.elna
new file mode 100644
index 0000000..412e6ea
--- /dev/null
+++ b/testsuite/fail_compilation/record-base-cycle-indirect.elna
@@ -0,0 +1,13 @@
+type
+ A = record(B)
+ x: Int
+ end
+ B = record(A) (* @Error Type declaration forms a cycle: A -> B -> A *)
+ y: Int
+ end
+
+var
+ v: A
+
+begin
+end.
diff --git a/testsuite/runnable/case_constant_label.elna b/testsuite/runnable/case_constant_label.elna
new file mode 100644
index 0000000..5d55e9f
--- /dev/null
+++ b/testsuite/runnable/case_constant_label.elna
@@ -0,0 +1,13 @@
+var
+ base: const Int := 2
+ limit: const Int := base
+ x: Int := 2
+ matched: Bool := false
+
+begin
+ case x of
+ 1: assert(false)
+ | limit: matched := true
+ end;
+ assert(matched)
+end.
diff --git a/testsuite/runnable/exported_variable/helper.elna b/testsuite/runnable/exported_variable/helper.elna
new file mode 100644
index 0000000..23924be
--- /dev/null
+++ b/testsuite/runnable/exported_variable/helper.elna
@@ -0,0 +1,4 @@
+var
+ Shared*: Int := 42
+
+end.
diff --git a/testsuite/runnable/exported_variable/sut.elna b/testsuite/runnable/exported_variable/sut.elna
new file mode 100644
index 0000000..52fb291
--- /dev/null
+++ b/testsuite/runnable/exported_variable/sut.elna
@@ -0,0 +1,5 @@
+import helper
+
+begin
+ assert(Shared = 42)
+end.
diff --git a/testsuite/runnable/generic_pointer_arithmetic.elna b/testsuite/runnable/generic_pointer_arithmetic.elna
new file mode 100644
index 0000000..c737c7d
--- /dev/null
+++ b/testsuite/runnable/generic_pointer_arithmetic.elna
@@ -0,0 +1,13 @@
+var
+ base: [4]Int
+ element: ^Int
+ first: Pointer
+ second: Pointer
+
+begin
+ element := base.ptr;
+ first := element;
+ second := first + 1;
+ assert(cast(second : Word) - cast(first : Word) = 1u);
+ assert(second - 1 = first)
+end.