public
Description: The Nu programming language.
Homepage: http://programming.nu
Clone URL: git://github.com/timburks/nu.git
nu / test / test_parser.nu
100644 36 lines (31 sloc) 1.277 kb
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
35
36
;; test_parser.nu
;; tests for the Nu parser. Mainly used to test incremental parsing.
;;
;; Copyright (c) 2007 Tim Burks, Neon Design Technology, Inc.
 
(class TestParser is NuTestCase
     
     (imethod (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))
     
     (imethod (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"))))