From e6cbd132125eab9fe72e1c17df5f4c4bcfb32f20 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 23 May 2017 19:46:10 -0400 Subject: - Implemented Real<->Bits conversion (and used it to implement Hash). --- stdlib/test/test/lux/data/number.lux | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'stdlib/test') 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 Codec] ["Real/Hex" R;real Eq Hex@Codec] ) + +(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)))) -- cgit v1.2.3