aboutsummaryrefslogtreecommitdiffstats
path: root/spec/lang/literal_spec.moon
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-08-19 13:54:31 +0000
committers-ol <s+removethis@s-ol.nu>2025-03-02 14:24:49 +0000
commit49cfe858055fbb6bf5590c83eab1ffdcbeea9974 (patch)
tree5d4e90da910adea3862b1932926ffe9ef9c158e0 /spec/lang/literal_spec.moon
parentadd TestPilot:eval_once (diff)
downloadalive-49cfe858055fbb6bf5590c83eab1ffdcbeea9974.tar.gz
alive-49cfe858055fbb6bf5590c83eab1ffdcbeea9974.zip
add (failing) array spec
Diffstat (limited to 'spec/lang/literal_spec.moon')
-rw-r--r--spec/lang/literal_spec.moon33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/lang/literal_spec.moon b/spec/lang/literal_spec.moon
new file mode 100644
index 0000000..3db010d
--- /dev/null
+++ b/spec/lang/literal_spec.moon
@@ -0,0 +1,33 @@
+import TestPilot from require 'spec.test_setup'
+import T, Struct, Array, Constant from require 'alv'
+
+describe "literal", ->
+ TestPilot '
+ (def str "hello"
+ num 2
+ bool true
+ curl ([5]struct "a" 2 "b" false)
+ sqre ([7]array 1 2 3 4))
+ (export*)'
+
+ assert.is.true COPILOT.active_module.root\is_const!
+ scope = (assert COPILOT.active_module.root.result)\unwrap T.scope
+
+ it "string is parsed and returned correctly", ->
+ assert.is.equal (Constant.str 'hello'), (scope\get 'str')\const!
+
+ it "number is parsed and returned correctly", ->
+ assert.is.equal (Constant.num 2), (scope\get 'num')\const!
+
+ it "boolean is parsed and returned correctly", ->
+ assert.is.equal (Constant.bool true), (scope\get 'bool')\const!
+
+ it "struct is parsed and returned correctly", ->
+ struct = (scope\get 'curl')\const!
+ assert.is.equal (Struct a: T.num, b: T.bool), struct.type
+ assert.is.same { a: 2, b: false }, struct!
+
+ it "array is parsed and returned correctly", ->
+ array = (scope\get 'sqre')\const!
+ assert.is.equal (Array 4, T.num), array.type
+ assert.is.same {1, 2, 3, 4}, array!