]> gitweb.factorcode.org Git - factor.git/blob - extra/peg/javascript/tokenizer/tokenizer-tests.factor
more test IN: cleanup.
[factor.git] / extra / peg / javascript / tokenizer / tokenizer-tests.factor
1 ! Copyright (C) 2008 Chris Double.
2 ! See http://factorcode.org/license.txt for BSD license.
3
4 USING: kernel tools.test peg peg.javascript.ast
5 peg.javascript.tokenizer accessors ;
6
7 {
8   V{
9     T{ ast-number f 123 }
10     ";"
11     T{ ast-string f "hello" }
12     ";"
13     T{ ast-name f "foo" }
14     "("
15     T{ ast-name f "x" }
16     ")"
17     ";"
18   }
19 } [
20   "123; 'hello'; foo(x);" tokenize-javascript
21 ] unit-test
22
23 { V{ T{ ast-regexp f "<(w+)[^>]*?)/>" "g" } } } [
24   "/<(\\w+)[^>]*?)\\/>/g" tokenize-javascript
25 ] unit-test
26
27 {
28     V{ T{ ast-string { value "abc\"def\"" } } }
29 } [ "\"abc\\\"def\\\"\"" tokenize-javascript ] unit-test
30
31 {
32     V{ T{ ast-string { value "\b\f\n\r\t\v'\"\\" } } }
33 } [ "\"\\b\\f\\n\\r\\t\\v\\'\\\"\\\\\"" tokenize-javascript ] unit-test
34
35 {
36     V{ T{ ast-string { value "abc" } } }
37 } [ "\"\\x61\\u0062\\u{63}\"" tokenize-javascript ] unit-test