From 3de94c8a341ef3f19fd75eeeb98e5333d2fe89d0 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 5 Apr 2018 06:18:46 -0400 Subject: - Re-named "is" to "is?". --- stdlib/source/lux.lux | 6 +++--- stdlib/source/lux/concurrency/stm.lux | 12 +++++------ stdlib/source/lux/data/coll/bits.lux | 6 +++--- stdlib/source/lux/data/coll/dict.lux | 4 ++-- stdlib/source/lux/data/coll/ordered/dict.lux | 2 +- stdlib/source/lux/data/coll/tree/parser.lux | 2 +- stdlib/source/lux/data/error.lux | 8 ++++---- stdlib/source/lux/lang/type/check.lux | 2 +- stdlib/source/lux/test.lux | 8 ++++---- stdlib/test/test/lux.lux | 14 ++++++------- stdlib/test/test/lux/control/parser.lux | 9 --------- stdlib/test/test/lux/data/coll/array.lux | 6 +++--- stdlib/test/test/lux/data/coll/bits.lux | 8 ++++---- stdlib/test/test/lux/data/coll/sequence.lux | 2 +- stdlib/test/test/lux/data/coll/stack.lux | 6 +++--- stdlib/test/test/lux/data/coll/tree/zipper.lux | 28 +++++++++++++------------- stdlib/test/test/lux/data/ident.lux | 4 ++-- stdlib/test/test/lux/data/lazy.lux | 8 ++++---- stdlib/test/test/lux/host.js.lux | 22 ++++++++++---------- stdlib/test/test/lux/macro/syntax.lux | 10 ++++----- stdlib/test/test/lux/math/constructive.lux | 2 +- 21 files changed, 80 insertions(+), 89 deletions(-) diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index 7fa2ea692..ec9ac013e 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -5688,14 +5688,14 @@ _ (fail "Wrong syntax for $"))) -(def: #export (is reference sample) +(def: #export (is? reference sample) {#.doc (doc "Tests whether the 2 values are identical (not just \"equal\")." "This one should succeed:" (let [value 5] - (is value value)) + (is? value value)) "This one should fail:" - (is 5 (i/+ 2 3)))} + (is? 5 (i/+ 2 3)))} (All [a] (-> a a Bool)) ("lux is" reference sample)) diff --git a/stdlib/source/lux/concurrency/stm.lux b/stdlib/source/lux/concurrency/stm.lux index 69a36461a..a62a35677 100644 --- a/stdlib/source/lux/concurrency/stm.lux +++ b/stdlib/source/lux/concurrency/stm.lux @@ -76,8 +76,8 @@ (All [a] (-> (Var a) Tx (Maybe a))) (|> tx (list.find (function [[_var _original _current]] - (is (:! (Var Unit) var) - (:! (Var Unit) _var)))) + (is? (:! (Var Unit) var) + (:! (Var Unit) _var)))) (:: maybe.Monad map (function [[_var _original _current]] _current)) (:!!) @@ -102,8 +102,8 @@ #.Nil (#.Cons [_var _original _current] tx') - (if (is (:! (Var Unit) var) - (:! (Var Unit) _var)) + (if (is? (:! (Var Unit) var) + (:! (Var Unit) _var)) (#.Cons {#var (:! (Var Unit) _var) #original (:! Unit _original) #current (:! Unit value)} @@ -165,12 +165,12 @@ (def: (can-commit? tx) (-> Tx Bool) (list.every? (function [[_var _original _current]] - (is _original (read!! _var))) + (is? _original (read!! _var))) tx)) (def: (commit-var! [_var _original _current]) (-> (Ex [a] (Tx-Frame a)) Unit) - (if (is _original _current) + (if (is? _original _current) [] (io.run (write! _current _var)))) diff --git a/stdlib/source/lux/data/coll/bits.lux b/stdlib/source/lux/data/coll/bits.lux index 64d404c1a..9a081c254 100644 --- a/stdlib/source/lux/data/coll/bits.lux +++ b/stdlib/source/lux/data/coll/bits.lux @@ -70,7 +70,7 @@ no-op) chunk - (|> (if (is ..empty output) + (|> (if (is? ..empty output) (: Bits (array.new size|output)) output) (array.write idx|output chunk) @@ -111,7 +111,7 @@ chunk (if (n/> +0 size|output) - (|> (if (is ..empty output) + (|> (if (is? ..empty output) (: Bits (array.new size|output)) output) (array.write idx chunk) @@ -136,7 +136,7 @@ (recur (n/dec size|output) output) chunk - (|> (if (is ..empty output) + (|> (if (is? ..empty output) (: Bits (array.new size|output)) output) (array.write idx chunk) diff --git a/stdlib/source/lux/data/coll/dict.lux b/stdlib/source/lux/data/coll/dict.lux index 1091100b6..4c25216c4 100644 --- a/stdlib/source/lux/data/coll/dict.lux +++ b/stdlib/source/lux/data/coll/dict.lux @@ -389,7 +389,7 @@ (#.Some sub-node) (let [sub-node' (remove' (level-up level) hash key Hash sub-node)] ## Then check if a removal was actually done. - (if (is sub-node sub-node') + (if (is? sub-node sub-node') ## If not, then there's nothing to change here either. node ## But if the sub-removal yielded an empty sub-node... @@ -418,7 +418,7 @@ (#.Some (#.Left sub-node)) (let [sub-node' (remove' (level-up level) hash key Hash sub-node)] ## Verify that it was removed. - (if (is sub-node sub-node') + (if (is? sub-node sub-node') ## If not, there's also nothing to change here. node ## But if it came out empty... diff --git a/stdlib/source/lux/data/coll/ordered/dict.lux b/stdlib/source/lux/data/coll/ordered/dict.lux index 3b19c232a..81e6a3be4 100644 --- a/stdlib/source/lux/data/coll/ordered/dict.lux +++ b/stdlib/source/lux/data/coll/ordered/dict.lux @@ -255,7 +255,7 @@ [( reference key) (let [side-root (get@ root) outcome (recur side-root)] - (if (is side-root outcome) + (if (is? side-root outcome) ?root (#.Some ( (maybe.assume outcome) root))))] diff --git a/stdlib/source/lux/data/coll/tree/parser.lux b/stdlib/source/lux/data/coll/tree/parser.lux index 726a04146..c9bf542f3 100644 --- a/stdlib/source/lux/data/coll/tree/parser.lux +++ b/stdlib/source/lux/data/coll/tree/parser.lux @@ -34,7 +34,7 @@ (All [t] (Parser t [])) (function [zipper] (let [next ( zipper)] - (if (is zipper next) + (if (is? zipper next) (ex.throw Cannot-Move-Further []) (#E.Success [next []])))))] diff --git a/stdlib/source/lux/data/error.lux b/stdlib/source/lux/data/error.lux index 773724321..b619dc1ad 100644 --- a/stdlib/source/lux/data/error.lux +++ b/stdlib/source/lux/data/error.lux @@ -81,10 +81,10 @@ (macro: #export (default tokens compiler) {#.doc (doc "Allows you to provide a default value that will be used" "if a (Error x) value turns out to be #Error." - (is 10 - (default 20 (#Success 10))) - (is 20 - (default 20 (#Error "KABOOM!"))))} + (is? 10 + (default 20 (#Success 10))) + (is? 20 + (default 20 (#Error "KABOOM!"))))} (case tokens (^ (list else error)) (#Success [compiler (list (` (case (~ error) diff --git a/stdlib/source/lux/lang/type/check.lux b/stdlib/source/lux/lang/type/check.lux index 59f27ad43..ccb7780e2 100644 --- a/stdlib/source/lux/lang/type/check.lux +++ b/stdlib/source/lux/lang/type/check.lux @@ -516,7 +516,7 @@ (def: #export (check' expected actual assumptions) {#.doc "Type-check to ensure that the 'expected' type subsumes the 'actual' type."} (-> Type Type (List Assumption) (Check (List Assumption))) - (if (is expected actual) + (if (is? expected actual) (check/wrap assumptions) (with-error-stack (function [_] (ex.construct Type-Check-Failed [expected actual])) diff --git a/stdlib/source/lux/test.lux b/stdlib/source/lux/test.lux index e000f6130..d18c74df8 100644 --- a/stdlib/source/lux/test.lux +++ b/stdlib/source/lux/test.lux @@ -147,11 +147,11 @@ false))) (test "Can have defaults for Maybe values." - (and (is "yolo" (maybe.default "yolo" - #.None)) + (and (is? "yolo" (maybe.default "yolo" + #.None)) - (is "lol" (maybe.default "yolo" - (#.Some "lol"))))) + (is? "lol" (maybe.default "yolo" + (#.Some "lol"))))) )) "Also works with random generation of values for property-based testing." diff --git a/stdlib/test/test/lux.lux b/stdlib/test/test/lux.lux index f5c5fd2f1..b8861eab6 100644 --- a/stdlib/test/test/lux.lux +++ b/stdlib/test/test/lux.lux @@ -18,11 +18,11 @@ y (r.text size)] ($_ seq (test "Every value is identical to itself, and the 'id' function doesn't change values in any way." - (and (is x x) - (is x (id x)))) + (and (is? x x) + (is? x (id x)))) (test "Values created separately can't be identical." - (not (is x y))) + (not (is? x y))) )))) (do-template [category rand-gen inc dec even? odd? = < >] @@ -183,11 +183,11 @@ false))) (test "Can have defaults for Maybe values." - (and (is "yolo" (maybe.default "yolo" - #.None)) + (and (is? "yolo" (maybe.default "yolo" + #.None)) - (is "lol" (maybe.default "yolo" - (#.Some "lol"))))) + (is? "lol" (maybe.default "yolo" + (#.Some "lol"))))) )) (template: (hypotenuse x y) diff --git a/stdlib/test/test/lux/control/parser.lux b/stdlib/test/test/lux/control/parser.lux index 64e8fac32..ae69d8ec9 100644 --- a/stdlib/test/test/lux/control/parser.lux +++ b/stdlib/test/test/lux/control/parser.lux @@ -42,15 +42,6 @@ _ false)) -(def: (is? Eq test parser input) - (All [s a] (-> (Eq a) a (&.Parser s a) s Bool)) - (case (&.run input parser) - (#E.Success [_ output]) - (:: Eq = test output) - - _ - false)) - (def: (fails? input) (All [a] (-> (E.Error a) Bool)) (case input diff --git a/stdlib/test/test/lux/data/coll/array.lux b/stdlib/test/test/lux/data/coll/array.lux index cd834a41e..289e7e988 100644 --- a/stdlib/test/test/lux/data/coll/array.lux +++ b/stdlib/test/test/lux/data/coll/array.lux @@ -30,11 +30,11 @@ (n/= size (@.size original))) (test "Cloning an array should yield and identical array, but not the same one." (and (:: (@.Eq number.Eq) = original clone) - (not (is original clone)))) + (not (is? original clone)))) (test "Full-range manual copies should give the same result as cloning." (exec (@.copy size +0 original +0 copy) (and (:: (@.Eq number.Eq) = original copy) - (not (is original copy))))) + (not (is? original copy))))) (test "Array folding should go over all values." (exec (:: @.Fold fold (function [x idx] @@ -107,7 +107,7 @@ (test "Functor shouldn't alter original array." (let [copy (map id array)] (and (= array copy) - (not (is array copy))))) + (not (is? array copy))))) (test "Functor should go over all available array elements." (let [there (map n/inc array) back-again (map n/dec there)] diff --git a/stdlib/test/test/lux/data/coll/bits.lux b/stdlib/test/test/lux/data/coll/bits.lux index ccf0ff63d..d33fa61b1 100644 --- a/stdlib/test/test/lux/data/coll/bits.lux +++ b/stdlib/test/test/lux/data/coll/bits.lux @@ -44,7 +44,7 @@ (test "Bits (must) shrink when (and as much as) possible." (let [grown (/.flip idx /.empty)] (and (n/> +0 (/.capacity grown)) - (is /.empty (/.flip idx grown))))) + (is? /.empty (/.flip idx grown))))) (test "Intersection can be detected when there are set bits in common." (and (not (/.intersects? /.empty @@ -59,14 +59,14 @@ (test "'and' with oneself changes nothing" (:: /.Eq = sample (/.and sample sample))) (test "'and' with one's opposite yields the empty bit-set." - (is /.empty (/.and sample (/.not sample)))) + (is? /.empty (/.and sample (/.not sample)))) (test "'or' with one's opposite fully saturates a bit-set." (n/= (/.size (/.or sample (/.not sample))) (/.capacity sample))) (test "'xor' with oneself yields the empty bit-set." - (is /.empty (/.xor sample sample))) + (is? /.empty (/.xor sample sample))) (test "'xor' with one's opposite fully saturates a bit-set." (n/= (/.size (/.xor sample (/.not sample))) (/.capacity sample))) @@ -74,7 +74,7 @@ (test "Double negation results in original bit-set." (:: /.Eq = sample (/.not (/.not sample)))) (test "Negation does not affect the empty bit-set." - (is /.empty (/.not /.empty))) + (is? /.empty (/.not /.empty))) (_eq.spec /.Eq ..bits) )))) diff --git a/stdlib/test/test/lux/data/coll/sequence.lux b/stdlib/test/test/lux/data/coll/sequence.lux index 145493c3e..afeca6154 100644 --- a/stdlib/test/test/lux/data/coll/sequence.lux +++ b/stdlib/test/test/lux/data/coll/sequence.lux @@ -37,7 +37,7 @@ (&.put idx non-member) (&.nth idx) maybe.assume - (is non-member))) + (is? non-member))) (test "Can update elements of sequences." (|> sample diff --git a/stdlib/test/test/lux/data/coll/stack.lux b/stdlib/test/test/lux/data/coll/stack.lux index c5f1e598f..216c1a8c5 100644 --- a/stdlib/test/test/lux/data/coll/stack.lux +++ b/stdlib/test/test/lux/data/coll/stack.lux @@ -37,9 +37,9 @@ )) (test "Pushing onto a stack always increases it by 1, adding a new value at the top." - (and (is sample - (&.pop (&.push new-top sample))) + (and (is? sample + (&.pop (&.push new-top sample))) (n/= (n/inc (&.size sample)) (&.size (&.push new-top sample))) (|> (&.push new-top sample) &.peek maybe.assume - (is new-top)))) + (is? new-top)))) )))) diff --git a/stdlib/test/test/lux/data/coll/tree/zipper.lux b/stdlib/test/test/lux/data/coll/tree/zipper.lux index 1347ee7bd..831cc9573 100644 --- a/stdlib/test/test/lux/data/coll/tree/zipper.lux +++ b/stdlib/test/test/lux/data/coll/tree/zipper.lux @@ -52,8 +52,8 @@ (if (&.branch? zipper) (let [child (|> zipper &.down)] (and (not (tree/= sample (&.unzip child))) - (|> child &.up (is zipper) not) - (|> child &.root (is zipper) not))) + (|> child &.up (is? zipper) not) + (|> child &.root (is? zipper) not))) (and (&.leaf? zipper) (|> zipper (&.prepend-child new-val) &.branch?))))) @@ -64,12 +64,12 @@ zipper (|> zipper (&.prepend-child pre-val) (&.append-child post-val))] - (and (|> zipper &.down &.value (is pre-val)) - (|> zipper &.down &.right &.value (is mid-val)) - (|> zipper &.down &.right &.right &.value (is post-val)) - (|> zipper &.down &.rightmost &.leftmost &.value (is pre-val)) - (|> zipper &.down &.right &.left &.value (is pre-val)) - (|> zipper &.down &.rightmost &.value (is post-val)))) + (and (|> zipper &.down &.value (is? pre-val)) + (|> zipper &.down &.right &.value (is? mid-val)) + (|> zipper &.down &.right &.right &.value (is? post-val)) + (|> zipper &.down &.rightmost &.leftmost &.value (is? pre-val)) + (|> zipper &.down &.right &.left &.value (is? pre-val)) + (|> zipper &.down &.rightmost &.value (is? post-val)))) true))) (test "Can insert children around a node (unless it's root)." @@ -83,12 +83,12 @@ (&.insert-right post-val) maybe.assume &.up)] - (and (|> zipper &.down &.value (is pre-val)) - (|> zipper &.down &.right &.value (is mid-val)) - (|> zipper &.down &.right &.right &.value (is post-val)) - (|> zipper &.down &.rightmost &.leftmost &.value (is pre-val)) - (|> zipper &.down &.right &.left &.value (is pre-val)) - (|> zipper &.down &.rightmost &.value (is post-val)))) + (and (|> zipper &.down &.value (is? pre-val)) + (|> zipper &.down &.right &.value (is? mid-val)) + (|> zipper &.down &.right &.right &.value (is? post-val)) + (|> zipper &.down &.rightmost &.leftmost &.value (is? pre-val)) + (|> zipper &.down &.right &.left &.value (is? pre-val)) + (|> zipper &.down &.rightmost &.value (is? post-val)))) (and (|> zipper (&.insert-left pre-val) (case> (#.Some _) false #.None true)) (|> zipper (&.insert-right post-val) (case> (#.Some _) false diff --git a/stdlib/test/test/lux/data/ident.lux b/stdlib/test/test/lux/data/ident.lux index 2e3b59853..d6732619e 100644 --- a/stdlib/test/test/lux/data/ident.lux +++ b/stdlib/test/test/lux/data/ident.lux @@ -32,8 +32,8 @@ (^open "&/") &.Codec]] ($_ seq (test "Can get the module & name parts of an ident." - (and (is module1 (&.module ident1)) - (is name1 (&.name ident1)))) + (and (is? module1 (&.module ident1)) + (is? name1 (&.name ident1)))) (test "Can compare idents for equality." (and (&/= ident1 ident1) diff --git a/stdlib/test/test/lux/data/lazy.lux b/stdlib/test/test/lux/data/lazy.lux index c007990de..1b8a76730 100644 --- a/stdlib/test/test/lux/data/lazy.lux +++ b/stdlib/test/test/lux/data/lazy.lux @@ -18,10 +18,10 @@ (n/= expected (&.thaw lazy))) (test "Lazy values only evaluate once." - (and (not (is expected - (&.thaw lazy))) - (is (&.thaw lazy) - (&.thaw lazy)))) + (and (not (is? expected + (&.thaw lazy))) + (is? (&.thaw lazy) + (&.thaw lazy)))) )))) (context: "Functor, Applicative, Monad." diff --git a/stdlib/test/test/lux/host.js.lux b/stdlib/test/test/lux/host.js.lux index c7d65343a..49b15d7e4 100644 --- a/stdlib/test/test/lux/host.js.lux +++ b/stdlib/test/test/lux/host.js.lux @@ -1,4 +1,4 @@ -(;module: +(.module: lux (lux [io] (control ["M" monad #+ do Monad]) @@ -10,22 +10,22 @@ (context: "JavaScript operations" ($_ seq (test "Null equals itself." - (is (&;null) (&;null))) + (is? (&.null) (&.null))) (test "Undefined equals itself." - (is (&;undef) (&;undef))) + (is? (&.undef) (&.undef))) (test "Can reference JavaScript objects." - (is (&;ref "Math") (&;ref "Math"))) + (is? (&.ref "Math") (&.ref "Math"))) (test "Can create objects and access their fields." - (|> (&;object "foo" "BAR") - (&;get "foo" Text) - (is "BAR"))) + (|> (&.object "foo" "BAR") + (&.get "foo" Text) + (is? "BAR"))) (test "Can call JavaScript functions" - (and (is 124.0 - (&;call! (&;ref "Math.ceil" &;Function) [123.45] Frac)) - (is 124.0 - (&;call! (&;ref "Math") "ceil" [123.45] Frac)))) + (and (is? 124.0 + (&.call! (&.ref "Math.ceil" &.Function) [123.45] Frac)) + (is? 124.0 + (&.call! (&.ref "Math") "ceil" [123.45] Frac)))) )) diff --git a/stdlib/test/test/lux/macro/syntax.lux b/stdlib/test/test/lux/macro/syntax.lux index f53af1cb7..5c5ea835f 100644 --- a/stdlib/test/test/lux/macro/syntax.lux +++ b/stdlib/test/test/lux/macro/syntax.lux @@ -9,7 +9,7 @@ [number] [bool] [ident] - ["E" error]) + ["e" error]) ["r" math/random] [macro] (macro [code] @@ -35,17 +35,17 @@ _ false)) -(def: (is? Eq test parser input) +(def: (equals? Eq reference parser input) (All [a] (-> (Eq a) a (Syntax a) (List Code) Bool)) (case (p.run input parser) (#.Right [_ output]) - (:: Eq = test output) + (:: Eq = reference output) _ false)) (def: (fails? input) - (All [a] (-> (E.Error a) Bool)) + (All [a] (-> (e.Error a) Bool)) (case input (#.Left _) true @@ -66,7 +66,7 @@ (with-expansions [ (do-template [ ] [(test - (and (is? (list ( ))) + (and (equals? (list ( ))) (found? (s.this? ( )) (list ( ))) (enforced? (s.this ( )) (list ( )))))] diff --git a/stdlib/test/test/lux/math/constructive.lux b/stdlib/test/test/lux/math/constructive.lux index 715a9a60c..86f8b7360 100644 --- a/stdlib/test/test/lux/math/constructive.lux +++ b/stdlib/test/test/lux/math/constructive.lux @@ -25,7 +25,7 @@ (theorem: #export [t] (is {reference t} {sample t}) (Test (equality reference sample)) - (.if (.is reference sample) + (.if (.is? reference sample) (#_.True (.let [the-axiom (axiom "is")] the-axiom)) (#_.False absurdity))) -- cgit v1.2.3