1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

Add ECMAScript parser tests.

* test-suite/tests/ecmascript.test ("parser"): Add parser tests for the
  previous fixes.
This commit is contained in:
Ludovic Courtès 2011-01-26 23:45:13 +01:00
parent 84816b3aae
commit 90cfcf8fa7

View file

@ -40,6 +40,7 @@
(parse "true;" 'true) (parse "true;" 'true)
(parse "2 + 2;" '(+ (number 2) (number 2))) (parse "2 + 2;" '(+ (number 2) (number 2)))
(parse "2\xa0+2;" '(+ (number 2) (number 2))) ; U+00A0 is whitespace
(parse "\"hello\";" '(string "hello")) (parse "\"hello\";" '(string "hello"))
(parse "function square(x) { return x * x; }" (parse "function square(x) { return x * x; }"
'(var (square (lambda (x) (return (* (ref x) (ref x))))))) '(var (square (lambda (x) (return (* (ref x) (ref x)))))))
@ -52,7 +53,11 @@
(parse "\"\\x12\";" ; Latin-1 escape in string literal (parse "\"\\x12\";" ; Latin-1 escape in string literal
'(string "\x12")) '(string "\x12"))
(parse "\"\\u1234\";" ; Unicode escape in string literal (parse "\"\\u1234\";" ; Unicode escape in string literal
'(string "\u1234"))) '(string "\u1234"))
(parse "function foo(x) { }" ; empty function body
'(var (foo (lambda (x) (begin)))))
(parse ".123;" '(number 0.123))
(parse "0xff;" '(number 255)))
(define-syntax ecompile (define-syntax ecompile