forked from programming-nu/nu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_parser.nu
35 lines (31 loc) · 1.18 KB
/
test_parser.nu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
;; test_parser.nu
;; tests for the Nu parser. Mainly used to test incremental parsing.
;;
;; Copyright (c) 2007 Tim Burks, Radtastical Inc.
(class TestParser is NuTestCase
(- (id) testParseHereStrings is
(set parser ((NuParser alloc) init))
(parser parse:"(set x <<-END")
(assert_equal YES (parser incomplete))
(parser parse:"hello")
(assert_equal YES (parser incomplete))
(set script (parser parse:"worldEND)"))
(assert_equal NO (parser incomplete))
(eval script)
(assert_equal <<-END
hello
worldEND x))
(- (id) testParseMultilineRegularExpressions is
(set parser ((NuParser alloc) init))
(parser parse:"(set x /foo")
(assert_equal YES (parser incomplete))
(set script (parser parse:"bar/x)"))
(assert_equal NO (parser incomplete))
(eval script)
(assert_not_equal nil (x findInString:"foobar"))
(parser parse:"(set y /foo")
(assert_equal YES (parser incomplete))
(set script (parser parse:"bar/)"))
(assert_equal NO (parser incomplete))
(eval script)
(assert_not_equal nil (y findInString:"foo\nbar"))))