From 78fd01f7e6688448bbd710336d4d7b1c35ae058a Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 25 Jul 2019 00:45:51 -0400 Subject: No more "i/"-prefixed functions. --- stdlib/source/test/lux.lux | 16 +++---- stdlib/source/test/lux/data/number/frac.lux | 4 +- stdlib/source/test/lux/data/number/i64.lux | 10 +++-- stdlib/source/test/lux/data/number/int.lux | 6 +-- stdlib/source/test/lux/data/product.lux | 13 +++--- stdlib/source/test/lux/host.jvm.lux | 55 ++++++++++++----------- stdlib/source/test/lux/host.old.lux | 10 +++-- stdlib/source/test/lux/macro/code.lux | 12 ++--- stdlib/source/test/lux/macro/poly/equivalence.lux | 4 +- stdlib/source/test/lux/math/modular.lux | 30 +++++++------ stdlib/source/test/lux/target/jvm.lux | 4 +- stdlib/source/test/lux/time/duration.lux | 7 ++- stdlib/source/test/lux/time/instant.lux | 8 ++-- stdlib/source/test/lux/world/file.lux | 6 +-- 14 files changed, 103 insertions(+), 82 deletions(-) (limited to 'stdlib/source/test') diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index 597f6d83e..580c02d2e 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -20,7 +20,7 @@ ["." name] [number ["." i64] - ["." int] + ["i" int] ["r" rev] ["f" frac]]] ["." math] @@ -314,14 +314,14 @@ (<| (_.context "Natural numbers.") (..even-or-odd random.nat n/even? n/odd?)) (<| (_.context "Integers.") - (..even-or-odd random.int i/even? i/odd?)))) + (..even-or-odd random.int i.even? i.odd?)))) (<| (_.context "Minimum and maximum.") (`` ($_ _.and (~~ (template [<=> ] [(<| (_.context ) (..minimum-and-maximum <=> [ ] [ ]))] - [i/= i/< i/min i/> i/max random.int "Integers."] + [i.= i.< i.min i.> i.max random.int "Integers."] [n/= n/< n/min n/> n/max random.nat "Natural numbers."] [r.= r.< r.min r.> r.max random.rev "Revolutions."] [f.= f.< f.min f.> f.max random.safe-frac "Fractions."] @@ -333,11 +333,11 @@ " " (%.name (name-of )))) (..conversion <=>))] - [i/= .nat .int (random@map (i/% +1,000,000) random.int)] - [n/= .int .nat (random@map (n/% 1,000,000) random.nat)] - [i/= int.frac f.int (random@map (i/% +1,000,000) random.int)] - [f.= f.int int.frac (random@map (|>> (i/% +1,000,000) int.frac) random.int)] - [r.= r.frac f.rev frac-rev] + [i.= .nat .int (random@map (i.% +1,000,000) random.int)] + [n/= .int .nat (random@map (n/% 1,000,000) random.nat)] + [i.= i.frac f.int (random@map (i.% +1,000,000) random.int)] + [f.= f.int i.frac (random@map (|>> (i.% +1,000,000) i.frac) random.int)] + [r.= r.frac f.rev frac-rev] ))))) (<| (_.context "Prelude macros.") ..prelude-macros) diff --git a/stdlib/source/test/lux/data/number/frac.lux b/stdlib/source/test/lux/data/number/frac.lux index 257d4c049..7afefb76d 100644 --- a/stdlib/source/test/lux/data/number/frac.lux +++ b/stdlib/source/test/lux/data/number/frac.lux @@ -15,11 +15,11 @@ {1 ["." / [// #* - ["." int]]]}) + ["i" int]]]}) (def: #export test Test - (let [gen-frac (:: r.monad map (|>> (i/% +100) int.frac) r.int)] + (let [gen-frac (:: r.monad map (|>> (i.% +100) i.frac) r.int)] (<| (_.context (%.name (name-of /._))) (`` ($_ _.and ($equivalence.spec /.equivalence gen-frac) diff --git a/stdlib/source/test/lux/data/number/i64.lux b/stdlib/source/test/lux/data/number/i64.lux index fd4b3adeb..fbfecf07a 100644 --- a/stdlib/source/test/lux/data/number/i64.lux +++ b/stdlib/source/test/lux/data/number/i64.lux @@ -3,7 +3,9 @@ ["_" test (#+ Test)] [data ["." name] - ["%" text/format (#+ format)]] + ["%" text/format (#+ format)] + [number + ["i" int]]] [abstract [monad (#+ do)] {[0 #test] @@ -82,7 +84,7 @@ (n/= pattern)))) (_.test "Shift right respect the sign of ints." (let [value (.int pattern)] - (if (i/< +0 value) - (i/< +0 (/.arithmetic-right-shift idx value)) - (i/>= +0 (/.arithmetic-right-shift idx value))))) + (if (i.< +0 value) + (i.< +0 (/.arithmetic-right-shift idx value)) + (i.>= +0 (/.arithmetic-right-shift idx value))))) )))) diff --git a/stdlib/source/test/lux/data/number/int.lux b/stdlib/source/test/lux/data/number/int.lux index 7d11f0a03..c9491c913 100644 --- a/stdlib/source/test/lux/data/number/int.lux +++ b/stdlib/source/test/lux/data/number/int.lux @@ -40,10 +40,10 @@ )) (_.test "Alternate notations." - (and (i/= (bin "+11001001") + (and (/.= (bin "+11001001") (bin "+11,00,10,01")) - (i/= (oct "-615243") + (/.= (oct "-615243") (oct "-615,243")) - (i/= (hex "+deadBEEF") + (/.= (hex "+deadBEEF") (hex "+dead,BEEF")))) )))) diff --git a/stdlib/source/test/lux/data/product.lux b/stdlib/source/test/lux/data/product.lux index b7522077c..7c962804b 100644 --- a/stdlib/source/test/lux/data/product.lux +++ b/stdlib/source/test/lux/data/product.lux @@ -1,7 +1,10 @@ (.module: [lux #* ["_" test (#+ Test)] - ["%" data/text/format (#+ format)]] + [data + ["%" text/format (#+ format)] + [number + ["i" int]]]] {1 ["." /]}) @@ -10,11 +13,11 @@ (<| (_.context (%.name (name-of .&))) ($_ _.and (_.test "Can access the sides of a pair." - (and (i/= +1 (/.left [+1 +2])) - (i/= +2 (/.right [+1 +2])))) + (and (i.= +1 (/.left [+1 +2])) + (i.= +2 (/.right [+1 +2])))) (_.test "Can swap the sides of a pair." (let [[_left _right] (/.swap [+1 +2])] - (and (i/= +2 _left) - (i/= +1 _right)))) + (and (i.= +2 _left) + (i.= +1 _right)))) ))) diff --git a/stdlib/source/test/lux/host.jvm.lux b/stdlib/source/test/lux/host.jvm.lux index f142a1912..d1753e7a1 100644 --- a/stdlib/source/test/lux/host.jvm.lux +++ b/stdlib/source/test/lux/host.jvm.lux @@ -4,7 +4,9 @@ [control pipe] [data - ["." text ("#;." equivalence)]] + ["." text ("#;." equivalence)] + [number + ["i" int]]] [math ["r" random]] ["_" test (#+ Test)]] @@ -30,35 +32,38 @@ (#static currentTimeMillis [] #io long) (#static getenv [java/lang/String] #io #? java/lang/String)) -(class: #final (TestClass A) [java/lang/Runnable] - ## Fields - (#private foo boolean) - (#private bar A) - (#private baz java/lang/Object) - ## Methods - (#public [] (new self {value A}) [] - (exec (:= ::foo #1) - (:= ::bar value) - (:= ::baz "") - [])) - (#public (virtual self) java/lang/Object - "") - (#public #static (static) java/lang/Object - "") - (java/lang/Runnable [] (run self) void - [])) +## TODO: Handle "class:" ASAP. +## (class: #final (TestClass A) [java/lang/Runnable] +## ## Fields +## (#private foo boolean) +## (#private bar A) +## (#private baz java/lang/Object) +## ## Methods +## (#public [] (new self {value A}) [] +## (exec (:= ::foo #1) +## (:= ::bar value) +## (:= ::baz "") +## [])) +## (#public (virtual self) java/lang/Object +## "") +## (#public #static (static) java/lang/Object +## "") +## (java/lang/Runnable [] (run self) void +## [])) (def: test-runnable (object [] [java/lang/Runnable] [] - (java/lang/Runnable [] (run self) void - []))) + (java/lang/Runnable + [] (run self) void + []))) (def: test-callable (object [a] [(java/util/concurrent/Callable a)] [] - (java/util/concurrent/Callable [] (call self) a - (undefined)))) + ((java/util/concurrent/Callable a) + [] (call self) a #throws [java/lang/Exception] + (undefined)))) (interface: TestInterface ([] foo [boolean java/lang/String] void #throws [java/lang/Exception])) @@ -70,9 +75,9 @@ (`` ($_ _.and (~~ (template [ ] [(_.test - (or (|> sample (i/= sample)) + (or (|> sample (i.= sample)) (let [capped-sample (|> sample )] - (|> capped-sample (i/= capped-sample)))))] + (|> capped-sample (i.= capped-sample)))))] [/.long-to-byte /.byte-to-long "Can succesfully convert to/from byte."] [/.long-to-short /.short-to-long "Can succesfully convert to/from short."] @@ -126,7 +131,7 @@ (_.test "Can set and get array values." (let [arr (/.array Long size)] (exec (/.array-write idx value arr) - (i/= value (/.array-read idx arr)))))))) + (i.= value (/.array-read idx arr)))))))) (def: #export test ($_ _.and diff --git a/stdlib/source/test/lux/host.old.lux b/stdlib/source/test/lux/host.old.lux index c9446b857..19e8ae9ba 100644 --- a/stdlib/source/test/lux/host.old.lux +++ b/stdlib/source/test/lux/host.old.lux @@ -4,7 +4,9 @@ [control pipe] [data - ["." text ("#;." equivalence)]] + ["." text ("#;." equivalence)] + [number + ["i" int]]] [math ["r" random]] ["_" test (#+ Test)]] @@ -66,9 +68,9 @@ (`` ($_ _.and (~~ (template [ ] [(_.test - (or (|> sample (i/= sample)) + (or (|> sample (i.= sample)) (let [capped-sample (|> sample )] - (|> capped-sample (i/= capped-sample)))))] + (|> capped-sample (i.= capped-sample)))))] [/.long-to-byte /.byte-to-long "Can succesfully convert to/from byte."] [/.long-to-short /.short-to-long "Can succesfully convert to/from short."] @@ -122,7 +124,7 @@ (_.test "Can set and get array values." (let [arr (/.array Long size)] (exec (/.array-write idx value arr) - (i/= value (/.array-read idx arr)))))))) + (i.= value (/.array-read idx arr)))))))) (def: #export test ($_ _.and diff --git a/stdlib/source/test/lux/macro/code.lux b/stdlib/source/test/lux/macro/code.lux index e0bcd9df4..00d734ee7 100644 --- a/stdlib/source/test/lux/macro/code.lux +++ b/stdlib/source/test/lux/macro/code.lux @@ -7,7 +7,7 @@ [data ["." text ("#@." equivalence)] [number - ["." int] + ["i" int] ["f" frac]]]] {1 ["." /]}) @@ -20,12 +20,12 @@ nat r.nat int r.int rev r.rev - above (:: @ map (i/% +100) r.int) - below (:: @ map (i/% +100) r.int) + above (:: @ map (i.% +100) r.int) + below (:: @ map (i.% +100) r.int) #let [frac (|> below - (i// +100) - int.frac - (f.+ (int.frac above)) + (i./ +100) + i.frac + (f.+ (i.frac above)) (f.* -1.0))] text (r.ascii 10) short (r.ascii/alpha 10) diff --git a/stdlib/source/test/lux/macro/poly/equivalence.lux b/stdlib/source/test/lux/macro/poly/equivalence.lux index c6dcd4687..adf150aee 100644 --- a/stdlib/source/test/lux/macro/poly/equivalence.lux +++ b/stdlib/source/test/lux/macro/poly/equivalence.lux @@ -11,7 +11,7 @@ ["." bit] ["." maybe] [number - ["." int]] + ["i" int]] ["." text] [collection ["." list]]] @@ -50,7 +50,7 @@ (Random Record) (do random.monad [size (:: @ map (n/% 2) random.nat) - #let [gen-int (|> random.int (:: @ map (|>> int.abs (i/% +1,000,000))))]] + #let [gen-int (|> random.int (:: @ map (|>> i.abs (i.% +1,000,000))))]] ($_ random.and random.bit gen-int diff --git a/stdlib/source/test/lux/math/modular.lux b/stdlib/source/test/lux/math/modular.lux index 8a2ba754d..96a80dc4c 100644 --- a/stdlib/source/test/lux/math/modular.lux +++ b/stdlib/source/test/lux/math/modular.lux @@ -8,7 +8,9 @@ ["." try]] [data ["." product] - ["." bit ("#@." equivalence)]] + ["." bit ("#@." equivalence)] + [number + ["i" int]]] ["." type ("#@." equivalence)]] {1 ["." /]}) @@ -19,12 +21,12 @@ (def: modulusR (r.Random Int) (|> r.int - (:: r.monad map (i/% +1000)) - (r.filter (|>> (i/= +0) not)))) + (:: r.monad map (i.% +1000)) + (r.filter (|>> (i.= +0) not)))) (def: valueR (r.Random Int) - (|> r.int (:: r.monad map (i/% +1000)))) + (|> r.int (:: r.monad map (i.% +1000)))) (def: (modR modulus) (All [m] (-> (/.Modulus m) (r.Random [Int (/.Mod m)]))) @@ -63,7 +65,7 @@ (<| (_.context (%.name (name-of /.Mod))) (do r.monad [_normalM modulusR - _alternativeM (|> modulusR (r.filter (|>> (i/= _normalM) not))) + _alternativeM (|> modulusR (r.filter (|>> (i.= _normalM) not))) #let [normalM (|> _normalM /.from-int try.assume) alternativeM (|> _alternativeM /.from-int try.assume)] [_param param] (modR normalM) @@ -78,15 +80,15 @@ (not (type@= (:of normalM) (:of copyM))))) (_.test "Can extract the original integer from the modulus." - (i/= _normalM + (i.= _normalM (/.to-int normalM))) (_.test "Can compare mod'ed values." (and (/.= subject subject) - ((comparison /.= i/=) param subject) - ((comparison /.< i/<) param subject) - ((comparison /.<= i/<=) param subject) - ((comparison /.> i/>) param subject) - ((comparison /.>= i/>=) param subject))) + ((comparison /.= i.=) param subject) + ((comparison /.< i.<) param subject) + ((comparison /.<= i.<=) param subject) + ((comparison /.> i.>) param subject) + ((comparison /.>= i.>=) param subject))) (_.test "Mod'ed values are ordered." (and (bit@= (/.< param subject) (not (/.>= param subject))) @@ -96,9 +98,9 @@ (not (or (/.< param subject) (/.> param subject)))))) (_.test "Can do arithmetic." - (and ((arithmetic normalM /.+ i/+) param subject) - ((arithmetic normalM /.- i/-) param subject) - ((arithmetic normalM /.* i/*) param subject))) + (and ((arithmetic normalM /.+ i.+) param subject) + ((arithmetic normalM /.- i.-) param subject) + ((arithmetic normalM /.* i.*) param subject))) (_.test "Can sometimes find multiplicative inverse." (case (/.inverse subject) (#.Some subject^-1) diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux index def28b2a0..47ed621d8 100644 --- a/stdlib/source/test/lux/target/jvm.lux +++ b/stdlib/source/test/lux/target/jvm.lux @@ -11,6 +11,8 @@ ["!" capability]]] [data [binary (#+ Binary)] + [number + ["i" int]] ["." text ["%" format (#+ format)]] [format @@ -147,7 +149,7 @@ output (java/lang/reflect/Method::invoke (host.null) (host.array java/lang/Object 0) method)] (wrap (:coerce Int output))) (#try.Success actual) - (i/= expected actual) + (i.= expected actual) (#try.Failure error) false))))) diff --git a/stdlib/source/test/lux/time/duration.lux b/stdlib/source/test/lux/time/duration.lux index 8ec82dc70..9eea2e03b 100644 --- a/stdlib/source/test/lux/time/duration.lux +++ b/stdlib/source/test/lux/time/duration.lux @@ -10,6 +10,9 @@ ["$." order] ["$." monoid] ["$." codec]]}] + [data + [number + ["i" int]]] [math ["r" random (#+ Random)]]] {1 @@ -32,7 +35,7 @@ (do r.monad [millis r.int] (_.test "Can convert from/to milliseconds." - (|> millis /.from-millis /.to-millis (i/= millis)))) + (|> millis /.from-millis /.to-millis (i.= millis)))) (do r.monad [sample (|> duration (:: @ map (/.frame /.day))) frame duration @@ -40,7 +43,7 @@ #let [(^open "/@.") /.order]] ($_ _.and (_.test "Can scale a duration." - (|> sample (/.scale-up factor) (/.query sample) (i/= (.int factor)))) + (|> sample (/.scale-up factor) (/.query sample) (i.= (.int factor)))) (_.test "Scaling a duration by one does not change it." (|> sample (/.scale-up 1) (/@= sample))) (_.test "Merging a duration with it's opposite yields an empty duration." diff --git a/stdlib/source/test/lux/time/instant.lux b/stdlib/source/test/lux/time/instant.lux index 3e3e2ca8c..484aecb5a 100644 --- a/stdlib/source/test/lux/time/instant.lux +++ b/stdlib/source/test/lux/time/instant.lux @@ -13,7 +13,9 @@ [control pipe] [data - ["." text]] + ["." text] + [number + ["i" int]]] [math ["r" random (#+ Random)]] [time @@ -28,7 +30,7 @@ (def: #export instant (Random Instant) - (:: r.monad map (|>> (i/% boundary) /.from-millis) r.int)) + (:: r.monad map (|>> (i.% boundary) /.from-millis) r.int)) (def: #export test Test @@ -43,7 +45,7 @@ (do r.monad [millis r.int] (_.test "Can convert from/to milliseconds." - (|> millis /.from-millis /.to-millis (i/= millis)))) + (|> millis /.from-millis /.to-millis (i.= millis)))) (do r.monad [sample instant span _duration.duration diff --git a/stdlib/source/test/lux/world/file.lux b/stdlib/source/test/lux/world/file.lux index 2659183af..91f7ba0be 100644 --- a/stdlib/source/test/lux/world/file.lux +++ b/stdlib/source/test/lux/world/file.lux @@ -15,7 +15,7 @@ ["." binary (#+ Binary)] ["." text] [number - ["." int]] + ["i" int]] [collection ["." list]]] [time @@ -29,7 +29,7 @@ (def: truncate-millis (let [millis +1,000] - (|>> (i// millis) (i/* millis)))) + (|>> (i./ millis) (i.* millis)))) (def: (creation-and-deletion number) (-> Nat Test) @@ -71,7 +71,7 @@ [file-size (|> r.nat (:: @ map (|>> (n/% 100) (n/max 10)))) dataL (_binary.binary file-size) dataR (_binary.binary file-size) - new-modified (|> r.int (:: @ map (|>> int.abs + new-modified (|> r.int (:: @ map (|>> i.abs truncate-millis duration.from-millis instant.absolute)))] -- cgit v1.2.3