diff options
| author | Robert Norton | 2017-07-19 18:08:02 +0100 |
|---|---|---|
| committer | Robert Norton | 2017-07-19 18:08:02 +0100 |
| commit | 632b10c0d4b01dc1af8593b8ae1f088fbfd9e342 (patch) | |
| tree | ac566808213125670da5f4dc3d702fe663333f7e /src/test/lib/tests/test_mod.sail | |
| parent | d8969b1f9631dc15d5fb6b3b33a4a69dbfb7358a (diff) | |
split library tests into separate files to avoid risk of sail compiler stack overflow.
Diffstat (limited to 'src/test/lib/tests/test_mod.sail')
| -rw-r--r-- | src/test/lib/tests/test_mod.sail | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/lib/tests/test_mod.sail b/src/test/lib/tests/test_mod.sail new file mode 100644 index 00000000..7f078bae --- /dev/null +++ b/src/test/lib/tests/test_mod.sail @@ -0,0 +1,23 @@ +function unit test () = { + test_assert ("modpospos_exact", (21 mod 7) == 0); + test_assert ("modposneg_exact", (21 mod -7) == 0); + test_assert ("modnegpos_exact", (-21 mod 7) == 0); + test_assert ("modnegneg_exact", (-21 mod -7) == 0); + + test_assert ("modpospos_approx", (21 mod 8) == 5); + test_assert ("modposneg_approx", (21 mod -8) == 5); + test_assert ("modnegpos_approx", (-21 mod 8) == -5); + test_assert ("modnegneg_approx", (-21 mod -8) == -5); + + (* XXX how to test this? Type checker should catch? + test_assert ("mod_zero", (21 mod 0) == undefined); *) + + test_assert("mod_vec_range_pos", (0x7 mod 5) == 2); + test_assert("mod_vec_range_neg", (0xf mod 5) == 0); + + test_assert("mod_vec_pos", (0x7 mod 0x5) == 0x2); + test_assert("mod_vec_neg", (0xf mod 0x5) == 0x0); + test_assert("mod_vec_pos_neg", (0x7 mod 0x8) == 0x7); + test_assert("mod_vec_neg_neg", (0xf mod 0x8) == 0x7); +} + |
