summaryrefslogtreecommitdiff
path: root/src/test/lib/tests/test_add.sail
diff options
context:
space:
mode:
authorAlasdair Armstrong2017-07-26 14:12:09 +0100
committerAlasdair Armstrong2017-07-26 14:12:09 +0100
commit678ab0e23ba4a8d95010df2bd2467dae7d544e29 (patch)
tree0b2e02773327b9483f24b2e1ad46b7235ec9633e /src/test/lib/tests/test_add.sail
parent26e59493cde0ffbf1868426fe3bec158f2dbaad0 (diff)
parent18cf235fad35a0e06e26ea91ee0e1c673febddb8 (diff)
Merge remote-tracking branch 'origin/master' into sail_new_tc
Diffstat (limited to 'src/test/lib/tests/test_add.sail')
-rw-r--r--src/test/lib/tests/test_add.sail19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/lib/tests/test_add.sail b/src/test/lib/tests/test_add.sail
new file mode 100644
index 00000000..ce0a19f0
--- /dev/null
+++ b/src/test/lib/tests/test_add.sail
@@ -0,0 +1,19 @@
+function unit test () = {
+ test_assert ("add", 1 + 1 == 2);
+ test_assert ("add_vec", ((bit[4])(0x1 + 0x1)) == 0x2);
+ test_assert ("add_vec_ov", ((bit[4])(0xf + 0x1)) == 0x0);
+ test_assert ("add_vec_vec_range", ((range<0,30>)(0x1 + 0x1)) == 2);
+ test_assert ("add_vec_vec_range_ov", ((range<0,15>)(0xf + 0x1)) == 0); (* XXX broken... *)
+ test_assert ("add_vec_range", ((bit[4])(0x1 + 1)) == 0x2);
+ test_assert ("add_vec_range_range", ((range<0,15>)(0xe + 1)) == 15);
+ test_assert ("add_overflow_vec", (((bit[4], bit, bit))(0x1 + 0x1)) == (0x2, false, false));
+ test_assert ("add_overflow_vec_ov", (((bit[4], bit, bit))(0xf + 0x1)) == (0x0, true, true)); (* XXX overflow flag makes no sense for unsigned... *)
+ test_assert ("add_overflow_vec_ovs", (((bit[4], bit, bit))(0x4 + 0x4)) == (0x8, false, false));
+ test_assert ("add_vec_range_range", ((range<0,16>)(0xe + 1)) == 15);
+ test_assert ("add_range_vec", ((bit[4])(1 + 0xe)) == 0xf);
+ test_assert ("add_range_vec_range", ((range<0,3>)(1 + 0xe)) == 15);
+ test_assert ("add_vec_bit", ((bit[4])(0xe + bitone)) == 0xf);
+ (* not defined on either model...
+ test_assert ("add_bit_vec", ((bit[4])(bitone + 0x1)) == 0x2); *)
+}
+