]> gitweb.factorcode.org Git - factor.git/blob - core/strings/parser/parser-tests.factor
strings.parser: fix bug with octal escape followed by more numbers
[factor.git] / core / strings / parser / parser-tests.factor
1 USING: accessors eval kernel lexer strings.parser tools.test ;
2
3 { "Hello\n\rworld" } [ "Hello\\n\\rworld" unescape-string ] unit-test
4
5 { "Hello\n\rworld" } [ "Hello\n\rworld" ] unit-test
6 { "Hello\n\rworld\n" } [ "Hello\n\rworld
7 " ] unit-test
8 { "Hello\n\rworld" "hi" } [ "Hello\n\rworld" "hi" ] unit-test
9 { "Hello\n\rworld" "hi" } [ "Hello\n\rworld" "hi" ] unit-test
10 { "Hello\n\rworld\n" "hi" } [ "Hello\n\rworld
11 " "hi" ] unit-test
12 { "Hello\n\rworld\"" "hi" } [ "Hello\n\rworld\"" "hi" ] unit-test
13
14 { "foobarbaz" } [ "\"foo\\\nbar\\\r\nbaz\"" eval( -- obj ) ] unit-test
15
16 { "\"abc\"" } [ "\"\\\"abc\\\"\"" eval( -- string ) ] unit-test
17 [ "\"" eval( -- string ) ] [ error>> unexpected? ] must-fail-with
18 [ "\"abc" eval( -- string ) ] [ error>> unexpected? ] must-fail-with
19 [ "\"abc\n\n" eval( -- string ) ] [ error>> unexpected? ] must-fail-with
20 [ "\"hello\"length" eval( -- string ) ] [ error>> unexpected? ] must-fail-with
21
22 { "\"\\" } [ "\"\\" ] unit-test
23
24 { "\e" } [ "\u00001b" ] unit-test
25 { "\e" } [ "\x1b" ] unit-test
26
27 { "foo" } [ "\"\\\nfoo\"" eval( -- obj ) ] unit-test
28 { "foo" } [ "\"foo\\\n\"" eval( -- obj ) ] unit-test
29 { "foo bar" } [ "\"foo \\\nbar\"" eval( -- obj ) ] unit-test
30
31 { "a" } [ "\"\\141\"" eval( -- obj ) ] unit-test
32 { "a1" } [ "\"\\1411\"" eval( -- obj ) ] unit-test
33 { "\0" } [ "\"\\0\"" eval( -- obj ) ] unit-test
34 { "\x01" } [ "\"\\01\"" eval( -- obj ) ] unit-test
35 { "\n" } [ "\"\\012\"" eval( -- obj ) ] unit-test
36 { "\x01d2" } [ "\"\\01d2\"" eval( -- obj ) ] unit-test
37 { "\x018" } [ "\"\\018\"" eval( -- obj ) ] unit-test