diff --git a/javascript/render-fast.ss b/javascript/render-fast.ss index 383909d..7794ced 100644 --- a/javascript/render-fast.ss +++ b/javascript/render-fast.ss @@ -34,13 +34,13 @@ (when expr (display-str " = ") (display-js expr))] - [(struct FunctionDeclaration (_ id args body)) (display-str "function ") + [(struct FunctionDeclaration (_ id args body)) (display-str "function") (display-js id) (display-str "(") (display-list ", " args) (display-str ") { ") (for-each display-js body) - (display-str "} ")] + (display-str "}")] [(struct VariableDeclaration (_ bindings)) (display-str "var ") (display-list ", " bindings) (display-str "; ")] @@ -72,7 +72,8 @@ [(struct NewExpression (_ id args)) (display-str "new ") (display-js id) (display-str "(") - (display-list ", " args)] + (display-list ", " args) + (display-str ")")] [(struct PostfixExpression (_ expr op)) (display-js expr) (display-str op)] [(struct PrefixExpression (_ op expr)) (display-str op) @@ -98,7 +99,7 @@ (display-str " ") (display-js rhs) (display-str ")")] - [(struct FunctionExpression (_ id args body)) (display-str "function ") + [(struct FunctionExpression (_ id args body)) (display-str "(function") (when id (display-js id) (display-str " ")) @@ -106,7 +107,7 @@ (display-list ", " args) (display-str ") { ") (for-each display-js body) - (display-str "} ")] + (display-str "})")] [(struct CallExpression (_ fn args)) (display-js fn) (display-str "(") (display-list ", " args) diff --git a/javascript/syntax-test.ss b/javascript/syntax-test.ss index ff9a9fc..15c7fa1 100644 --- a/javascript/syntax-test.ss +++ b/javascript/syntax-test.ss @@ -4,6 +4,7 @@ "../test-base.ss" "syntax-internal.ss") (prefix-in scheme: scheme/pretty) + srfi/13 "../test-base.ss" "expander.ss" "render.ss" @@ -23,7 +24,7 @@ (with-syntax ([expanded (expand-javascript #'actual)]) #`(test-case message (with-check-info (['compiled expanded]) - (check-equal? (javascript->string expanded) + (check-equal? (string-trim-both (javascript->string expanded)) expected)))))]))) (define-javascript-syntax (!var-debug [id expr] ...)