spec/parser_spec.rb in nydp-0.0.5 vs spec/parser_spec.rb in nydp-0.0.6
- old
+ new
@@ -47,10 +47,17 @@
it "should parse a lisp expression" do
expect(parse "(foo bar)").to eq pair_list([foo, bar])
end
+ it "should parse untidy symbols" do
+ s0 = sym "foo bar"
+ s1 = sym ""
+ s2 = sym '" hello, there, silly billy!"'
+ expect(parse "(|foo bar| || |\" hello, there, silly billy!\"|)").to eq pair_list([s0, s1, s2])
+ end
+
it "should parse numbers expression" do
expect(parse "(1 2 3)").to eq pair_list([1, 2, 3])
end
it "should parse an improper list" do
@@ -134,9 +141,14 @@
two = numbers.car
three = numbers.cdr.car
four = numbers.cdr.cdr.car
expect([two, three, four].map &:class).to eq [Fixnum, Fixnum, Fixnum]
+ end
+
+ it "should handle prefix and postfix syntax also" do
+ parsed = parse(".foo123:")
+ expect(parsed.inspect).to eq "(dot-syntax || (colon-syntax foo123 ||))"
end
it "should parse a dotted symbol" do
expect(parse "(list a b foo.bar c)").to eq pair_list([sym(:list), a, b, pair_list([dotsyn, foo, bar]), c])
end