aboutsummaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/fail_compilation/aligned_attribute.elna20
-rw-r--r--testsuite/fail_compilation/local_var_exported.elna2
-rw-r--r--testsuite/runnable/aligned_attribute.elna41
3 files changed, 62 insertions, 1 deletions
diff --git a/testsuite/fail_compilation/aligned_attribute.elna b/testsuite/fail_compilation/aligned_attribute.elna
new file mode 100644
index 0000000..3b5a56e
--- /dev/null
+++ b/testsuite/fail_compilation/aligned_attribute.elna
@@ -0,0 +1,20 @@
+type
+ Uneven = record
+ #aligned(3) x: Word8 (* @Error Alignment must be a power of two *)
+ end
+ Twice = record
+ #aligned(4) #aligned(8) y: Word8 (* @Error Attribute '#aligned' specified more than once *)
+ end
+ Unknown = record
+ #packed(1) z: Word8 (* @Error Attribute '#packed' not declared *)
+ end
+
+proc takes(#aligned(8) p: Int) (* @Error Attribute '#aligned' is not supported in this position *)
+begin
+return
+
+program()
+begin
+return 0u8
+
+end.
diff --git a/testsuite/fail_compilation/local_var_exported.elna b/testsuite/fail_compilation/local_var_exported.elna
index 5323e5e..307d34f 100644
--- a/testsuite/fail_compilation/local_var_exported.elna
+++ b/testsuite/fail_compilation/local_var_exported.elna
@@ -1,6 +1,6 @@
proc test_local_export()
var
- v* : Int (* @Error Local symbol 'v' cannot be exported *)
+ v* : Int (* @Error Local symbols cannot be exported *)
return
end.
diff --git a/testsuite/runnable/aligned_attribute.elna b/testsuite/runnable/aligned_attribute.elna
new file mode 100644
index 0000000..330847e
--- /dev/null
+++ b/testsuite/runnable/aligned_attribute.elna
@@ -0,0 +1,41 @@
+type
+ Plain = record
+ a: Word8;
+ b: Word8
+ end
+
+ Spread = record
+ a, #aligned(8) b: Word8
+ end
+
+ Packed = record
+ a: Word8;
+ #aligned(1) wide: Word
+ end
+
+ Over = #aligned(16) record
+ a: Word8
+ end
+
+var
+ #aligned(32) tuned: Word8
+ spread: Spread
+ first: ^Word8
+ second: ^Word8
+
+program()
+begin
+ assert(#size(Plain) = 2u);
+ assert(#size(Spread) = 16u);
+ assert(#offset(Spread, a) = 0u);
+ assert(#offset(Spread, b) = 8u);
+ assert(#size(Packed) = 9u);
+ assert(#offset(Packed, wide) = 1u);
+ assert(#size(Over) = 16u);
+ assert(#alignment(Over) = 16u);
+ first := @spread.a;
+ second := @spread.b;
+ assert(cast(second: Word) - cast(first: Word) = 8u)
+return 0u8
+
+end.