aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2022-01-27 15:35:18 +0000
committers-ol <s+removethis@s-ol.nu>2025-03-02 14:24:49 +0000
commit8b0ff802dbf2a45c9c1ce6d026bb1a646e709adf (patch)
tree4945ceca327086ea96ad9b5b10e409b7c6d63aa7
parentuse base.match.any consistently (diff)
downloadalive-8b0ff802dbf2a45c9c1ce6d026bb1a646e709adf.tar.gz
alive-8b0ff802dbf2a45c9c1ce6d026bb1a646e709adf.zip
clean up spec a bit
-rw-r--r--spec/lang/array_spec.moon10
-rw-r--r--spec/lang/do_spec.moon36
-rw-r--r--spec/lang/fn_spec.moon2
-rw-r--r--spec/lang/struct_spec.moon4
-rw-r--r--spec/lang/thread_spec.moon7
-rw-r--r--spec/test_setup.moon12
6 files changed, 34 insertions, 37 deletions
diff --git a/spec/lang/array_spec.moon b/spec/lang/array_spec.moon
index f1fe0ab..b55cec6 100644
--- a/spec/lang/array_spec.moon
+++ b/spec/lang/array_spec.moon
@@ -1,5 +1,5 @@
import TestPilot from require 'spec.test_setup'
-import T, Array, Constant from require 'alv'
+import T, Array from require 'alv'
describe "array", ->
test = TestPilot '', '(import* array-)\n'
@@ -41,7 +41,7 @@ describe "array", ->
it "can get a value", ->
rt = COPILOT\eval_once '(get (array 1 2) 0)'
assert.is.true rt\is_const!
- assert.is.equal (Constant.num 1), rt.result
+ assert.is.equal '<num= 1>', tostring rt.result
it "checks index range", ->
err = assert.has.error -> COPILOT\eval_once '(get (array 1 2) -1)'
@@ -58,7 +58,7 @@ describe "array", ->
it "can peek a value", ->
rt = COPILOT\eval_once '(head (array 1 2))'
assert.is.true rt\is_const!
- assert.is.equal (Constant.num 1), rt.result
+ assert.is.equal '<num= 1>', tostring rt.result
describe '(tail)', ->
it "gets rest of an array", ->
@@ -141,8 +141,8 @@ describe "array", ->
it "size can be read using (size)", ->
rt = COPILOT\eval_once '(size (array 1))'
assert.is.true rt\is_const!
- assert.is.equal (Constant.num 1), rt.result
+ assert.is.equal '<num= 1>', tostring rt.result
rt = COPILOT\eval_once '(size (array 1 2 3))'
assert.is.true rt\is_const!
- assert.is.equal (Constant.num 3), rt.result
+ assert.is.equal '<num= 3>', tostring rt.result
diff --git a/spec/lang/do_spec.moon b/spec/lang/do_spec.moon
index 310a75d..fd2825b 100644
--- a/spec/lang/do_spec.moon
+++ b/spec/lang/do_spec.moon
@@ -1,29 +1,27 @@
import TestPilot from require 'spec.test_setup'
-import T, Struct, Array, Constant from require 'alv'
describe "do", ->
- COPILOT = TestPilot ''
+ COPILOT = TestPilot!
it "can be empty", ->
- rt = COPILOT\eval_once '(do)'
- assert.is.true rt\is_const!
- assert.is.nil rt.result
+ with COPILOT\eval_once '(do)'
+ assert.is.true \is_const!
+ assert.is.nil .result
it "returns the last result, if any", ->
- rt = COPILOT\eval_once '(do 1 2 3)'
- assert.is.true rt\is_const!
- assert.is.equal (Constant.num 3), rt.result
+ with COPILOT\eval_once '(do 1 2 3)'
+ assert.is.true \is_const!
+ assert.is.equal '<num= 3>', tostring .result
- rt = COPILOT\eval_once '(do 1 2 (def _ 3))'
- assert.is.true rt\is_const!
- assert.is.nil rt.result
+ with COPILOT\eval_once '(do 1 2 (def _ 3))'
+ assert.is.true \is_const!
+ assert.is.nil .result
it "passes through side-effects", ->
- rt = COPILOT\eval_once '
- (import* time)
- (do
- (every 0.5 "bang! side-effect")
- 3)'
- assert.is.false rt\is_const!
- assert.is.equal (Constant.num 3), rt.result
-
+ with COPILOT\eval_once '
+ (import* time)
+ (do
+ (every 0.5 "bang! side-effect")
+ 3)'
+ assert.is.false \is_const!
+ assert.is.equal '<num= 3>', tostring .result
diff --git a/spec/lang/fn_spec.moon b/spec/lang/fn_spec.moon
index 3686c91..af27cf3 100644
--- a/spec/lang/fn_spec.moon
+++ b/spec/lang/fn_spec.moon
@@ -2,7 +2,7 @@ import TestPilot from require 'spec.test_setup'
import T, Struct, Array, Constant from require 'alv'
describe "function", ->
- COPILOT = TestPilot ''
+ COPILOT = TestPilot!
it "returns constant results when constant", ->
rt = COPILOT\eval_once '
diff --git a/spec/lang/struct_spec.moon b/spec/lang/struct_spec.moon
index 6a6e0fa..9937f99 100644
--- a/spec/lang/struct_spec.moon
+++ b/spec/lang/struct_spec.moon
@@ -1,5 +1,5 @@
import TestPilot from require 'spec.test_setup'
-import T, Struct, Constant from require 'alv'
+import T, Struct from require 'alv'
describe "struct", ->
test = TestPilot '', '(import* struct-)\n'
@@ -24,7 +24,7 @@ describe "struct", ->
it "can get values", ->
rt = COPILOT\eval_once '(get (struct "a" 1 "b" false) "a")'
assert.is.true rt\is_const!
- assert.is.equal (Constant.num 1), rt.result
+ assert.is.equal '<num= 1>', tostring rt.result
it "checks keys", ->
err = assert.has.error -> COPILOT\eval_once '(get (struct "a" 1) "b")'
diff --git a/spec/lang/thread_spec.moon b/spec/lang/thread_spec.moon
index aa30a1b..9e84575 100644
--- a/spec/lang/thread_spec.moon
+++ b/spec/lang/thread_spec.moon
@@ -1,8 +1,7 @@
import TestPilot from require 'spec.test_setup'
-import T, Struct, Array, Constant from require 'alv'
describe "thread macros", ->
- COPILOT = TestPilot ''
+ COPILOT = TestPilot!
it "thread forward (->)", ->
rt = COPILOT\eval_once '
@@ -12,7 +11,7 @@ describe "thread macros", ->
(+ 2)
(/ 2))'
assert.is.true rt\is_const!
- assert.is.equal (Constant.num 6), rt.result
+ assert.is.equal '<num= 6.0>', tostring rt.result
it "thread last forward (->>)", ->
rt = COPILOT\eval_once '
@@ -22,4 +21,4 @@ describe "thread macros", ->
(+ 2)
(/ 10))'
assert.is.true rt\is_const!
- assert.is.equal (Constant.num 2), rt.result
+ assert.is.equal '<num= 2.0>', tostring rt.result
diff --git a/spec/test_setup.moon b/spec/test_setup.moon
index 8e1efee..52d9791 100644
--- a/spec/test_setup.moon
+++ b/spec/test_setup.moon
@@ -15,18 +15,18 @@ os.time = do
export COPILOT
class TestPilot extends Copilot
- new: (code, @preamble='') =>
+ new: (code='', @preamble='') =>
super!
COPILOT = @
- if code
- @active_module = StringModule 'main', @preamble .. code
+ if code.__class == Module
+ @active_module = code
@last_modules.__root = @active_module
- @tick!
else
- @active_module = Module!
+ @active_module = StringModule 'main', @preamble .. code
@last_modules.__root = @active_module
+ @tick!
begin_eval: => @active_module.registry\begin_eval!
end_eval: => @active_module.registry\end_eval!
@@ -69,7 +69,7 @@ class TestPilot extends Copilot
:TestPilot
do_setup: ->
- TestPilot!
+ TestPilot Module!
COPILOT\begin_eval!
do_teardown: ->