aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test
diff options
context:
space:
mode:
authorEduardo Julian2017-05-23 19:46:10 -0400
committerEduardo Julian2017-05-23 19:46:10 -0400
commite6cbd132125eab9fe72e1c17df5f4c4bcfb32f20 (patch)
tree19e3da5e0c5aa68bdc49565fe361e2743516439c /stdlib/test
parentd1171dc59edd34418e1b8b4da432c78cd59a9cb4 (diff)
- Implemented Real<->Bits conversion (and used it to implement Hash<Real>).
Diffstat (limited to 'stdlib/test')
-rw-r--r--stdlib/test/test/lux/data/number.lux7
1 files changed, 7 insertions, 0 deletions
diff --git a/stdlib/test/test/lux/data/number.lux b/stdlib/test/test/lux/data/number.lux
index 3b4ba4909..378731fbf 100644
--- a/stdlib/test/test/lux/data/number.lux
+++ b/stdlib/test/test/lux/data/number.lux
@@ -142,3 +142,10 @@
["Real/Decimal" R;real Eq<Real> Codec<Text,Real>]
["Real/Hex" R;real Eq<Real> Hex@Codec<Text,Real>]
)
+
+(test: "Can convert real values to/from their bit patterns."
+ [raw R;real
+ factor (|> R;nat (:: @ map (|>. (n.% +1000) (n.max +1))))
+ #let [sample (|> factor nat-to-int int-to-real (r.* raw))]]
+ (assert "Can convert real values to/from their bit patterns."
+ (|> sample real-to-bits bits-to-real (r.= sample))))