factor/library/test/parser.factor

78 lines
1.4 KiB
Factor
Raw Normal View History

2004-07-16 02:26:21 -04:00
IN: scratchpad
USE: parser
USE: test
USE: unparser
2004-10-06 23:40:46 -04:00
USE: lists
USE: kernel
2004-12-23 01:14:07 -05:00
USE: generic
USE: words
2004-07-16 02:26:21 -04:00
[ CHAR: a 1 ]
[ 0 "abcd" next-char ] unit-test
[ CHAR: \s 6 ]
[ 1 "\\u0020hello" next-escape ] unit-test
[ CHAR: \n 2 ]
[ 1 "\\nhello" next-escape ] unit-test
[ CHAR: \s 6 ]
[ 0 "\\u0020hello" next-char ] unit-test
2004-07-16 02:26:21 -04:00
[ [ 1 [ 2 [ 3 ] 4 ] 5 ] ]
[ "1\n[\n2\n[\n3\n]\n4\n]\n5" parse ]
unit-test
2004-07-16 02:26:21 -04:00
[ [ t t f f ] ]
[ "t t f f" parse ]
unit-test
2004-07-16 02:26:21 -04:00
2004-08-04 03:12:55 -04:00
[ [ "hello world" ] ]
[ "\"hello world\"" parse ]
unit-test
2004-07-16 02:26:21 -04:00
[ [ "\n\r\t\\" ] ]
[ "\"\\n\\r\\t\\\\\"" parse ]
unit-test
2004-07-16 02:26:21 -04:00
[ "hello world" ]
[
"IN: scratchpad : hello \"hello world\" ;"
parse call "USE: scratchpad hello" eval
] unit-test
2004-07-16 02:26:21 -04:00
[ ]
[ "! This is a comment, people." parse call ]
unit-test
2004-07-16 02:26:21 -04:00
[ ]
[ "( This is a comment, people. )" parse call ]
unit-test
2004-07-16 02:26:21 -04:00
! Test escapes
[ [ " " ] ]
[ "\"\\u0020\"" parse ]
unit-test
2004-07-16 02:26:21 -04:00
[ [ "'" ] ]
[ "\"\\u0027\"" parse ]
unit-test
[ "\\u123" parse ] unit-test-fails
2004-10-06 23:40:46 -04:00
! Test improper lists
[ 2 ] [ "[[ 1 2 ]]" parse car cdr ] unit-test
[ "hello" ] [ "[[ 1 \"hello\" ]]" parse car cdr ] unit-test
[ #{ 1 2 }# ] [ "[[ 1 #{ 1 2 }# ]]" parse car cdr ] unit-test
2004-10-27 23:13:00 -04:00
! Test EOL comments in multiline strings.
[ [ "Hello" ] ] [ "#! This calls until-eol.\n\"Hello\"" parse ] unit-test
2004-11-13 18:07:18 -05:00
[ 4 ] [ "2 2 +" eval-catch ] unit-test
[ "4\n" ] [ "2 2 + ." eval>string ] unit-test
[ ] [ "fdafdf" eval-catch ] unit-test
2004-12-23 01:14:07 -05:00
[ word ] [ \ f class ] unit-test