diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/internal/cell_spec.moon | 6 | ||||
| -rw-r--r-- | spec/lib/array_spec.moon | 76 | ||||
| -rw-r--r-- | spec/lib/builtins/cond_spec.moon | 10 | ||||
| -rw-r--r-- | spec/lib/builtins/literal_spec.moon | 4 | ||||
| -rw-r--r-- | spec/lib/logic_spec.moon | 56 | ||||
| -rw-r--r-- | spec/lib/math_spec.moon | 162 | ||||
| -rw-r--r-- | spec/lib/string_spec.moon | 26 | ||||
| -rw-r--r-- | spec/lib/struct_spec.moon | 20 | ||||
| -rw-r--r-- | spec/lib/testing_spec.moon | 4 |
9 files changed, 181 insertions, 183 deletions
diff --git a/spec/internal/cell_spec.moon b/spec/internal/cell_spec.moon index bd97e63..c9ccb39 100644 --- a/spec/internal/cell_spec.moon +++ b/spec/internal/cell_spec.moon @@ -39,18 +39,18 @@ describe 'Cell', -> describe 'RootCell', -> test 'tag is always [0]', -> - cell = RootCell.parse {} + cell = RootCell\parse {} assert.is.equal '[0]', cell.tag\stringify! test 'head is always "do"', -> - cell = RootCell.parse {} + cell = RootCell\parse {} assert.is.equal (Constant.sym 'do'), cell\head! cell = RootCell nil, { hello_world, two_plus_two } assert.is.equal (Constant.sym 'do'), cell\head! test 'tail is all children', -> - cell = RootCell.parse {} + cell = RootCell\parse {} assert.is.same {}, cell\tail! cell = RootCell nil, { hello_world, two_plus_two } diff --git a/spec/lib/array_spec.moon b/spec/lib/array_spec.moon index b55cec6..130138c 100644 --- a/spec/lib/array_spec.moon +++ b/spec/lib/array_spec.moon @@ -2,147 +2,147 @@ import TestPilot from require 'spec.test_setup' import T, Array from require 'alv' describe "array", -> - test = TestPilot '', '(import* array-)\n' + test = TestPilot '', '(import* array)\n' svec3 = Array 3, T.str it "can contain any type", -> - COPILOT\eval_once '(array 1 2 3)' - COPILOT\eval_once '(array true false)' - COPILOT\eval_once '(array "a")' - COPILOT\eval_once '(array (array 1 2) (array 3 4))' + COPILOT\eval_once '[1 2 3]' + COPILOT\eval_once '[true false]' + COPILOT\eval_once '["a"]' + COPILOT\eval_once '[[1 2] [3 4]]' it "cannot contain mixed types", -> - err = assert.has.error -> COPILOT\eval_once '(array 1 false)' + err = assert.has.error -> COPILOT\eval_once '[1 false]' assert.matches "argument error: couldn't match arguments", err describe "(set)", -> it "can swap values", -> - rt = COPILOT\eval_once '(set (array "f" "b" "c") 0 "a")' + rt = COPILOT\eval_once '(set ["f" "b" "c"] 0 "a")' assert.is.true rt\is_const! assert.is.equal svec3\mk_const({ 'a', 'b', 'c' }), rt.result it "checks value type", -> - err = assert.has.error -> COPILOT\eval_once '(set (array 1) 0 "a")' + err = assert.has.error -> COPILOT\eval_once '(set [1] 0 "a")' assert.matches "expected value of type num, not str", err it "checks index range", -> - err = assert.has.error -> COPILOT\eval_once '(set (array 1 2) -1 0)' + err = assert.has.error -> COPILOT\eval_once '(set [1 2] -1 0)' assert.matches "index '%-1' out of range!", err - COPILOT\eval_once '(set (array 1 2) 0 0)' + COPILOT\eval_once '(set [1 2] 0 0)' - COPILOT\eval_once '(set (array 1 2) 1 0)' + COPILOT\eval_once '(set [1 2] 1 0)' - err = assert.has.error -> COPILOT\eval_once '(set (array 1 2) 2 0)' + err = assert.has.error -> COPILOT\eval_once '(set [1 2] 2 0)' assert.matches "index '2' out of range!", err describe "(get)", -> it "can get a value", -> - rt = COPILOT\eval_once '(get (array 1 2) 0)' + rt = COPILOT\eval_once '(get [1 2] 0)' assert.is.true rt\is_const! assert.is.equal '<num= 1>', tostring rt.result it "checks index range", -> - err = assert.has.error -> COPILOT\eval_once '(get (array 1 2) -1)' + err = assert.has.error -> COPILOT\eval_once '(get [1 2] -1)' assert.matches "index '%-1' out of range!", err - COPILOT\eval_once '(get (array 1 2) 0)' + COPILOT\eval_once '(get [1 2] 0)' - COPILOT\eval_once '(get (array 1 2) 1)' + COPILOT\eval_once '(get [1 2] 1)' - err = assert.has.error -> COPILOT\eval_once '(get (array 1 2) 2)' + err = assert.has.error -> COPILOT\eval_once '(get [1 2] 2)' assert.matches "index '2' out of range!", err describe '(head)', -> it "can peek a value", -> - rt = COPILOT\eval_once '(head (array 1 2))' + rt = COPILOT\eval_once '(head [1 2])' assert.is.true rt\is_const! assert.is.equal '<num= 1>', tostring rt.result describe '(tail)', -> it "gets rest of an array", -> - rt = COPILOT\eval_once '(tail (array 1))' + rt = COPILOT\eval_once '(tail [1])' assert.is.true rt\is_const! assert.is.same (Array 0, T.num), rt.result.type assert.is.same {}, rt.result! - rt = COPILOT\eval_once '(tail (array 1 2))' + rt = COPILOT\eval_once '(tail [1 2])' assert.is.true rt\is_const! assert.is.same (Array 1, T.num), rt.result.type assert.is.same { 2 }, rt.result! - rt = COPILOT\eval_once '(tail (array 1 2 3 4))' + rt = COPILOT\eval_once '(tail [1 2 3 4])' assert.is.true rt\is_const! assert.is.same (Array 3, T.num), rt.result.type assert.is.same { 2, 3, 4 }, rt.result! describe '(prepend)', -> it "prepends to array", -> - rt = COPILOT\eval_once '(prepend (array 2) 1)' + rt = COPILOT\eval_once '(prepend [2] 1)' assert.is.true rt\is_const! assert.is.same (Array 2, T.num), rt.result.type assert.is.same { 1, 2 }, rt.result! - rt = COPILOT\eval_once '(prepend (array 2 3 4) 1)' + rt = COPILOT\eval_once '(prepend [2 3 4] 1)' assert.is.true rt\is_const! assert.is.same (Array 4, T.num), rt.result.type assert.is.same { 1, 2, 3, 4 }, rt.result! describe "(insert)", -> it "can insert a value", -> - rt = COPILOT\eval_once '(insert (array "b" "c") 0 "a")' + rt = COPILOT\eval_once '(insert ["b" "c"] 0 "a")' assert.is.true rt\is_const! assert.is.equal svec3\mk_const({ 'a', 'b', 'c' }), rt.result - rt = COPILOT\eval_once '(insert (array "a" "c") 1 "b")' + rt = COPILOT\eval_once '(insert ["a" "c"] 1 "b")' assert.is.true rt\is_const! assert.is.equal svec3\mk_const({ 'a', 'b', 'c' }), rt.result - rt = COPILOT\eval_once '(insert (array "a" "b") 2 "c")' + rt = COPILOT\eval_once '(insert ["a" "b"] 2 "c")' assert.is.true rt\is_const! assert.is.equal svec3\mk_const({ 'a', 'b', 'c' }), rt.result it "checks index range", -> - err = assert.has.error -> COPILOT\eval_once '(insert (array 1 2) -1 0)' + err = assert.has.error -> COPILOT\eval_once '(insert [1 2] -1 0)' assert.matches "index '%-1' out of range!", err - COPILOT\eval_once '(insert (array 1 2) 0 0)' + COPILOT\eval_once '(insert [1 2] 0 0)' - COPILOT\eval_once '(insert (array 1 2) 1 0)' + COPILOT\eval_once '(insert [1 2] 1 0)' - COPILOT\eval_once '(insert (array 1 2) 2 0)' + COPILOT\eval_once '(insert [1 2] 2 0)' - err = assert.has.error -> COPILOT\eval_once '(insert (array 1 2) 3 0)' + err = assert.has.error -> COPILOT\eval_once '(insert [1 2] 3 0)' assert.matches "index '3' out of range!", err describe "(remove)", -> it "can remove a value", -> - rt = COPILOT\eval_once '(remove (array "d" "a" "b" "c") 0)' + rt = COPILOT\eval_once '(remove ["d" "a" "b" "c"] 0)' assert.is.true rt\is_const! assert.is.equal svec3\mk_const({ 'a', 'b', 'c' }), rt.result - rt = COPILOT\eval_once '(remove (array "a" "b" "c" "d") 3)' + rt = COPILOT\eval_once '(remove ["a" "b" "c" "d"] 3)' assert.is.true rt\is_const! assert.is.equal svec3\mk_const({ 'a', 'b', 'c' }), rt.result it "checks index range", -> - err = assert.has.error -> COPILOT\eval_once '(remove (array 1 2 3) -1)' + err = assert.has.error -> COPILOT\eval_once '(remove [1 2 3] -1)' assert.matches "index '%-1' out of range!", err - err = assert.has.error -> COPILOT\eval_once '(remove (array 1 2 3) 3)' + err = assert.has.error -> COPILOT\eval_once '(remove [1 2 3] 3)' assert.matches "index '3' out of range!", err it "can be concatenated with (concat)", -> - rt = COPILOT\eval_once '(concat (array "a" "b") (array "c"))' + rt = COPILOT\eval_once '(concat ["a" "b"] ["c"])' assert.is.true rt\is_const! assert.is.equal svec3\mk_const({ 'a', 'b', 'c' }), rt.result it "size can be read using (size)", -> - rt = COPILOT\eval_once '(size (array 1))' + rt = COPILOT\eval_once '(size [1])' assert.is.true rt\is_const! assert.is.equal '<num= 1>', tostring rt.result - rt = COPILOT\eval_once '(size (array 1 2 3))' + rt = COPILOT\eval_once '(size [1 2 3])' assert.is.true rt\is_const! assert.is.equal '<num= 3>', tostring rt.result diff --git a/spec/lib/builtins/cond_spec.moon b/spec/lib/builtins/cond_spec.moon index 04c56ef..b075f8b 100644 --- a/spec/lib/builtins/cond_spec.moon +++ b/spec/lib/builtins/cond_spec.moon @@ -5,7 +5,7 @@ describe "if", -> COPILOT = TestPilot! it "checks truthiness", -> - for truthy in *{'true', '1', '-1', '1234', '(array 1 2 3)', '"test"', '""'} + for truthy in *{'true', '1', '-1', '1234', '[1 2 3]', '"test"', '""'} with COPILOT\eval_once "(if #{truthy} 'yes' 'no')" assert.is.true \is_const! assert.is.equal 'yes', .result! @@ -41,7 +41,7 @@ describe "if", -> it "forwards any result", -> with COPILOT\eval_once ' (import* time) - (if true (every 1 (array 1 2 3)))' + (if true (every 1 [1 2 3]))' assert.is.false \is_const! assert.is.equal '<num[3]! nil>', tostring .result @@ -49,7 +49,7 @@ describe "when", -> COPILOT = TestPilot! it "checks truthiness", -> - for truthy in *{'true', '1', '-1', '1234', '(array 1 2 3)', '"test"', '""'} + for truthy in *{'true', '1', '-1', '1234', '[1 2 3]', '"test"', '""'} with COPILOT\eval_once "(when #{truthy} 'yes')" assert.is.true \is_const! assert.is.equal 'yes', .result! @@ -81,12 +81,12 @@ describe "when", -> with COPILOT\eval_once ' (import* time) (when true - (every 1 (array 1 2 3)) + (every 1 [1 2 3]) 1 2 3)' assert.is.false \is_const! assert.is.equal '<num~ 3>', tostring .result - with COPILOT\eval_once '(when true (array 1 2 3))' + with COPILOT\eval_once '(when true [1 2 3])' assert.is.true \is_const! assert.is.equal '<num[3]= [1 2 3]>', tostring .result diff --git a/spec/lib/builtins/literal_spec.moon b/spec/lib/builtins/literal_spec.moon index 3db010d..61a9b90 100644 --- a/spec/lib/builtins/literal_spec.moon +++ b/spec/lib/builtins/literal_spec.moon @@ -6,8 +6,8 @@ describe "literal", -> (def str "hello" num 2 bool true - curl ([5]struct "a" 2 "b" false) - sqre ([7]array 1 2 3 4)) + curl {"a" 2 "b" false} + sqre [1 2 3 4]) (export*)' assert.is.true COPILOT.active_module.root\is_const! diff --git a/spec/lib/logic_spec.moon b/spec/lib/logic_spec.moon index 2760e54..5b71465 100644 --- a/spec/lib/logic_spec.moon +++ b/spec/lib/logic_spec.moon @@ -9,25 +9,25 @@ describe "logic", -> (expect= false (== 1 2)) (expect= false (== 1 "hello")) (expect= true (== "hello" "hello")) - (expect= true (== (array 1 2 3) (array 1 2 3))) - (expect= false (== (array 1 2 3) (array 1 2 1))) - (expect= false (== (array 1 2 3) (array 1 2))) - (expect= false (== (array 1 2 3) (array 1 2 3 4))) + (expect= true (== [1 2 3] [1 2 3])) + (expect= false (== [1 2 3] [1 2 1])) + (expect= false (== [1 2 3] [1 2])) + (expect= false (== [1 2 3] [1 2 3 4])) (expect= true (== - (struct "a" 1 "b" true "c" (array "test")) - (struct "a" 1 "b" true "c" (array "test")))) + {"a" 1 "b" true "c" ["test"]} + {"a" 1 "b" true "c" ["test"]})) (expect= false (== - (struct "a" 1 "b" false "c" (array "test")) - (struct "a" 1 "b" true "c" (array "test")))) + {"a" 1 "b" false "c" ["test"]} + {"a" 1 "b" true "c" ["test"]})) (expect= false (== - (struct "a" 1 "b" true "c" (array "test" "toast")) - (struct "a" 1 "b" true "c" (array "test")))) + {"a" 1 "b" true "c" ["test" "toast"]} + {"a" 1 "b" true "c" ["test"]})) (expect= false (== - (struct "a" 1 "b" true) - (struct "a" 1 "b" true "c" (array "test")))) + {"a" 1 "b" true} + {"a" 1 "b" true "c" ["test"]})) (expect= false (== - (struct "a" 1 "b" true) - (struct "a" 1))) + {"a" 1 "b" true} + {"a" 1})) (expect= true (== print print)) (expect= false (== print ==)) ' @@ -42,25 +42,25 @@ describe "logic", -> (expect= true (!= 1 2)) (expect= true (!= 1 "hello")) (expect= false (!= "hello" "hello")) - (expect= false (!= (array 1 2 3) (array 1 2 3))) - (expect= true (!= (array 1 2 3) (array 1 2 1))) - (expect= true (!= (array 1 2 3) (array 1 2))) - (expect= true (!= (array 1 2 3) (array 1 2 3 4))) + (expect= false (!= [1 2 3] [1 2 3])) + (expect= true (!= [1 2 3] [1 2 1])) + (expect= true (!= [1 2 3] [1 2])) + (expect= true (!= [1 2 3] [1 2 3 4])) (expect= false (!= - (struct "a" 1 "b" true "c" (array "test")) - (struct "a" 1 "b" true "c" (array "test")))) + {"a" 1 "b" true "c" ["test"]} + {"a" 1 "b" true "c" ["test"]})) (expect= true (!= - (struct "a" 1 "b" false "c" (array "test")) - (struct "a" 1 "b" true "c" (array "test")))) + {"a" 1 "b" false "c" ["test"]} + {"a" 1 "b" true "c" ["test"]})) (expect= true (!= - (struct "a" 1 "b" true "c" (array "test" "toast")) - (struct "a" 1 "b" true "c" (array "test")))) + {"a" 1 "b" true "c" ["test" "toast"]} + {"a" 1 "b" true "c" ["test"]})) (expect= true (!= - (struct "a" 1 "b" true) - (struct "a" 1 "b" true "c" (array "test")))) + {"a" 1 "b" true} + {"a" 1 "b" true "c" ["test"]})) (expect= true (!= - (struct "a" 1 "b" true) - (struct "a" 1))) + {"a" 1 "b" true} + {"a" 1})) (expect= false (!= print print)) (expect= true (!= print ==)) ' diff --git a/spec/lib/math_spec.moon b/spec/lib/math_spec.moon index 23a353b..40c7abd 100644 --- a/spec/lib/math_spec.moon +++ b/spec/lib/math_spec.moon @@ -88,85 +88,83 @@ describe "math", -> describe "add, sub, mul, div, pow, mod", -> it "handle scalar/vector", -> COPILOT\eval_once ' - (expect= (array 3 4 5) - (+ 1 (array 1 2 3) 1)) + (expect= [3 4 5] + (+ 1 [1 2 3] 1)) - (expect= (array 0 1 2) - (- (array 1 2 3) 1)) + (expect= [0 1 2] + (- [1 2 3] 1)) - (expect= (array 3 6 9) - (* 3 (array 1 2 3))) - (expect= (array 3 6 9) - (* (array 1 2 3) 3)) + (expect= [3 6 9] + (* 3 [1 2 3])) + (expect= [3 6 9] + (* [1 2 3] 3)) - (expect= (array 12 9 4) - (/ 36 (array 3 4 9))) + (expect= [12 9 4] + (/ 36 [3 4 9])) - (expect= (array 9 16 25) - (^ (array 3 4 5) 2)) - (expect= (array 1 2 4 8) - (^ 2 (array 0 1 2 3))) + (expect= [9 16 25] + (^ [3 4 5] 2)) + (expect= [1 2 4 8] + (^ 2 [0 1 2 3])) - (expect= (array 3 0 1) - (% (array 3 4 5) 4)) + (expect= [3 0 1] + (% [3 4 5] 4)) ' it "handle vector/vector and matrix/matrix", -> COPILOT\eval_once ' - (expect= (array 5 7 9) - (+ (array 1 2 3) - (array 4 5 6))) + (expect= [5 7 9] + (+ [1 2 3] + [4 5 6])) - (expect= (array (array 11 12) - (array 13 14)) + (expect= [[11 12] + [13 14]] (+ - (array (array 1 2) - (array 3 4)) + [[1 2] + [3 4]] 5 5)) - (expect= (array 2 0 -2) - (- (array 3 2 1) - (array 1 2 3))) + (expect= [2 0 -2] + (- [3 2 1] + [1 2 3])) - (expect= (array 1 -2 -3) - (- (array -1 2 3))) + (expect= [1 -2 -3] + (- [-1 2 3])) ' err = assert.has.error -> COPILOT\eval_once ' - (+ (array 1 2 3) - (array 1 2))' + (+ [1 2 3] + [1 2])' err = assert.has.error -> COPILOT\eval_once ' - (+ (array (array 1 2) (array 1 2)) - (array 1 2))' + (+ [[1 2] [1 2]] + [1 2])' err = assert.has.error -> COPILOT\eval_once ' - (- (array 1 2 3) - (array 1 2))' + (- [1 2 3] + [1 2])' err = assert.has.error -> COPILOT\eval_once ' - (- (array (array 1 2) (array 1 2)) - (array 1 2))' + (- [[1 2] [1 2]] + [1 2])' describe "mul", -> it "handles scalars and matrices", -> with COPILOT\eval_once ' (* 3 - (array - (array 1 2) - (array 4 5)))' + [[1 2] + [4 5]])' assert.is.true \is_const! assert.is.equal '<num[2][2]= [[3 6] [12 15]]>', tostring .result with COPILOT\eval_once ' - (* (array - (array 1 2) - (array 4 5)) + (* [[1 2] + [4 5]] 3)' assert.is.true \is_const! assert.is.equal '<num[2][2]= [[3 6] [12 15]]>', tostring .result @@ -174,90 +172,90 @@ describe "math", -> it "handles vectors and matrices", -> with COPILOT\eval_once ' (* - (array (array 1 0 0) - (array 0 1 0) - (array 0 0 1)) - (array 4 5 6))' + [[1 0 0] + [0 1 0] + [0 0 1]] + [4 5 6])' assert.is.true \is_const! assert.is.equal '<num[3]= [4 5 6]>', tostring .result with COPILOT\eval_once ' (* - (array (array 1 0 0) - (array 0 1 0) - (array 3 2 1)) - (array 4 5 1))' + [[1 0 0] + [0 1 0] + [3 2 1]] + [4 5 1])' assert.is.true \is_const! assert.is.equal '<num[3]= [4 5 23]>', tostring .result it "handles matrices", -> with COPILOT\eval_once ' (* - (array (array 1 2 3) - (array 4 5 6)) - (array (array 10 11) - (array 20 21) - (array 30 31)))' + [[1 2 3] + [4 5 6]] + [[10 11] + [20 21] + [30 31]])' assert.is.true \is_const! assert.is.equal '<num[2][2]= [[140 146] [320 335]]>', tostring .result it "handles everything mixed", -> with COPILOT\eval_once ' (* - (array (array 1 2 3) - (array 4 5 6)) + [[1 2 3] + [4 5 6]] 2 - (array (array 10 11) - (array 20 21) - (array 30 31)))' + [[10 11] + [20 21] + [30 31]])' assert.is.true \is_const! assert.is.equal '<num[2][2]= [[280 292] [640 670]]>', tostring .result with COPILOT\eval_once ' (* - (array (array 1 2 3) - (array 4 5 6)) + [[1 2 3] + [4 5 6]] 2 - (array (array 10 11) - (array 20 21) - (array 30 31)) - (array 4 7))' + [[10 11] + [20 21] + [30 31]] + [4 7])' assert.is.true \is_const! assert.is.equal '<num[2]= [3164 7250]>', tostring .result it "errors with wrong sizes (matrix and vector)", -> err = assert.has.error -> COPILOT\eval_once ' (* - (array (array 1 2 3) - (array 4 5 6)) - (array 1 2))' + [[1 2 3] + [4 5 6]] + [1 2])' -- assert.matches "", err err = assert.has.error -> COPILOT\eval_once ' (* - (array 1 2 3) - (array (array 1 2 3) - (array 4 5 6)))' + [1 2 3] + [[1 2 3] + [4 5 6]])' -- assert.matches "", err it "errors with wrong sizes (matrix)", -> err = assert.has.error -> COPILOT\eval_once ' (* - (array (array 1 2 3) - (array 4 5 6)) - (array (array 1 2) - (array 4 5)))' + [[1 2 3] + [4 5 6)] + [[1 2] + [4 5]])' -- assert.matches "", err it "min, max, clamp, huge", -> COPILOT\eval_once ' - (expect= (array 3 2 1) - (min (array 3 4 1) (array 5 2 huge))) - (expect= (array 5 huge 4) - (max (array 3 huge 4) (array 5 999 2))) + (expect= [3 2 1] + (min [3 4 1] [5 2 huge])) + (expect= [5 huge 4] + (max [3 huge 4] [5 999 2])) - (expect= (array -2 -1 0 1 3.5) - (clamp -2 3.5 (array -4 -1 0 1 4))) + (expect= [-2 -1 0 1 3.5] + (clamp -2 3.5 [-4 -1 0 1 4])) (expect= 1 (inc 0)) (expect= -1 (dec 0)) diff --git a/spec/lib/string_spec.moon b/spec/lib/string_spec.moon index 859c402..c787609 100644 --- a/spec/lib/string_spec.moon +++ b/spec/lib/string_spec.moon @@ -16,22 +16,22 @@ describe "string", -> it "stringifies arrays", -> COPILOT\eval_once ' - (expect= "[1 2 3]" (string/str (array 1 2 3))) - (expect= \'["a" "b" "c"]\' (string/str (array "a" "b" "c"))) + (expect= "[1 2 3]" (string/str [1 2 3])) + (expect= \'["a" "b" "c"]\' (string/str ["a" "b" "c"])) ' it "stringifies structs", -> COPILOT\eval_once ' (expect= \'{a: 1 b: true c: "hello"}\' - (string/str (struct "a" 1 - "b" true - "c" "hello"))) + (string/str {"a" 1 + "b" true + "c" "hello"})) ' it "stringifies deeply", -> COPILOT\eval_once ' (expect= "{a: {b: [1 2 3]}}" - (string/str (struct "a" (struct "b" (array 1 2 3))))) + (string/str {"a" {"b" [1 2 3]}})) ' it "joins multiple arguments", -> @@ -48,23 +48,23 @@ describe "string", -> describe "concat", -> it "concatenates string-arrays", -> COPILOT\eval_once ' - (expect= "hello" (string/concat (array "hello"))) - (expect= "helloworld" (string/concat (array "hello" "world"))) - (expect= "helloobeautifulworld" (string/concat (array "hello" "o" "beautiful" "world"))) + (expect= "hello" (string/concat ["hello"])) + (expect= "helloworld" (string/concat ["hello" "world"])) + (expect= "helloobeautifulworld" (string/concat ["hello" "o" "beautiful" "world"])) ' it "takes custom separator", -> COPILOT\eval_once ' - (expect= "a, b, c" (string/concat ", " (array "a" "b" "c"))) - (expect= "hello world" (string/concat " " (array "hello" "world"))) - (expect= "hello o beautiful world" (string/concat " " (array "hello" "o" "beautiful" "world"))) + (expect= "a, b, c" (string/concat ", " ["a" "b" "c"])) + (expect= "hello world" (string/concat " " ["hello" "world"])) + (expect= "hello o beautiful world" (string/concat " " ["hello" "o" "beautiful" "world"])) ' describe "join", -> it "concatenates and stringifies", -> COPILOT\eval_once ' (expect= "that is 1 beautiful tree" (string/join " " "that is" 1 "beautiful tree")) - (expect= "my favorite color is [0.9 0.2 1]" (string/join " " "my favorite color is" (array 0.9 0.2 1))) + (expect= "my favorite color is [0.9 0.2 1]" (string/join " " "my favorite color is" [0.9 0.2 1])) (expect= "i_am_snek" (string/join "_" "i" "am" "snek")) ' diff --git a/spec/lib/struct_spec.moon b/spec/lib/struct_spec.moon index 9937f99..94dcc5a 100644 --- a/spec/lib/struct_spec.moon +++ b/spec/lib/struct_spec.moon @@ -2,50 +2,50 @@ import TestPilot from require 'spec.test_setup' import T, Struct from require 'alv' describe "struct", -> - test = TestPilot '', '(import* struct-)\n' + test = TestPilot '', '(import* struct)\n' ab = Struct { a: T.num, b: T.bool } describe "(set)", -> it "can update values", -> - rt = COPILOT\eval_once '(set (struct "a" 1 "b" false) "a" 2)' + rt = COPILOT\eval_once '(set {"a" 1 "b" false} "a" 2)' assert.is.true rt\is_const! assert.is.equal ab\mk_const({ a: 2, b: false }), rt.result it "cannot add members", -> - err = assert.has.error -> COPILOT\eval_once '(set (struct "a" 1) "b" 2)' + err = assert.has.error -> COPILOT\eval_once '(set {"a" 1} "b" 2)' assert.matches "{a: num} has no 'b' key", err it "checks value type", -> - err = assert.has.error -> COPILOT\eval_once '(set (struct "a" 1) "a" "str")' + err = assert.has.error -> COPILOT\eval_once '(set {"a" 1} "a" "str")' assert.matches "expected value for key 'a' to be num, not str", err describe "(get)", -> it "can get values", -> - rt = COPILOT\eval_once '(get (struct "a" 1 "b" false) "a")' + rt = COPILOT\eval_once '(get {"a" 1 "b" false} "a")' assert.is.true rt\is_const! assert.is.equal '<num= 1>', tostring rt.result it "checks keys", -> - err = assert.has.error -> COPILOT\eval_once '(get (struct "a" 1) "b")' + err = assert.has.error -> COPILOT\eval_once '(get {"a" 1} "b")' assert.matches "has no 'b' key", err describe "(insert)", -> it "can add members", -> - rt = COPILOT\eval_once '(insert (struct "b" true) "a" 1)' + rt = COPILOT\eval_once '(insert {"b" true} "a" 1)' assert.is.true rt\is_const! assert.is.equal ab\mk_const({ a: 1, b: true }), rt.result it "doesn't clobber existing members", -> - err = assert.has.error -> COPILOT\eval_once '(insert (struct "a" 1) "a" 2)' + err = assert.has.error -> COPILOT\eval_once '(insert {"a" 1} "a" 2)' assert.matches "key 'a' already exists in value of type {a: num}", err describe "(remove)", -> it "can remove members", -> - rt = COPILOT\eval_once '(remove (struct "a" 1 "b" false "c" "abc") "c")' + rt = COPILOT\eval_once '(remove {"a" 1 "b" false "c" "abc"} "c")' assert.is.true rt\is_const! assert.is.equal ab\mk_const({ a: 1, b: false }), rt.result it "checks keys", -> - err = assert.has.error -> COPILOT\eval_once '(remove (struct "a" 1) "b")' + err = assert.has.error -> COPILOT\eval_once '(remove {"a" 1} "b")' assert.matches "has no 'b' key", err diff --git a/spec/lib/testing_spec.moon b/spec/lib/testing_spec.moon index 5be7848..0605c00 100644 --- a/spec/lib/testing_spec.moon +++ b/spec/lib/testing_spec.moon @@ -46,7 +46,7 @@ describe "testing", -> assert.is.true \is_const! assert.is.nil .result - with COPILOT\eval_once '(expect= (array 1 2) (array 1 2))' + with COPILOT\eval_once '(expect= [1 2] (mkarray 1 2))' assert.is.true \is_const! assert.is.nil .result @@ -58,7 +58,7 @@ describe "testing", -> assert.has.error -> COPILOT\eval_once '(expect= true false)' assert.has.error -> COPILOT\eval_once '(expect= "asdf" "bsdf")' - assert.has.error -> COPILOT\eval_once '(expect= (array 1 2) (array 1 3))' + assert.has.error -> COPILOT\eval_once '(expect= [1 2] [1 3])' it "fails different types", -> assert.has.error -> COPILOT\eval_once '(expect= true 2)' |
