From 58090eb3ecd06f563b6864aad7d28a00dc908c66 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 1 May 2018 19:26:29 -0400 Subject: - Allow underscore separators in the hex, octal and binary encoding macros for Nat/Int/Deg/Frac. --- stdlib/test/test/lux/data/number.lux | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'stdlib/test') 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")))))) -- cgit v1.2.3