factor/core/strings/parser/parser-tests.factor

40 lines
984 B
Factor
Raw Normal View History

USING: accessors eval strings.parser strings.parser.private
tools.test ;
2009-09-19 04:55:05 -04:00
IN: strings.parser.tests
{ "Hello\n\rworld" } [ "Hello\\n\\rworld" unescape-string ] unit-test
2009-09-19 04:55:05 -04:00
{ "Hello\n\rworld" } [ "Hello\n\rworld" ] unit-test
{ "Hello\n\rworld" } [ """Hello\n\rworld""" ] unit-test
{ "Hello\n\rworld\n" } [ "Hello\n\rworld
2009-09-19 04:55:05 -04:00
" ] unit-test
{ "Hello\n\rworld" "hi" } [ "Hello\n\rworld" "hi" ] unit-test
{ "Hello\n\rworld" "hi" } [ """Hello\n\rworld""" """hi""" ] unit-test
{ "Hello\n\rworld\n" "hi" } [ """Hello\n\rworld
2009-09-19 04:55:05 -04:00
""" """hi""" ] unit-test
{ "Hello\n\rworld\"" "hi" } [ """Hello\n\rworld\"""" """hi""" ] unit-test
[
"\"\"\"Hello\n\rworld\\\n\"\"\"" eval( -- obj )
] [
error>> escaped-char-expected?
] must-fail-with
2009-09-20 16:08:06 -04:00
{
2009-09-20 16:08:06 -04:00
" \" abc \" "
} [
2009-09-20 16:08:06 -04:00
"\"\"\" \" abc \" \"\"\"" eval( -- string )
] unit-test
{
2009-09-20 16:08:06 -04:00
"\"abc\""
} [
2009-09-20 16:08:06 -04:00
"\"\"\"\"abc\"\"\"\"" eval( -- string )
] unit-test
2009-09-20 22:50:17 -04:00
{ "\"\\" } [ "\"\\" ] unit-test
{ "\e" } [ "\u00001b" ] unit-test
{ "\e" } [ "\x1b" ] unit-test