factor/extra/peg/javascript/tokenizer/tokenizer-tests.factor

38 lines
851 B
Factor
Raw Normal View History

2008-06-18 08:42:11 -04:00
! Copyright (C) 2008 Chris Double.
! See http://factorcode.org/license.txt for BSD license.
2018-02-15 11:45:08 -05:00
USING: kernel tools.test peg peg.javascript.ast
peg.javascript.tokenizer accessors ;
2008-06-18 08:42:11 -04:00
{
V{
T{ ast-number f 123 }
";"
T{ ast-string f "hello" }
";"
T{ ast-name f "foo" }
"("
T{ ast-name f "x" }
")"
";"
}
2008-06-18 08:42:11 -04:00
} [
2008-07-03 23:48:52 -04:00
"123; 'hello'; foo(x);" tokenize-javascript
2008-06-18 08:42:11 -04:00
] unit-test
2008-06-29 23:20:12 -04:00
{ V{ T{ ast-regexp f "<(w+)[^>]*?)/>" "g" } } } [
2008-07-03 23:48:52 -04:00
"/<(\\w+)[^>]*?)\\/>/g" tokenize-javascript
] unit-test
{
V{ T{ ast-string { value "abc\"def\"" } } }
} [ "\"abc\\\"def\\\"\"" tokenize-javascript ] unit-test
{
V{ T{ ast-string { value "\b\f\n\r\t\v'\"\\" } } }
} [ "\"\\b\\f\\n\\r\\t\\v\\'\\\"\\\\\"" tokenize-javascript ] unit-test
{
V{ T{ ast-string { value "abc" } } }
} [ "\"\\x61\\u0062\\u{63}\"" tokenize-javascript ] unit-test