aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-01-30 09:44:23 +0000
committers-ol <s-ol@users.noreply.github.com>2020-01-30 09:44:23 +0000
commitf526eb9f1ad140a0566c4f18e19b5ce17d6ea2b1 (patch)
tree708fc4cb5100d62f64231d53954e106e28a5ee99 /spec
parentsupport tagging (diff)
downloadalive-f526eb9f1ad140a0566c4f18e19b5ce17d6ea2b1.tar.gz
alive-f526eb9f1ad140a0566c4f18e19b5ce17d6ea2b1.zip
more types &c
Diffstat (limited to 'spec')
-rw-r--r--spec/ast_spec.moon2
-rw-r--r--spec/parsing_spec.moon49
2 files changed, 39 insertions, 12 deletions
diff --git a/spec/ast_spec.moon b/spec/ast_spec.moon
index 402ce03..cfb64cf 100644
--- a/spec/ast_spec.moon
+++ b/spec/ast_spec.moon
@@ -10,6 +10,6 @@ describe 'Xpr', ->
root = Xpr { '', ac, ' ', b, '' }, 'naked'
iter = root\walk_sexpr!
- for res in *{ ac, b, aa, ab }
+ for res in *{ ac, aa, ab, b }
assert.is.equal res, iter!
assert.is.nil iter!
diff --git a/spec/parsing_spec.moon b/spec/parsing_spec.moon
index 5e6e1fc..7e8e5a7 100644
--- a/spec/parsing_spec.moon
+++ b/spec/parsing_spec.moon
@@ -7,17 +7,44 @@ describe 'atom parsing', ->
assert.is.equal 'some-toast', sym.value
assert.is.equal 'some-toast', sym\stringify!
- test 'numbers', ->
- num = atom\match '1234 nope'
- assert.is.equal '1234', num.raw
- assert.is.equal 1234, num.value
- assert.is.equal '1234', num\stringify!
-
- test 'strings', ->
- str = atom\match '"help some stuff!" nope'
- assert.is.equal 'help some stuff!', str.raw
- assert.is.equal 'help some stuff!', str.value
- assert.is.equal '"help some stuff!"', str\stringify!
+ describe 'numbers', ->
+ it 'parses ints', ->
+ num = atom\match '1234 nope'
+ assert.is.equal '1234', num.raw
+ assert.is.equal 1234, num.value
+ assert.is.equal '1234', num\stringify!
+
+ it 'parses floats', ->
+ num = atom\match '0.123 nope'
+ assert.is.equal 0.123, num.value
+ assert.is.equal '0.123', num\stringify!
+
+ num = atom\match '.123 nope'
+ assert.is.equal .123, num.value
+ assert.is.equal '.123', num\stringify!
+
+ num = atom\match '0. nope'
+ assert.is.equal 0, num.value
+ assert.is.equal '0.', num\stringify!
+
+ describe 'strings', ->
+ it 'parses double-quote strings', ->
+ str = atom\match '"help some stuff!" nope'
+ assert.is.equal 'help some stuff!', str.raw
+ assert.is.equal 'help some stuff!', str.value
+ assert.is.equal '"help some stuff!"', str\stringify!
+
+ it 'parses single-quote strings', ->
+ str = atom\match "'help some stuff!' nope"
+ assert.is.equal "help some stuff!", str.raw
+ assert.is.equal "help some stuff!", str.value
+ assert.is.equal "'help some stuff!'", str\stringify!
+
+ it 'handles escapes', ->
+ str = atom\match '"string with \\"quote\\"s"'
+ assert.is.equal 'string with \\"quote\\"s', str.raw
+ assert.is.equal 'string with "quote"s', str.value
+ assert.is.equal '"string with \\"quote\\"s"', str\stringify!
test 'whitespace parsing', ->
assert.is.equal ' ', space\match ' '