diff options
Diffstat (limited to 'testsuite')
13 files changed, 119 insertions, 11 deletions
diff --git a/testsuite/compilable/float_literals.elna b/testsuite/compilable/float_literals.elna index ed23989..77af6b1 100644 --- a/testsuite/compilable/float_literals.elna +++ b/testsuite/compilable/float_literals.elna @@ -1,9 +1,9 @@ proc f() -const - x := 3.14 - y := 1e10 - z := 4.567e8 - t := 2.5E-3 +var + x: const Float := 3.14 + y: const Float := 1e10 + z: const Float := 4.567e8 + t: const Float := 2.5E-3 return end. diff --git a/testsuite/compilable/pointer_const_conversion.elna b/testsuite/compilable/pointer_const_conversion.elna new file mode 100644 index 0000000..fd8e097 --- /dev/null +++ b/testsuite/compilable/pointer_const_conversion.elna @@ -0,0 +1,7 @@ +var + x: Int + p: ^const Int + +begin + p := @x +end. diff --git a/testsuite/compilable/take_const_address.elna b/testsuite/compilable/take_const_address.elna new file mode 100644 index 0000000..54a2992 --- /dev/null +++ b/testsuite/compilable/take_const_address.elna @@ -0,0 +1,7 @@ +var + x: ^const Int + y: const Int + +begin + x := @y +end. diff --git a/testsuite/fail_compilation/assign_const_array_pointer.elna b/testsuite/fail_compilation/assign_const_array_pointer.elna new file mode 100644 index 0000000..32dc66d --- /dev/null +++ b/testsuite/fail_compilation/assign_const_array_pointer.elna @@ -0,0 +1,9 @@ +proc f() +var + p: ^[2]Int + q: ^const [2]Int +begin + p := q (* @Error Expected type '\^\[2\]Int', but got '\^const \[2\]Int' *) +return + +end. diff --git a/testsuite/fail_compilation/assign_const_member.elna b/testsuite/fail_compilation/assign_const_member.elna new file mode 100644 index 0000000..8aecb01 --- /dev/null +++ b/testsuite/fail_compilation/assign_const_member.elna @@ -0,0 +1,14 @@ +type + R = record + x: const Int + end + +proc f() +var + r1: R := R{ x: 5 } + r2: R := R{ x: 5 } +begin + r1 := r2 (* @Error Cannot assign to a value of type 'R', because it is constant or contains constant members *) +return + +end. diff --git a/testsuite/fail_compilation/assign_const_primitive.elna b/testsuite/fail_compilation/assign_const_primitive.elna new file mode 100644 index 0000000..34b095b --- /dev/null +++ b/testsuite/fail_compilation/assign_const_primitive.elna @@ -0,0 +1,8 @@ +proc f() +var + x: const Int +begin + x := 5 (* @Error Cannot assign to a value of type 'const Int', because it is constant or contains constant members *) +return + +end. diff --git a/testsuite/fail_compilation/assign_const_record_pointer.elna b/testsuite/fail_compilation/assign_const_record_pointer.elna new file mode 100644 index 0000000..5e6f3df --- /dev/null +++ b/testsuite/fail_compilation/assign_const_record_pointer.elna @@ -0,0 +1,17 @@ +type + B = record + x: Int + end + D = record(B) + y: Int + end + +proc f() +var + b: ^B + d: ^const D +begin + b := d (* @Error Expected type '\^B', but got '\^const D' *) +return + +end. diff --git a/testsuite/fail_compilation/assign_deep_const_pointer.elna b/testsuite/fail_compilation/assign_deep_const_pointer.elna new file mode 100644 index 0000000..7ed3840 --- /dev/null +++ b/testsuite/fail_compilation/assign_deep_const_pointer.elna @@ -0,0 +1,9 @@ +proc f() +var + p: ^^const Int + q: ^^Int +begin + p := q (* @Error Expected type '\^\^const Int', but got '\^\^Int' *) +return + +end. diff --git a/testsuite/fail_compilation/assign_element_of_const.elna b/testsuite/fail_compilation/assign_element_of_const.elna new file mode 100644 index 0000000..9afd520 --- /dev/null +++ b/testsuite/fail_compilation/assign_element_of_const.elna @@ -0,0 +1,8 @@ +proc f() +var + a: const [2]Int +begin + a[1] := 6 (* @Error Cannot assign to a value of type 'const Int', because it is constant or contains constant members *) +return + +end. diff --git a/testsuite/fail_compilation/assign_member_of_const.elna b/testsuite/fail_compilation/assign_member_of_const.elna new file mode 100644 index 0000000..fc945bb --- /dev/null +++ b/testsuite/fail_compilation/assign_member_of_const.elna @@ -0,0 +1,13 @@ +type + R = record + x: Int + end + +proc f() +var + r: const R := R{ x: 5 } +begin + r.x := 6 (* @Error Cannot assign to a value of type 'const Int', because it is constant or contains constant members *) +return + +end. diff --git a/testsuite/fail_compilation/local_const_exported.elna b/testsuite/fail_compilation/local_const_exported.elna deleted file mode 100644 index 1c6c728..0000000 --- a/testsuite/fail_compilation/local_const_exported.elna +++ /dev/null @@ -1,6 +0,0 @@ -proc test_local_export() -const - c* := 42 (* @Error Local symbol 'c' cannot be exported *) -return - -end. diff --git a/testsuite/runnable/const_copy.elna b/testsuite/runnable/const_copy.elna new file mode 100644 index 0000000..5982149 --- /dev/null +++ b/testsuite/runnable/const_copy.elna @@ -0,0 +1,12 @@ +proc f() +var + x: const Int := 5 + y: Int +begin + y := x; + assert(y = 5) +return + +begin + f() +end. diff --git a/testsuite/runnable/const_initialization.elna b/testsuite/runnable/const_initialization.elna new file mode 100644 index 0000000..7f922ff --- /dev/null +++ b/testsuite/runnable/const_initialization.elna @@ -0,0 +1,10 @@ +proc f() +var + x: const Int := 5 +begin + assert(x = 5) +return + +begin + f() +end. |
