summaryrefslogtreecommitdiffstats
path: root/tests/016
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-05-21 06:43:40 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-05-21 06:43:40 -0700
commitbe5103ccf9c9b49e471f09e004f9521236c35b25 (patch)
tree9465b640a14faef60c2ad0e6c27e25a9f3ce2311 /tests/016
parent1cee56f47a9bf92f00fc08c9dbdea68b6868b025 (diff)
downloadtxr-be5103ccf9c9b49e471f09e004f9521236c35b25.tar.gz
txr-be5103ccf9c9b49e471f09e004f9521236c35b25.tar.bz2
txr-be5103ccf9c9b49e471f09e004f9521236c35b25.zip
math: add some tests related to integer conversion.
* tests/016/arith.tl: Add tests covering the fixnum/bignum knee, and ffi operations of various sizes that provide coverage of various conversion routines.
Diffstat (limited to 'tests/016')
-rw-r--r--tests/016/arith.tl50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/016/arith.tl b/tests/016/arith.tl
index 6a99b24a..1609833f 100644
--- a/tests/016/arith.tl
+++ b/tests/016/arith.tl
@@ -71,3 +71,53 @@
(test [apply bracket '(15 10 20 30)] 1)
(test [apply bracket '(25 10 20 30)] 2)
(test [apply bracket '(30 10 20 30)] 3)
+
+(test (typeof fixnum-max) fixnum)
+(test (typeof (succ fixnum-max)) bignum)
+(test (typeof fixnum-min) fixnum)
+(test (typeof (pred fixnum-min)) bignum)
+
+(test (< fixnum-min fixnum-max) t)
+(test (< (pred fixnum-min) fixnum-min) t)
+(test (> (succ fixnum-max) fixnum-max) t)
+
+(test (ffi-put #xA5 (ffi le-int16))
+ #b'A500')
+(test (ffi-put #xA5 (ffi be-int16))
+ #b'00A5')
+(test (mequal (ffi-put #xA5 (ffi int16))
+ #b'A500'
+ #b'00A5') t)
+
+(test (ffi-put #xAABBCC (ffi le-int32))
+ #b'CCBBAA00')
+(test (ffi-put #xAABBCC (ffi be-int32))
+ #b'00AABBCC')
+(test (mequal (ffi-put #xAABBCC (ffi int32))
+ #b'CCBBAA00'
+ #b'00AABBCC') t)
+
+(test (ffi-put #xAABBCCDDEE (ffi le-int64))
+ #b'EEDDCCBBAA000000')
+(test (ffi-put #xAABBCCDDEE (ffi be-int64))
+ #b'000000AABBCCDDEE')
+(test (mequal (ffi-put #xAABBCCDDEE (ffi int64))
+ #b'EEDDCCBBAA000000'
+ #b'000000AABBCCDDEE') t)
+
+(test (ffi-get #b'A500' (ffi le-int16))
+ #xA5)
+(test (ffi-get #b'00A5' (ffi be-int16))
+ #xA5)
+
+
+(test (ffi-get #b'CCBBAA00' (ffi le-int32))
+ #xAABBCC)
+(test (ffi-get #b'00AABBCC' (ffi be-int32))
+ #xAABBCC)
+
+
+(test (ffi-get #b'EEDDCCBBAA000000' (ffi le-int64))
+ #xAABBCCDDEE)
+(test (ffi-get #b'000000AABBCCDDEE' (ffi be-int64))
+ #xAABBCCDDEE)