aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test
diff options
context:
space:
mode:
authorEduardo Julian2018-05-01 19:26:29 -0400
committerEduardo Julian2018-05-01 19:26:29 -0400
commit58090eb3ecd06f563b6864aad7d28a00dc908c66 (patch)
treedb95d720afd2559206c5b7e33a38407474497087 /stdlib/test
parent4b7d81c1e0449adc031ece6299fe4d0a09f66347 (diff)
- Allow underscore separators in the hex, octal and binary encoding macros for Nat/Int/Deg/Frac.
Diffstat (limited to 'stdlib/test')
-rw-r--r--stdlib/test/test/lux/data/number.lux18
1 files changed, 18 insertions, 0 deletions
diff --git a/stdlib/test/test/lux/data/number.lux b/stdlib/test/test/lux/data/number.lux
index 3ba7db2c2..263dd346d 100644
--- a/stdlib/test/test/lux/data/number.lux
+++ b/stdlib/test/test/lux/data/number.lux
@@ -163,3 +163,21 @@
#let [sample (|> factor nat-to-int int-to-frac (f/* raw))]]
(test "Can convert frac values to/from their bit patterns."
(|> sample frac-to-bits bits-to-frac (f/= sample))))))
+
+(context: "Macros for alternative numeric encodings."
+ ($_ seq
+ (test "Binary."
+ (and (n/= (bin "+11001001") (bin "+11_00_10_01"))
+ (i/= (bin "11001001") (bin "11_00_10_01"))
+ (d/= (bin ".11001001") (bin ".11_00_10_01"))
+ (f/= (bin "1100.1001") (bin "11_00.10_01"))))
+ (test "Octal."
+ (and (n/= (oct "+615243") (oct "+615_243"))
+ (i/= (oct "615243") (oct "615_243"))
+ (d/= (oct ".615243") (oct ".615_243"))
+ (f/= (oct "6152.43") (oct "615_2.43"))))
+ (test "Hexadecimal."
+ (and (n/= (hex "+deadBEEF") (hex "+dead_BEEF"))
+ (i/= (hex "deadBEEF") (hex "dead_BEEF"))
+ (d/= (hex ".deadBEEF") (hex ".dead_BEEF"))
+ (f/= (hex "deadBE.EF") (hex "dead_BE.EF"))))))