diff options
Diffstat (limited to 'testsuite')
| -rw-r--r-- | testsuite/fail_compilation/pointer_subtraction_mismatch.elna | 10 | ||||
| -rw-r--r-- | testsuite/runnable/pointer_subtraction.elna | 18 |
2 files changed, 28 insertions, 0 deletions
diff --git a/testsuite/fail_compilation/pointer_subtraction_mismatch.elna b/testsuite/fail_compilation/pointer_subtraction_mismatch.elna new file mode 100644 index 0000000..5ad1dcb --- /dev/null +++ b/testsuite/fail_compilation/pointer_subtraction_mismatch.elna @@ -0,0 +1,10 @@ +program() + +var + p: ^Int + q: ^Word + diff: Int + +begin + diff := p - q (* @Error Invalid operands of type '\^Int' and '\^Word' for operator - *) +end. diff --git a/testsuite/runnable/pointer_subtraction.elna b/testsuite/runnable/pointer_subtraction.elna new file mode 100644 index 0000000..41d45f6 --- /dev/null +++ b/testsuite/runnable/pointer_subtraction.elna @@ -0,0 +1,18 @@ +program() +var + a: [4]Int + first: ^Int + third: ^Int + diff: Int + c: ^const Int + diff_const: Int + +begin + first := @a[1]; + third := @a[3]; + diff := third - first; + c := third; + diff_const := c - first; + assert(diff = 2); + assert(diff_const = 2) +end. |
