Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 57 lines (44 sloc) 2.743 kb
6610659 @cormullion misc updates and changes
authored
1 #!/usr/bin/env newlisp
2
3 (load (string (env {HOME}) {/projects/programming/newlisp-projects/newlisp-parser.lsp}))
4
5 (define (test test-name original (display? nil))
6 (letn ((parsed (Nlex:parse-newlisp original))
7 (new-original (Nlex:nlx-to-plaintext parsed)))
eac1ee9 @cormullion tweaking CSS
authored
8 (set 'parsed-original (parse original) 'parsed-new-original (parse new-original))
9 (if-not (and (empty? (difference parsed-original parsed-new-original))
10 (empty? (difference parsed-new-original parsed-original )))
11 (begin
12 (println
13 (format "test %-40s failed: in old: \t %-60s" test-name
14 (string (difference (parse original) (parse new-original)))))
15 (println
16 (format "test %-40s failed: in new: \t %-60s" test-name
17 (string (difference (parse new-original) (parse original))))))
18 (println (format "test %-40s passed" test-name)))
19 (set 'original-lines (parse original "\n") 'new-original-lines (parse new-original "\n"))
20 (if display? (dolist (line original-lines)
21 (print (format "\t%-60s \t %-60s \n" line (new-original-lines $idx) ))))))
6610659 @cormullion misc updates and changes
authored
22
23 ; numbers
24 (test {integers } {(map + 1 2 3 123 -1212312312 -13 -14 0 3 6 01 02 03 04 05 06 07 08 09 11 16)})
25 (test {floats } {(map add 1.2 -1.42 56. )})
26 (test {scientific } {123 0xE8 123e2 -1.3e-12 1.23 123e-3 45 1.23e4 42 1.123e-54} 'display)
27
28 ; bracketed
29 (test {[text] brackets } {[text](+ 1 1)[/text]})
30 (test {[cmd] brackets } {[cmd](+ 1 1)[/cmd]})
31 (test {[CMD] brackets should fail } {[CMD](+ 1 1)[/CMD]})
32 (test {both brackets } {[text][cmd](+ 1 1)[/cmd][/text]})
33 (test {weird bracketed symbols } [text]myvar A-name [blah] X34-zz [* 7 5 ()};] *111*[/text] 'display)
34
35 ; strings
36
37 (test {strings braced} [text]{this is a braced string}[/text])
38 (test {strings brackets} {[text]this is a bracketed string[/text]})
39 (test {nested braces} [text]{this is {nested} braced string}[/text])
40
41 ; unicode
42 (test {unicode } {{\unnnn} (utf8len "我能吞下玻璃而不伤身体。")} 'display)
43
5f0eb96 @cormullion speed up and presentation
authored
44 ; try parsing some smallish files
45 (test {this parser script } (read-file (string (env {HOME}) {/projects/programming/newlisp-projects/newlisp-parser.lsp})))
46 ;(test {markdown } (read-file (string (env {HOME}) {/projects/programming/newlisp-projects/markdown.lsp})))
47 ;(test {life } (read-file (string (env {HOME}) {/projects/programming/newlisp-projects/life.lsp})))
48
49 ; try parsing bigger files takes too long
50 ;(test {qa} (read-file (string (env {HOME}) {/projects/programming/newlisp-working/newlisp-10.3.2/qa-specific-tests/qa-bench})))
6610659 @cormullion misc updates and changes
authored
51
52 (println "\n" {all tests completed})
53
e40ffcc @cormullion irc.lsp: improve reliability, idle callback
authored
54 (println (Nlex:parse-newlisp "(+ 2 2)"))
55
6610659 @cormullion misc updates and changes
authored
56 (exit)
Something went wrong with that request. Please try again.