diff options
| author | s-ol <s+removethis@s-ol.nu> | 2022-02-05 10:11:13 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2025-03-02 14:24:49 +0000 |
| commit | c484cce5ab1f6acd14ecad30adb586a6d5fa0fd1 (patch) | |
| tree | a45c702a83e150fea5b14b279e5f0cab9b65bc3e /spec/lang/struct_spec.moon | |
| parent | examples: more smoothing in love example :) (diff) | |
| download | alive-c484cce5ab1f6acd14ecad30adb586a6d5fa0fd1.tar.gz alive-c484cce5ab1f6acd14ecad30adb586a6d5fa0fd1.zip | |
rearrange spec, fix for Lua 5.1
Diffstat (limited to 'spec/lang/struct_spec.moon')
| -rw-r--r-- | spec/lang/struct_spec.moon | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/spec/lang/struct_spec.moon b/spec/lang/struct_spec.moon deleted file mode 100644 index 9937f99..0000000 --- a/spec/lang/struct_spec.moon +++ /dev/null @@ -1,51 +0,0 @@ -import TestPilot from require 'spec.test_setup' -import T, Struct from require 'alv' - -describe "struct", -> - 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)' - 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)' - 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")' - 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")' - 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")' - assert.matches "has no 'b' key", err - - describe "(insert)", -> - it "can add members", -> - rt = COPILOT\eval_once '(insert (struct "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)' - 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")' - 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")' - assert.matches "has no 'b' key", err |
