Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 794 lines (542 sloc) 72.126 kb
cdeb385 @alanz Adding travis ci support
authored
1 module Main where
2
f2115d2 @alanz Builds and runs tests. Need to make test pass.
authored
3 import Test.Framework (defaultMain, testGroup, Test)
4 import Test.Framework.Providers.HUnit
5 import Test.HUnit hiding (Test)
6
7
370c4fb @alanz Worked in unicode spaces and line separators.
authored
8 import Control.Monad (liftM)
f2115d2 @alanz Builds and runs tests. Need to make test pass.
authored
9 import Language.JavaScript.Parser.Parser
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
10 import Language.JavaScript.Parser
9a0a707 @alanz Silly error in runtests.hs, importing wrong grammar. All tests now pass.
authored
11 --import Language.JavaScript.Parser.Grammar
12 import Language.JavaScript.Parser.Grammar5
f2115d2 @alanz Builds and runs tests. Need to make test pass.
authored
13
cdeb385 @alanz Adding travis ci support
authored
14 {-
15 import Distribution.TestSuite
16
17 instance TestOptions (String, Bool) where
18 name = fst
19 options = const []
20 defaultOptions _ = return (Options [])
21 check _ _ = []
22
23 instance PureTestable (String, Bool) where
24 run (name, result) _ | result == True = Pass
25 | result == False = Fail (name ++ " failed!")
26
27 test :: (String, Bool) -> Test
28 test = pure
29 -}
30
f2115d2 @alanz Builds and runs tests. Need to make test pass.
authored
31 main :: IO ()
22ab0a4 @alanz WIP
authored
32 main = defaultMain [testSuite,{- ++AZ++temporary++ commentSuite ,-}commentPrintSuite]
f2115d2 @alanz Builds and runs tests. Need to make test pass.
authored
33
9a0a707 @alanz Silly error in runtests.hs, importing wrong grammar. All tests now pass.
authored
34 one :: IO ()
35 one = defaultMain [oneSuite]
36
37 oneSuite :: Test
38 oneSuite = testGroup "One"
39 [
40 testCase "ObjectLiteral7" (testProg "x={get foo() {return 1},set foo(a) {x=a}}" "")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
41 ]
9a0a707 @alanz Silly error in runtests.hs, importing wrong grammar. All tests now pass.
authored
42
f2115d2 @alanz Builds and runs tests. Need to make test pass.
authored
43 testSuite :: Test
44 testSuite = testGroup "Parser"
1561235 @alanz Investigating issue #2. The given test case passes?
authored
45 [
46 testCase "helloWorld" caseHelloWorld
28faefb @alanz Making progress on literals.
authored
47 , testCase "LiteralNull" (testLiteral "null" "Right (JSLiteral \"null\")")
48 , testCase "LiteralFalse" (testLiteral "false" "Right (JSLiteral \"false\")")
49 , testCase "LiteralTrue" (testLiteral "true" "Right (JSLiteral \"true\")")
5a2251a @alanz Worked in Appendix A from ECMA-262 ed 5, into Grammar5.y. All tests bar...
authored
50 , testCase "LiteralHexInteger1" (testLiteral "0x1234fF" "Right (JSHexInteger \"0x1234fF\")")
51 , testCase "LiteralHexInteger2" (testLiteral "0X1234fF" "Right (JSHexInteger \"0X1234fF\")")
d4a1d72 @alanz Added string literal parsing
authored
52 , testCase "LiteralDecimal1" (testLiteral "1.0e4" "Right (JSDecimal \"1.0e4\")")
53 , testCase "LiteralDecimal2" (testLiteral "2.3E6" "Right (JSDecimal \"2.3E6\")")
54 , testCase "LiteralDecimal3" (testLiteral "4.5" "Right (JSDecimal \"4.5\")")
55 , testCase "LiteralDecimal3" (testLiteral "0.7e8" "Right (JSDecimal \"0.7e8\")")
56 , testCase "LiteralDecimal4" (testLiteral "0.7E8" "Right (JSDecimal \"0.7E8\")")
57 , testCase "LiteralDecimal5" (testLiteral "10" "Right (JSDecimal \"10\")")
58 , testCase "LiteralDecimal6" (testLiteral "0" "Right (JSDecimal \"0\")")
56cf6b0 @alanz Heading toward compliance with edition 5. Trailing commas allowed in arr...
authored
59 , testCase "LiteralDecimal7" (testLiteral "0.03" "Right (JSDecimal \"0.03\")")
60 , testCase "LiteralDecimal9" (testLiteral "0.7e+8" "Right (JSDecimal \"0.7e+8\")")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
61 , testCase "LiteralDecimal10" (testLiteral "0.7e-18" "Right (JSDecimal \"0.7e-18\")")
56cf6b0 @alanz Heading toward compliance with edition 5. Trailing commas allowed in arr...
authored
62 , testCase "LiteralDecimal11" (testLiteral "1.0e+4" "Right (JSDecimal \"1.0e+4\")")
63 , testCase "LiteralDecimal12" (testLiteral "1.0e-4" "Right (JSDecimal \"1.0e-4\")")
8296513 @alanz Close issue #5 by correcting the lexical analyser for DecimalLiteral. Ve...
authored
64 , testCase "LiteralDecimal13" (testLiteral "1e18" "Right (JSDecimal \"1e18\")")
65 , testCase "LiteralDecimal14" (testLiteral "1e+18" "Right (JSDecimal \"1e+18\")")
66 , testCase "LiteralDecimal15" (testLiteral "1e-18" "Right (JSDecimal \"1e-18\")")
6f80eb4 @aszlig Fix signed integers in exponents beginning with 0.
aszlig authored
67 , testCase "LiteralDecimal16" (testLiteral "1E-01" "Right (JSDecimal \"1E-01\")")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
68
991d05e @aszlig Implement parsing for octal numbers.
aszlig authored
69 , testCase "LiteralOctal" (testLiteral "010" "Right (JSOctal \"010\")")
70
1561235 @alanz Investigating issue #2. The given test case passes?
authored
71 , testCase "LiteralString1" (testLiteral "\"hello\\nworld\"" "Right (JSStringLiteral '\"' \"hello\\\\nworld\")")
d4a1d72 @alanz Added string literal parsing
authored
72 , testCase "LiteralString2" (testLiteral "'hello\\nworld'" "Right (JSStringLiteral '\\'' \"hello\\\\nworld\")")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
73
1b88772 @alanz Starting to work in PrimaryExpression.
authored
74 , testCase "LiteralThis" (testPE "this" "Right (JSLiteral \"this\")")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
75
1b88772 @alanz Starting to work in PrimaryExpression.
authored
76 , testCase "LiteralRegex1" (testPE "/blah/" "Right (JSRegEx \"/blah/\")")
77 , testCase "LiteralRegex2" (testPE "/$/g" "Right (JSRegEx \"/$/g\")")
c2d9ea4 @alanz More changes as shortcomings brought to light by hjsmin.
authored
78 , testCase "LiteralRegex3" (testPE "/\\n/g" "Right (JSRegEx \"/\\\\n/g\")")
b0b1e32 @alanz Finally able to parse the if else statement
authored
79 , testCase "LiteralRegex4" (testPE "/^\"(?:\\.|[^\"])*\"|^'(?:[^']|\\.)*'/" "Right (JSRegEx \"/^\\\"(?:\\\\.|[^\\\"])*\\\"|^'(?:[^']|\\\\.)*'/\")")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
80
b0b1e32 @alanz Finally able to parse the if else statement
authored
81
1b88772 @alanz Starting to work in PrimaryExpression.
authored
82 , testCase "Identifier1" (testPE "_$" "Right (JSIdentifier \"_$\")")
83 , testCase "Identifier2" (testPE "this_" "Right (JSIdentifier \"this_\")")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
84
eaa4a80 @alanz Working in fuller grammar.
authored
85 , testCase "ArrayLiteral1" (testPE "[]" "Right (JSArrayLiteral [])")
dd8c858 @alanz Cleaning up AST
authored
86 , testCase "ArrayLiteral2" (testPE "[,]" "Right (JSArrayLiteral [JSElision JSLiteral \",\"])")
87 , testCase "ArrayLiteral3" (testPE "[,,]" "Right (JSArrayLiteral [JSElision JSLiteral \",\",JSElision JSLiteral \",\"])")
88 , testCase "ArrayLiteral4" (testPE "[,,x]" "Right (JSArrayLiteral [JSElision JSLiteral \",\",JSElision JSLiteral \",\",JSIdentifier \"x\"])")
89 , testCase "ArrayLiteral5" (testPE "[,,x]" "Right (JSArrayLiteral [JSElision JSLiteral \",\",JSElision JSLiteral \",\",JSIdentifier \"x\"])")
90 , testCase "ArrayLiteral6" (testPE "[,x,,x]" "Right (JSArrayLiteral [JSElision JSLiteral \",\",JSIdentifier \"x\",JSElision JSLiteral \",\",JSElision JSLiteral \",\",JSIdentifier \"x\"])")
e45a7d0 @alanz Progress.
authored
91 , testCase "ArrayLiteral7" (testPE "[x]" "Right (JSArrayLiteral [JSIdentifier \"x\"])")
56cf6b0 @alanz Heading toward compliance with edition 5. Trailing commas allowed in arr...
authored
92 , testCase "ArrayLiteral8" (testPE "[x,]" "Right (JSArrayLiteral [JSIdentifier \"x\",JSLiteral \",\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
93
80f48b6 @alanz WIP
authored
94 , testCase "ObjectLiteral1" (testPE "{}" "Right (JSObjectLiteral [])")
95 , testCase "ObjectLiteral2" (testPE "{x:1}" "Right (JSObjectLiteral [JSPropertyNameandValue (JSIdentifier \"x\") [JSDecimal \"1\"]])")
96 , testCase "ObjectLiteral3" (testPE "{x:1,y:2}" "Right (JSObjectLiteral [JSPropertyNameandValue (JSIdentifier \"x\") [JSDecimal \"1\"],JSLiteral \",\",JSPropertyNameandValue (JSIdentifier \"y\") [JSDecimal \"2\"]])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
97
2512179 @alanz Cleaning up AST and grammar.
authored
98 , testCase "ObjectLiteral4" (testPE "{evaluate:evaluate,load:function load(s){if(x)return s;1}}"
06077c5 @alanz Ongoing simplification of AST
authored
99 "Right (JSObjectLiteral [JSPropertyNameandValue (JSIdentifier \"evaluate\") [JSIdentifier \"evaluate\"],JSLiteral \",\",JSPropertyNameandValue (JSIdentifier \"load\") [JSFunctionExpression [JSIdentifier \"load\"] [JSIdentifier \"s\"] (JSBlock ([JSIf (JSExpression [JSIdentifier \"x\"]) ([JSReturn [JSExpression [JSIdentifier \"s\"]] JSLiteral \";\"]) ([]),JSExpression [JSDecimal \"1\"]]))]])")
b0b1e32 @alanz Finally able to parse the if else statement
authored
100
4229c1b @alanz Allow trailing comma in object literal
authored
101 , testCase "ObjectLiteral5" (testPE "{x:1,}" "Right (JSObjectLiteral [JSPropertyNameandValue (JSIdentifier \"x\") [JSDecimal \"1\"],JSLiteral \",\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
102
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
103 , testCase "ObjectLiteral6" (testProg "a={\n values: 7,\n}\n" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"a\",JSOperator JSLiteral \"=\",JSObjectLiteral [JSPropertyNameandValue (JSIdentifier \"values\") [JSDecimal \"7\"],JSLiteral \",\"]],JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
104
105 -- Edition 5 extensions
06077c5 @alanz Ongoing simplification of AST
authored
106 , testCase "ObjectLiteral7" (testProg "x={get foo() {return 1},set foo(a) {x=a}}" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSObjectLiteral [JSPropertyAccessor NT (JSLiteral \"get\") (TokenPn 3 1 4) [NoComment] (JSIdentifier \"foo\") [] (JSBlock ([JSReturn [JSExpression [JSDecimal \"1\"]] JSLiteral \"\"])),JSLiteral \",\",JSPropertyAccessor NT (JSLiteral \"set\") (TokenPn 24 1 25) [NoComment] (JSIdentifier \"foo\") [JSIdentifier \"a\"] (JSBlock ([JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSIdentifier \"a\"]]))]],JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
107
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
108 , testCase "ObjectLiteral8" (testProg "a={if:1,interface:2}" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"a\",JSOperator JSLiteral \"=\",JSObjectLiteral [JSPropertyNameandValue (JSIdentifier \"if\") [JSDecimal \"1\"],JSLiteral \",\",JSPropertyNameandValue (JSIdentifier \"interface\") [JSDecimal \"2\"]]],JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
109
e377fc5 @alanz More progress
authored
110 , testCase "ExpressionParen" (testPE "(56)" "Right (JSExpressionParen (JSExpression [JSDecimal \"56\"]))")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
111
ee76587 @alanz Progress.
authored
112 , testCase "Statement1" (testStmt "x" "Right (JSExpression [JSIdentifier \"x\"])")
113 , testCase "Statement2" (testStmt "null" "Right (JSExpression [JSLiteral \"null\"])")
114 , testCase "Statement3" (testStmt "true?1:2" "Right (JSExpression [JSExpressionTernary [JSLiteral \"true\"] [JSDecimal \"1\"] [JSDecimal \"2\"]])")
eaa4a80 @alanz Working in fuller grammar.
authored
115
ee76587 @alanz Progress.
authored
116 , testCase "Statement4" (testStmt "x||y" "Right (JSExpression [JSExpressionBinary \"||\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
117 , testCase "Statement5" (testStmt "x&&y" "Right (JSExpression [JSExpressionBinary \"&&\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
ee76587 @alanz Progress.
authored
118 , testCase "Statement6" (testStmt "x|y" "Right (JSExpression [JSExpressionBinary \"|\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
119 , testCase "Statement6" (testStmt "x^y" "Right (JSExpression [JSExpressionBinary \"^\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
120 , testCase "Statement7" (testStmt "x&y" "Right (JSExpression [JSExpressionBinary \"&\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
121
ee76587 @alanz Progress.
authored
122 , testCase "Statement8" (testStmt "x==y" "Right (JSExpression [JSExpressionBinary \"==\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
123 , testCase "Statement9" (testStmt "x!=y" "Right (JSExpression [JSExpressionBinary \"!=\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
ee76587 @alanz Progress.
authored
124 , testCase "Statement10" (testStmt "x===y" "Right (JSExpression [JSExpressionBinary \"===\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
125 , testCase "Statement11" (testStmt "x!==y" "Right (JSExpression [JSExpressionBinary \"!==\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
126
ee76587 @alanz Progress.
authored
127 , testCase "Statement12" (testStmt "x<y" "Right (JSExpression [JSExpressionBinary \"<\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
128 , testCase "Statement12" (testStmt "x>y" "Right (JSExpression [JSExpressionBinary \">\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
129 , testCase "Statement12" (testStmt "x<=y" "Right (JSExpression [JSExpressionBinary \"<=\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
130 , testCase "Statement12" (testStmt "x>=y" "Right (JSExpression [JSExpressionBinary \">=\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
131 -- , testCase "Statement12" (testStmt "x instanceof y" "") -- TODO: restore test case
1561235 @alanz Investigating issue #2. The given test case passes?
authored
132
133 , testCase "Statement13" (testStmt "x<<y" "Right (JSExpression [JSExpressionBinary \"<<\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
134 , testCase "Statement13" (testStmt "x>>y" "Right (JSExpression [JSExpressionBinary \">>\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
135 , testCase "Statement13" (testStmt "x>>>y" "Right (JSExpression [JSExpressionBinary \">>>\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
136
ee76587 @alanz Progress.
authored
137 , testCase "Statement14" (testStmt "x+y" "Right (JSExpression [JSExpressionBinary \"+\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
138 , testCase "Statement14" (testStmt "x-y" "Right (JSExpression [JSExpressionBinary \"-\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
139
ee76587 @alanz Progress.
authored
140 , testCase "Statement15" (testStmt "x*y" "Right (JSExpression [JSExpressionBinary \"*\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
ffc0feb @alanz Working towards a modal lexer to sort out the extended regexp problem.
authored
141 , testCase "Statement16" (testStmt "x/y" "Right (JSExpression [JSExpressionBinary \"/\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
142 , testCase "Statement17" (testStmt "x%y" "Right (JSExpression [JSExpressionBinary \"%\" [JSIdentifier \"x\"] [JSIdentifier \"y\"]])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
143
144 , testCase "Statement18" (testStmt "delete y" "Right (JSExpression [JSUnary \"delete \",JSIdentifier \"y\"])")
145 , testCase "Statement19" (testStmt "void y" "Right (JSExpression [JSUnary \"void \",JSIdentifier \"y\"])")
146 , testCase "Statement20" (testStmt "typeof y" "Right (JSExpression [JSUnary \"typeof \",JSIdentifier \"y\"])")
147 , testCase "Statement21" (testStmt "++y" "Right (JSExpression [JSUnary \"++\",JSIdentifier \"y\"])")
148 , testCase "Statement22" (testStmt "--y" "Right (JSExpression [JSUnary \"--\",JSIdentifier \"y\"])")
149 , testCase "Statement23" (testStmt "+y" "Right (JSExpression [JSUnary \"+\",JSIdentifier \"y\"])")
150 , testCase "Statement24" (testStmt "-y" "Right (JSExpression [JSUnary \"-\",JSIdentifier \"y\"])")
151 , testCase "Statement25" (testStmt "~y" "Right (JSExpression [JSUnary \"~\",JSIdentifier \"y\"])")
152 , testCase "Statement26" (testStmt "!y" "Right (JSExpression [JSUnary \"!\",JSIdentifier \"y\"])")
153
ffc0feb @alanz Working towards a modal lexer to sort out the extended regexp problem.
authored
154 , testCase "Statement27" (testStmt "y++" "Right (JSExpression [JSExpressionPostfix \"++\" [JSIdentifier \"y\"]])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
155 , testCase "Statement28" (testStmt "y--" "Right (JSExpression [JSExpressionPostfix \"--\" [JSIdentifier \"y\"]])")
156
e377fc5 @alanz More progress
authored
157 -- Member Expressions
06077c5 @alanz Ongoing simplification of AST
authored
158 , testCase "MemberExpression1a" (testStmt "function(){}" "Right (JSExpression [JSFunctionExpression [] [] (JSBlock ([]))])")
159 , testCase "MemberExpression1b" (testStmt "function(a){}" "Right (JSExpression [JSFunctionExpression [] [JSIdentifier \"a\"] (JSBlock ([]))])")
160 , testCase "MemberExpression1c" (testStmt "function(a,b){}" "Right (JSExpression [JSFunctionExpression [] [JSIdentifier \"a\",JSLiteral \",\",JSIdentifier \"b\"] (JSBlock ([]))])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
161
e5e7404 @alanz Working through tests
authored
162 , testCase "MemberExpression1d" (testStmt "x[y]" "Right (JSExpression [JSMemberSquare [JSIdentifier \"x\"] (JSExpression [JSIdentifier \"y\"])])")
163 , testCase "MemberExpression1e" (testStmt "x[y][z]" "Right (JSExpression [JSMemberSquare [JSMemberSquare [JSIdentifier \"x\"] (JSExpression [JSIdentifier \"y\"])] (JSExpression [JSIdentifier \"z\"])])")
164 , testCase "MemberExpression1f" (testStmt "x.y" "Right (JSExpression [JSMemberDot [JSIdentifier \"x\"] (JSIdentifier \"y\")])")
165 , testCase "MemberExpression1g" (testStmt "x.y.z" "Right (JSExpression [JSMemberDot [JSMemberDot [JSIdentifier \"x\"] (JSIdentifier \"y\")] (JSIdentifier \"z\")])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
166
01e8617 @alanz Proper UTF8 output
authored
167 , testCase "MemberExpression1h" (testStmt "new x()" "Right (JSExpression [JSLiteral \"new\",JSIdentifier \"x\",JSArguments []])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
168
01e8617 @alanz Proper UTF8 output
authored
169 , testCase "NewExpression1" (testStmt "new x.y" "Right (JSExpression [JSLiteral \"new\",JSMemberDot [JSIdentifier \"x\"] (JSIdentifier \"y\")])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
170
145cb6c @alanz Time to tackle the other elements of Statement.
authored
171 , testCase "CallExpression1" (testStmt "x()" "Right (JSExpression [JSIdentifier \"x\",JSArguments []])")
172 , testCase "CallExpression2" (testStmt "x()()" "Right (JSExpression [JSIdentifier \"x\",JSArguments [],JSCallExpression \"()\" [JSArguments []]])")
173 , testCase "CallExpression3" (testStmt "x()[4]" "Right (JSExpression [JSIdentifier \"x\",JSArguments [],JSCallExpression \"[]\" [JSExpression [JSDecimal \"4\"]]])")
174 , testCase "CallExpression4" (testStmt "x().x" "Right (JSExpression [JSIdentifier \"x\",JSArguments [],JSCallExpression \".\" [JSIdentifier \"x\"]])")
e5e7404 @alanz Working through tests
authored
175 , testCase "CallExpression5" (testStmt "x(a,b=2).x" "Right (JSExpression [JSIdentifier \"x\",JSArguments [JSIdentifier \"a\",JSLiteral \",\",JSIdentifier \"b\",JSOperator JSLiteral \"=\",JSDecimal \"2\"],JSCallExpression \".\" [JSIdentifier \"x\"]])")
176
177 , testCase "AssignExpression1" (testStmt "x=1" "Right (JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSDecimal \"1\"])")
803c73d @alanz Making progress.
authored
178 , testCase "AssignExpression2" (testStmt "x*=1" "Right (JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"*=\",JSDecimal \"1\"])")
179 , testCase "AssignExpression3" (testStmt "x/=1" "Right (JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"/=\",JSDecimal \"1\"])")
180 , testCase "AssignExpression4" (testStmt "x%=1" "Right (JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"%=\",JSDecimal \"1\"])")
181 , testCase "AssignExpression5" (testStmt "x+=1" "Right (JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"+=\",JSDecimal \"1\"])")
182 , testCase "AssignExpression6" (testStmt "x-=1" "Right (JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"-=\",JSDecimal \"1\"])")
183 , testCase "AssignExpression7" (testStmt "x<<=1" "Right (JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"<<=\",JSDecimal \"1\"])")
184 , testCase "AssignExpression8" (testStmt "x>>=1" "Right (JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \">>=\",JSDecimal \"1\"])")
185 , testCase "AssignExpression9" (testStmt "x>>>=1" "Right (JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \">>>=\",JSDecimal \"1\"])")
186 , testCase "AssignExpression10" (testStmt "x&=1" "Right (JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"&=\",JSDecimal \"1\"])")
187 , testCase "AssignExpression11" (testStmt "x^=1" "Right (JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"^=\",JSDecimal \"1\"])")
188 , testCase "AssignExpression12" (testStmt "x|=1" "Right (JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"|=\",JSDecimal \"1\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
189
190
bbb74a6 @alanz More simplifications of AST and Grammar.
authored
191 , testCase "Block1" (testStmt "{}" "Right (JSBlock ([]))")
192 , testCase "Block2" (testStmt "{x=1}" "Right (JSBlock ([JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSDecimal \"1\"]]))")
193 , testCase "Block3" (testStmt "{x=1;y=2}" "Right (JSBlock ([JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSDecimal \"1\"],JSLiteral \";\",JSExpression [JSIdentifier \"y\",JSOperator JSLiteral \"=\",JSDecimal \"2\"]]))")
194 , testCase "Block4" (testStmt "{{}}" "Right (JSBlock ([JSBlock ([])]))")
195 , testCase "Block5" (testStmt "{{{}}}" "Right (JSBlock ([JSBlock ([JSBlock ([])])]))")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
196
bbb74a6 @alanz More simplifications of AST and Grammar.
authored
197 , testCase "If1" (testStmt "if (1) {}" "Right (JSIf (JSExpression [JSDecimal \"1\"]) ([JSBlock ([])]) ([]))")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
198
bbb74a6 @alanz More simplifications of AST and Grammar.
authored
199 , testCase "IfElse1" (testStmt "if (1) {} else {}" "Right (JSIf (JSExpression [JSDecimal \"1\"]) ([JSBlock ([])]) ([JSLiteral \"else\",JSBlock ([])]))")
200 , testCase "IfElse2" (testStmt "if (1) x=1; else {}" "Right (JSIf (JSExpression [JSDecimal \"1\"]) ([JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSDecimal \"1\"],JSLiteral \";\"]) ([JSLiteral \"else\",JSBlock ([])]))")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
201
bbb74a6 @alanz More simplifications of AST and Grammar.
authored
202 , testCase "DoWhile1" (testStmt "do {x=1} while (true);" "Right (JSDoWhile (JSBlock ([JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSDecimal \"1\"]])) (JSExpression [JSLiteral \"true\"]) (JSLiteral \";\"))")
a6b393b @alanz Iteration Statement complete.
authored
203 , testCase "While1" (testStmt "while(true);" "Right (JSWhile (JSExpression [JSLiteral \"true\"]) (JSLiteral \";\"))")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
204
a6b393b @alanz Iteration Statement complete.
authored
205 , testCase "For1" (testStmt "for(;;);" "Right (JSFor [] [] [] (JSLiteral \";\"))")
803c73d @alanz Making progress.
authored
206 , testCase "For2" (testStmt "for(x=1;x<10;x++);" "Right (JSFor [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSDecimal \"1\"]] [JSExpression [JSExpressionBinary \"<\" [JSIdentifier \"x\"] [JSDecimal \"10\"]]] [JSExpression [JSExpressionPostfix \"++\" [JSIdentifier \"x\"]]] (JSLiteral \";\"))")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
207
a6b393b @alanz Iteration Statement complete.
authored
208 , testCase "ForVar1" (testStmt "for(var x;;);" "Right (JSForVar [JSVarDecl (JSIdentifier \"x\") []] [] [] (JSLiteral \";\"))")
bbb74a6 @alanz More simplifications of AST and Grammar.
authored
209 , testCase "ForVar2a" (testStmt "for(var x=1;;);" "Right (JSForVar [JSVarDecl (JSIdentifier \"x\") [JSLiteral \"=\",JSDecimal \"1\"]] [] [] (JSLiteral \";\"))")
210 , testCase "ForVar2b" (testStmt "for(var x;y;z){}" "Right (JSForVar [JSVarDecl (JSIdentifier \"x\") []] [JSExpression [JSIdentifier \"y\"]] [JSExpression [JSIdentifier \"z\"]] (JSBlock ([])))")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
211
bbb74a6 @alanz More simplifications of AST and Grammar.
authored
212 , testCase "ForIn1" (testStmt "for(x in 5){}" "Right (JSForIn [JSIdentifier \"x\"] (JSExpression [JSDecimal \"5\"]) (JSBlock ([])))")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
213
bbb74a6 @alanz More simplifications of AST and Grammar.
authored
214 , testCase "ForVarIn1" (testStmt "for(var x in 5){}" "Right (JSForVarIn (JSVarDecl (JSIdentifier \"x\") []) (JSExpression [JSDecimal \"5\"]) (JSBlock ([])))")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
215
803c73d @alanz Making progress.
authored
216 , testCase "Var1" (testStmt "var x=1;" "Right (JSVariables JSLiteral \"var\" [JSVarDecl (JSIdentifier \"x\") [JSLiteral \"=\",JSDecimal \"1\"]])")
217 , testCase "Var2" (testStmt "const x=1,y=2;" "Right (JSVariables JSLiteral \"const\" [JSVarDecl (JSIdentifier \"x\") [JSLiteral \"=\",JSDecimal \"1\"],JSLiteral \",\",JSVarDecl (JSIdentifier \"y\") [JSLiteral \"=\",JSDecimal \"2\"]])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
218
dd8c858 @alanz Cleaning up AST
authored
219 , testCase "Continue1" (testStmt "continue;" "Right (JSContinue [] JSLiteral \";\")")
220 , testCase "Continue2" (testStmt "continue x;" "Right (JSContinue [JSIdentifier \"x\"] JSLiteral \";\")")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
221
dd8c858 @alanz Cleaning up AST
authored
222 , testCase "Break1" (testStmt "break;" "Right (JSBreak [] JSLiteral \";\")")
223 , testCase "Break2" (testStmt "break x;" "Right (JSBreak [JSIdentifier \"x\"] JSLiteral \";\")")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
224
dd8c858 @alanz Cleaning up AST
authored
225 , testCase "Return1" (testStmt "return;" "Right (JSReturn [] JSLiteral \";\")")
226 , testCase "Return2" (testStmt "return x;" "Right (JSReturn [JSExpression [JSIdentifier \"x\"]] JSLiteral \";\")")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
227
bbb74a6 @alanz More simplifications of AST and Grammar.
authored
228 , testCase "With1" (testStmt "with (x) {};" "Right (JSWith (JSExpression [JSIdentifier \"x\"]) [JSBlock ([]),JSLiteral \";\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
229
803c73d @alanz Making progress.
authored
230 , testCase "Labelled1" (testStmt "abc:x=1" "Right (JSLabelled (JSIdentifier \"abc\") (JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSDecimal \"1\"]))")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
231
2512179 @alanz Cleaning up AST and grammar.
authored
232 , testCase "Switch1" (testStmt "switch (x) {}" "Right (JSSwitch (JSExpression [JSIdentifier \"x\"]) JSBlock ([JSLiteral \"\"]))")
bbb74a6 @alanz More simplifications of AST and Grammar.
authored
233 , testCase "Switch2" (testStmt "switch (x) {case 1:break;}" "Right (JSSwitch (JSExpression [JSIdentifier \"x\"]) JSBlock ([JSCase (JSExpression [JSDecimal \"1\"]) ([JSBreak [] JSLiteral \";\"])]))")
234 , testCase "Switch3" (testStmt "switch (x) {case 0:\ncase 1:break;}" "Right (JSSwitch (JSExpression [JSIdentifier \"x\"]) JSBlock ([JSCase (JSExpression [JSDecimal \"0\"]) ([]),JSCase (JSExpression [JSDecimal \"1\"]) ([JSBreak [] JSLiteral \";\"])]))")
235 , testCase "Switch4" (testStmt "switch (x) {default:break;}" "Right (JSSwitch (JSExpression [JSIdentifier \"x\"]) JSBlock ([JSLiteral \"\",JSDefault ([JSBreak [] JSLiteral \";\"]),JSLiteral \"\"]))")
236 , testCase "Switch5" (testStmt "switch (x) {default:\ncase 1:break;}" "Right (JSSwitch (JSExpression [JSIdentifier \"x\"]) JSBlock ([JSLiteral \"\",JSDefault ([]),JSCase (JSExpression [JSDecimal \"1\"]) ([JSBreak [] JSLiteral \";\"])]))")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
237
17f9c3f @alanz Statement fully parsed.
authored
238 , testCase "Throw1" (testStmt "throw 1" "Right (JSThrow (JSExpression [JSDecimal \"1\"]))")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
239
2512179 @alanz Cleaning up AST and grammar.
authored
240 , testCase "Try1" (testStmt "try{}catch(a){}" "Right (JSTry (JSBlock ([])) [JSCatch (JSIdentifier \"a\") [] (JSBlock ([]))])")
241 , testCase "Try2" (testStmt "try{}finally{}" "Right (JSTry (JSBlock ([])) [JSFinally (JSBlock ([]))])")
242 , testCase "Try3" (testStmt "try{}catch(a){}finally{}" "Right (JSTry (JSBlock ([])) [JSCatch (JSIdentifier \"a\") [] (JSBlock ([])),JSFinally (JSBlock ([]))])")
b1502c3 @alanz Added in syntax extensions to try-catch: multiple catch blocks, and cond...
authored
243
2512179 @alanz Cleaning up AST and grammar.
authored
244 , testCase "Try4" (testStmt "try{}catch(a){}catch(b){}finally{}" "Right (JSTry (JSBlock ([])) [JSCatch (JSIdentifier \"a\") [] (JSBlock ([])),JSCatch (JSIdentifier \"b\") [] (JSBlock ([])),JSFinally (JSBlock ([]))])")
245 , testCase "Try5" (testStmt "try{}catch(a){}catch(b){}" "Right (JSTry (JSBlock ([])) [JSCatch (JSIdentifier \"a\") [] (JSBlock ([])),JSCatch (JSIdentifier \"b\") [] (JSBlock ([]))])")
246 , testCase "Try6" (testStmt "try{}catch(a if true){}catch(b){}" "Right (JSTry (JSBlock ([])) [JSCatch (JSIdentifier \"a\") [JSLiteral \"if\",JSLiteral \"true\"] (JSBlock ([])),JSCatch (JSIdentifier \"b\") [] (JSBlock ([]))])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
247
06077c5 @alanz Ongoing simplification of AST
authored
248 , testCase "Function1" (testProg "function a(){}" "Right (JSSourceElementsTop [JSFunction (JSIdentifier \"a\") [] (JSBlock ([])),JSLiteral \"\"])")
249 , testCase "Function2" (testProg "function a(b,c){}" "Right (JSSourceElementsTop [JSFunction (JSIdentifier \"a\") [JSIdentifier \"b\",JSLiteral \",\",JSIdentifier \"c\"] (JSBlock ([])),JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
250
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
251 , testCase "Comment1" (testProg "//blah\nx=1;//foo\na" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSDecimal \"1\"],JSLiteral \";\",JSExpression [JSIdentifier \"a\"],JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
252
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
253 , testCase "Comment2" (testProg "/*x=1\ny=2\n*/z=2;//foo\na" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"z\",JSOperator JSLiteral \"=\",JSDecimal \"2\"],JSLiteral \";\",JSExpression [JSIdentifier \"a\"],JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
254
803c73d @alanz Making progress.
authored
255 , testCase "min_100_animals1" (testProg "function Animal(name){if(!name)throw new Error('Must specify an animal name');this.name=name};Animal.prototype.toString=function(){return this.name};o=new Animal(\"bob\");o.toString()==\"bob\""
06077c5 @alanz Ongoing simplification of AST
authored
256 "Right (JSSourceElementsTop [JSFunction (JSIdentifier \"Animal\") [JSIdentifier \"name\"] (JSBlock ([JSIf (JSExpression [JSUnary \"!\",JSIdentifier \"name\"]) ([JSThrow (JSExpression [JSLiteral \"new\",JSIdentifier \"Error\",JSArguments [JSStringLiteral '\\'' \"Must specify an animal name\"]]),JSLiteral \";\"]) ([]),JSExpression [JSMemberDot [JSLiteral \"this\"] (JSIdentifier \"name\"),JSOperator JSLiteral \"=\",JSIdentifier \"name\"]])),JSLiteral \";\",JSExpression [JSMemberDot [JSMemberDot [JSIdentifier \"Animal\"] (JSIdentifier \"prototype\")] (JSIdentifier \"toString\"),JSOperator JSLiteral \"=\",JSFunctionExpression [] [] (JSBlock ([JSReturn [JSExpression [JSMemberDot [JSLiteral \"this\"] (JSIdentifier \"name\")]] JSLiteral \"\"]))],JSLiteral \";\",JSExpression [JSIdentifier \"o\",JSOperator JSLiteral \"=\",JSLiteral \"new\",JSIdentifier \"Animal\",JSArguments [JSStringLiteral '\"' \"bob\"]],JSLiteral \";\",JSExpression [JSExpressionBinary \"==\" [JSMemberDot [JSIdentifier \"o\"] (JSIdentifier \"toString\"),JSArguments []] [JSStringLiteral '\"' \"bob\"]],JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
257
06077c5 @alanz Ongoing simplification of AST
authored
258 , testCase "min_100_animals2" (testProg "Animal=function(){return this.name};" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"Animal\",JSOperator JSLiteral \"=\",JSFunctionExpression [] [] (JSBlock ([JSReturn [JSExpression [JSMemberDot [JSLiteral \"this\"] (JSIdentifier \"name\")]] JSLiteral \"\"]))],JSLiteral \";\",JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
259
2512179 @alanz Cleaning up AST and grammar.
authored
260 , testCase "min_100_animals3" (testProg "if(a)x=1;y=2" "Right (JSSourceElementsTop [JSIf (JSExpression [JSIdentifier \"a\"]) ([JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSDecimal \"1\"],JSLiteral \";\"]) ([]),JSExpression [JSIdentifier \"y\",JSOperator JSLiteral \"=\",JSDecimal \"2\"],JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
261
2512179 @alanz Cleaning up AST and grammar.
authored
262 , testCase "min_100_animals4" (testProg "if(a)x=a()y=2" "Right (JSSourceElementsTop [JSIf (JSExpression [JSIdentifier \"a\"]) ([JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSIdentifier \"a\",JSArguments []]]) ([]),JSExpression [JSIdentifier \"y\",JSOperator JSLiteral \"=\",JSDecimal \"2\"],JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
263
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
264 , testCase "05_regex" (testProg "newlines=spaces.match(/\\n/g)" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"newlines\",JSOperator JSLiteral \"=\",JSMemberDot [JSIdentifier \"spaces\"] (JSIdentifier \"match\"),JSArguments [JSRegEx \"/\\\\n/g\"]],JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
265
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
266 , testCase "05_regex2" (testProg "x=/\\n/g" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSRegEx \"/\\\\n/g\"],JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
267
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
268 , testCase "05_regex3" (testProg "x=i(/[?|^&(){}\\[\\]+\\-*\\/\\.]/g,\"\\\\$&\")" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSIdentifier \"i\",JSArguments [JSRegEx \"/[?|^&(){}\\\\[\\\\]+\\\\-*\\\\/\\\\.]/g\",JSLiteral \",\",JSStringLiteral '\"' \"\\\\\\\\$&\"]],JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
269
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
270 , testCase "05_regex4" (testProg "x=i(/^$/g,\"\\\\$&\")" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSIdentifier \"i\",JSArguments [JSRegEx \"/^$/g\",JSLiteral \",\",JSStringLiteral '\"' \"\\\\\\\\$&\"]],JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
271
87774e4 @alanz WIP
authored
272 , testCase "05_regex5" (testProg "if(/^[a-z]/.test(t)){consts+=t.toUpperCase();keywords[t]=i}else consts+=(/^\\W/.test(t)?opTypeNames[t]:t);"
bbb74a6 @alanz More simplifications of AST and Grammar.
authored
273 "Right (JSSourceElementsTop [JSIf (JSExpression [JSMemberDot [JSRegEx \"/^[a-z]/\"] (JSIdentifier \"test\"),JSArguments [JSIdentifier \"t\"]]) ([JSBlock ([JSExpression [JSIdentifier \"consts\",JSOperator JSLiteral \"+=\",JSMemberDot [JSIdentifier \"t\"] (JSIdentifier \"toUpperCase\"),JSArguments []],JSLiteral \";\",JSExpression [JSMemberSquare [JSIdentifier \"keywords\"] (JSExpression [JSIdentifier \"t\"]),JSOperator JSLiteral \"=\",JSIdentifier \"i\"]])]) ([JSLiteral \"else\",JSExpression [JSIdentifier \"consts\",JSOperator JSLiteral \"+=\",JSExpressionParen (JSExpression [JSExpressionTernary [JSMemberDot [JSRegEx \"/^\\\\W/\"] (JSIdentifier \"test\"),JSArguments [JSIdentifier \"t\"]] [JSMemberSquare [JSIdentifier \"opTypeNames\"] (JSExpression [JSIdentifier \"t\"])] [JSIdentifier \"t\"]])]]),JSLiteral \";\",JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
274
2512179 @alanz Cleaning up AST and grammar.
authored
275 , testCase "if_semi" (testProg "if(x);x=1" "Right (JSSourceElementsTop [JSIf (JSExpression [JSIdentifier \"x\"]) ([JSLiteral \";\"]) ([]),JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSDecimal \"1\"],JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
276
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
277 , testCase "67_bob" (testProg "(match = /^\"(?:\\\\.|[^\"])*\"|^'(?:[^']|\\\\.)*'/(input))" "Right (JSSourceElementsTop [JSExpression [JSExpressionParen (JSExpression [JSIdentifier \"match\",JSOperator JSLiteral \"=\",JSRegEx \"/^\\\"(?:\\\\\\\\.|[^\\\"])*\\\"|^'(?:[^']|\\\\\\\\.)*'/\",JSArguments [JSIdentifier \"input\"]])],JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
278
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
279 , testCase "122_jsexec" (testProg "v = getValue(execute(n[0], x)) in getValue(execute(n[1], x));" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"v\",JSOperator JSLiteral \"=\",JSExpressionBinary \" in \" [JSIdentifier \"getValue\",JSArguments [JSIdentifier \"execute\",JSArguments [JSMemberSquare [JSIdentifier \"n\"] (JSExpression [JSDecimal \"0\"]),JSLiteral \",\",JSIdentifier \"x\"]]] [JSIdentifier \"getValue\",JSArguments [JSIdentifier \"execute\",JSArguments [JSMemberSquare [JSIdentifier \"n\"] (JSExpression [JSDecimal \"1\"]),JSLiteral \",\",JSIdentifier \"x\"]]]],JSLiteral \";\",JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
280
06077c5 @alanz Ongoing simplification of AST
authored
281 , testCase "bug1a" (testProg "/* */\nfunction f() {\n/* */\n}\n" "Right (JSSourceElementsTop [JSFunction (JSIdentifier \"f\") [] (JSBlock ([])),JSLiteral \"\"])")
282 , testCase "bug1b" (testProg "/* **/\nfunction f() {\n/* */\n}\n" "Right (JSSourceElementsTop [JSFunction (JSIdentifier \"f\") [] (JSBlock ([])),JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
283
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
284 , testCase "unicode1-ws" (testProg "a \f\v\t\r\n=\x00a0\x1680\x180e\x2000\x2001\x2002\x2003\x2004\x2005\x2006\x2007\x2008\x2009\x200a\x2028\x2029\x202f\x205f\x3000\&1;" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"a\",JSOperator JSLiteral \"=\",JSDecimal \"1\"],JSLiteral \";\",JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
285
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
286 , testCase "unicode2-lt" (testProg "//comment\x000Ax=1;" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSDecimal \"1\"],JSLiteral \";\",JSLiteral \"\"])")
287 , testCase "unicode3-lt" (testProg "//comment\x000Dx=1;" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSDecimal \"1\"],JSLiteral \";\",JSLiteral \"\"])")
288 , testCase "unicode4-lt" (testProg "//comment\x2028x=1;" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSDecimal \"1\"],JSLiteral \";\",JSLiteral \"\"])")
289 , testCase "unicode5-lt" (testProg "//comment\x2029x=1;" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSDecimal \"1\"],JSLiteral \";\",JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
290
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
291 , testCase "unicode2" (testProg "àáâãäå = 1;" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"\\224\\225\\226\\227\\228\\229\",JSOperator JSLiteral \"=\",JSDecimal \"1\"],JSLiteral \";\",JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
292
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
293 , testCase "unicode3" (testProg "$aà = 1;_b=2;\0065a=2" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"$a\\224\",JSOperator JSLiteral \"=\",JSDecimal \"1\"],JSLiteral \";\",JSExpression [JSIdentifier \"_b\",JSOperator JSLiteral \"=\",JSDecimal \"2\"],JSLiteral \";\",JSExpression [JSIdentifier \"Aa\",JSOperator JSLiteral \"=\",JSDecimal \"2\"],JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
294
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
295 , testCase "unicode4" (testProg "x=\"àáâãäå\";y='\3012a\0068'" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSStringLiteral '\"' \"\\224\\225\\226\\227\\228\\229\"],JSLiteral \";\",JSExpression [JSIdentifier \"y\",JSOperator JSLiteral \"=\",JSStringLiteral '\\'' \"\\3012aD\"],JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
296
98e5bfe @alanz Introduce parseFileUtf8 to explicitly use utf8 for parsing a file, and u...
authored
297 , testCase "unicode5f" (testFileUtf8 "./test/Unicode.js" "JSSourceElementsTop [JSExpression [JSIdentifier \"\\224\\225\\226\\227\\228\\229\",JSOperator JSLiteral \"=\",JSDecimal \"1\"],JSLiteral \";\",JSLiteral \"\"]")
370c4fb @alanz Worked in unicode spaces and line separators.
authored
298
06077c5 @alanz Ongoing simplification of AST
authored
299 , testCase "bug2.a" (testProg "function() {\nz = function /*z*/(o) {\nreturn r;\n};}" "Right (JSSourceElementsTop [JSExpression [JSFunctionExpression [] [] (JSBlock ([JSExpression [JSIdentifier \"z\",JSOperator JSLiteral \"=\",JSFunctionExpression [] [JSIdentifier \"o\"] (JSBlock ([JSReturn [JSExpression [JSIdentifier \"r\"]] JSLiteral \";\"]))],JSLiteral \";\"]))],JSLiteral \"\"])")
425aa61 @alanz Initial fix for ECMAScript 3 allowing named function expressions.
authored
300
06077c5 @alanz Ongoing simplification of AST
authored
301 , testCase "bug2.b" (testProg "function() {\nz = function z(o) {\nreturn r;\n};}" "Right (JSSourceElementsTop [JSExpression [JSFunctionExpression [] [] (JSBlock ([JSExpression [JSIdentifier \"z\",JSOperator JSLiteral \"=\",JSFunctionExpression [JSIdentifier \"z\"] [JSIdentifier \"o\"] (JSBlock ([JSReturn [JSExpression [JSIdentifier \"r\"]] JSLiteral \";\"]))],JSLiteral \";\"]))],JSLiteral \"\"])")
425aa61 @alanz Initial fix for ECMAScript 3 allowing named function expressions.
authored
302
1561235 @alanz Investigating issue #2. The given test case passes?
authored
303 -- https://github.com/alanz/hjsmin/issues/#issue/3
01e8617 @alanz Proper UTF8 output
authored
304 , testCase "bug3" (testProg "var myLatlng = new google.maps.LatLng(56.8379100, 60.5806664);" "Right (JSSourceElementsTop [JSVariables JSLiteral \"var\" [JSVarDecl (JSIdentifier \"myLatlng\") [JSLiteral \"=\",JSLiteral \"new\",JSMemberDot [JSMemberDot [JSIdentifier \"google\"] (JSIdentifier \"maps\")] (JSIdentifier \"LatLng\"),JSArguments [JSDecimal \"56.8379100\",JSLiteral \",\",JSDecimal \"60.5806664\"]]],JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
305
306 -- https://github.com/alanz/hjsmin/issues/#issue/4
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
307 , testCase "bug4" (testProg "/* * geolocation. пытаемся определить свое местоположение * если не получается то используем defaultLocation * @Param {object} map экземпляр карты * @Param {object LatLng} defaultLocation Координаты центра по умолчанию * @Param {function} callbackAfterLocation Фу-ия которая вызывается после * геолокации. Т.к запрос геолокации асинхронен */x" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\"],JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
308
309
310
bbb74a6 @alanz More simplifications of AST and Grammar.
authored
311 , testCase "02_sm.js" (testProg "{zero}\none1;two\n{three\nfour;five;\n{\nsix;{seven;}\n}\n}" "Right (JSSourceElementsTop [JSBlock ([JSExpression [JSIdentifier \"zero\"]]),JSExpression [JSIdentifier \"one1\"],JSLiteral \";\",JSExpression [JSIdentifier \"two\"],JSBlock ([JSExpression [JSIdentifier \"three\"],JSExpression [JSIdentifier \"four\"],JSLiteral \";\",JSExpression [JSIdentifier \"five\"],JSLiteral \";\",JSBlock ([JSExpression [JSIdentifier \"six\"],JSLiteral \";\",JSBlock ([JSExpression [JSIdentifier \"seven\"],JSLiteral \";\"])])]),JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
312
bbb74a6 @alanz More simplifications of AST and Grammar.
authored
313 , testCase "02_sm.js.2" (testProg "{zero}\nget;two\n{three\nfour;set;\n{\nsix;{seven;}\n}\n}" "Right (JSSourceElementsTop [JSBlock ([JSExpression [JSIdentifier \"zero\"]]),JSExpression [JSIdentifier \"get\"],JSLiteral \";\",JSExpression [JSIdentifier \"two\"],JSBlock ([JSExpression [JSIdentifier \"three\"],JSExpression [JSIdentifier \"four\"],JSLiteral \";\",JSExpression [JSIdentifier \"set\"],JSLiteral \";\",JSBlock ([JSExpression [JSIdentifier \"six\"],JSLiteral \";\",JSBlock ([JSExpression [JSIdentifier \"seven\"],JSLiteral \";\"])])]),JSLiteral \"\"])")
ffe6528 @alanz Sorted out get/set as both tokens and identifiers.
authored
314
a8197d6 @alanz Bringing through whitespace as a separate CommentAnnotation
authored
315 , testCase "loc1" (testProgUn "x = 1\n y=2;" "Right (NN (JSSourceElementsTop [NN (JSExpression [NT (JSIdentifier \"x\") (TokenPn 0 1 1) [NoComment],NN (JSOperator (NT (JSLiteral \"=\") (TokenPn 2 1 3) [WhiteSpace (TokenPn 1 1 2) \" \"])),NT (JSDecimal \"1\") (TokenPn 4 1 5) [WhiteSpace (TokenPn 3 1 4) \" \"]]),NN (JSExpression [NT (JSIdentifier \"y\") (TokenPn 8 2 3) [WhiteSpace (TokenPn 5 1 6) \"\\n \"],NN (JSOperator (NT (JSLiteral \"=\") (TokenPn 9 2 4) [NoComment])),NT (JSDecimal \"2\") (TokenPn 10 2 5) [NoComment]]),NT (JSLiteral \";\") (TokenPn 11 2 6) [NoComment],NT (JSLiteral \"\") (TokenPn 0 0 0) [NoComment]]))")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
316
317 -- https://github.com/alanz/language-javascript/issues/2
06077c5 @alanz Ongoing simplification of AST
authored
318 , testCase "issue2" (testProg "var img = document.createElement('img');\nimg.src = \"mylogo.jpg\";\n$(img).click(function() {\n alert('clicked!');\n});" "Right (JSSourceElementsTop [JSVariables JSLiteral \"var\" [JSVarDecl (JSIdentifier \"img\") [JSLiteral \"=\",JSMemberDot [JSIdentifier \"document\"] (JSIdentifier \"createElement\"),JSArguments [JSStringLiteral '\\'' \"img\"]]],JSExpression [JSMemberDot [JSIdentifier \"img\"] (JSIdentifier \"src\"),JSOperator JSLiteral \"=\",JSStringLiteral '\"' \"mylogo.jpg\"],JSLiteral \";\",JSExpression [JSIdentifier \"$\",JSArguments [JSIdentifier \"img\"],JSCallExpression \".\" [JSIdentifier \"click\"],JSCallExpression \"()\" [JSArguments [JSFunctionExpression [] [] (JSBlock ([JSExpression [JSIdentifier \"alert\",JSArguments [JSStringLiteral '\\'' \"clicked!\"]],JSLiteral \";\"]))]]],JSLiteral \";\",JSLiteral \"\"])")
1561235 @alanz Investigating issue #2. The given test case passes?
authored
319
f9f8d11 @alanz Allow LineContinuation in string literal (ECMASCRIPT 5.1]
authored
320
321 -- Working in ECMASCRIPT 5.1 changes
3707ce6 @alanz Seem to have roundtrip sorted out.
authored
322 , testCase "lineTerminatorInString1" (testProg "x='abc\\\ndef';" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSStringLiteral '\\'' \"abc\\\\\\ndef\"],JSLiteral \";\",JSLiteral \"\"])")
323 , testCase "lineTerminatorInString2" (testProg "x=\"abc\\\ndef\";" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSStringLiteral '\"' \"abc\\\\\\ndef\"],JSLiteral \";\",JSLiteral \"\"])")
324 , testCase "lineTerminatorInString3" (testProg "x=\"abc\\\rdef\";" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSStringLiteral '\"' \"abc\\\\\\rdef\"],JSLiteral \";\",JSLiteral \"\"])")
325 , testCase "lineTerminatorInString4" (testProg "x=\"abc\\\x2028 def\";" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSStringLiteral '\"' \"abc\\\\\\8232 def\"],JSLiteral \";\",JSLiteral \"\"])")
326 , testCase "lineTerminatorInString5" (testProg "x=\"abc\\\x2029 def\";" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSStringLiteral '\"' \"abc\\\\\\8233 def\"],JSLiteral \";\",JSLiteral \"\"])")
327 , testCase "lineTerminatorInString6" (testProg "x=\"abc\\\r\ndef\";" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSStringLiteral '\"' \"abc\\\\\\r\\ndef\"],JSLiteral \";\",JSLiteral \"\"])")
f9f8d11 @alanz Allow LineContinuation in string literal (ECMASCRIPT 5.1]
authored
328
d61a2f9 @alanz Preparing for 0.4.7. Continue ECMASCRIPT update, remove incorrect
authored
329
330 -- https://github.com/alanz/language-javascript/issues/4
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
331 , testCase "issue4ok" (testProg "var k = {\ny: somename\n}" "Right (JSSourceElementsTop [JSVariables JSLiteral \"var\" [JSVarDecl (JSIdentifier \"k\") [JSLiteral \"=\",JSObjectLiteral [JSPropertyNameandValue (JSIdentifier \"y\") [JSIdentifier \"somename\"]]]],JSLiteral \"\"])")
332 , testCase "issue4bug1" (testProg "var k = {\ny: code\n}" "Right (JSSourceElementsTop [JSVariables JSLiteral \"var\" [JSVarDecl (JSIdentifier \"k\") [JSLiteral \"=\",JSObjectLiteral [JSPropertyNameandValue (JSIdentifier \"y\") [JSIdentifier \"code\"]]]],JSLiteral \"\"])")
333 , testCase "issue4bug2" (testProg "var k = {\ny: mode\n}" "Right (JSSourceElementsTop [JSVariables JSLiteral \"var\" [JSVarDecl (JSIdentifier \"k\") [JSLiteral \"=\",JSObjectLiteral [JSPropertyNameandValue (JSIdentifier \"y\") [JSIdentifier \"mode\"]]]],JSLiteral \"\"])")
d61a2f9 @alanz Preparing for 0.4.7. Continue ECMASCRIPT update, remove incorrect
authored
334
e28d42e @alanz Test shows error for issue #5
authored
335 -- https://github.com/alanz/language-javascript/issues/5
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
336 , testCase "issue5bug1" (testProg "x = { y: 1e8 }" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSObjectLiteral [JSPropertyNameandValue (JSIdentifier \"y\") [JSDecimal \"1e8\"]]],JSLiteral \"\"])")
bbb74a6 @alanz More simplifications of AST and Grammar.
authored
337 , testCase "issue5ok2" (testProg "{ y: 1e8 }" "Right (JSSourceElementsTop [JSBlock ([JSLabelled (JSIdentifier \"y\") (JSExpression [JSDecimal \"1e8\"])]),JSLiteral \"\"])")
338 , testCase "issue5ok3" (testProg "{ y: 18 }" "Right (JSSourceElementsTop [JSBlock ([JSLabelled (JSIdentifier \"y\") (JSExpression [JSDecimal \"18\"])]),JSLiteral \"\"])")
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
339 , testCase "issue5ok4" (testProg "x = { y: 18 }" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSObjectLiteral [JSPropertyNameandValue (JSIdentifier \"y\") [JSDecimal \"18\"]]],JSLiteral \"\"])")
8296513 @alanz Close issue #5 by correcting the lexical analyser for DecimalLiteral. Ve...
authored
340
77bd381 @alanz Fixed bug where lexer does switches to regexp mode after a ']' char, rep...
authored
341 -- https://github.com/alanz/language-javascript/issues/14
342 , testCase "issue14" (testProg "var z = x[i] / y;" "Right (JSSourceElementsTop [JSVariables JSLiteral \"var\" [JSVarDecl (JSIdentifier \"z\") [JSLiteral \"=\",JSExpressionBinary \"/\" [JSMemberSquare [JSIdentifier \"x\"] (JSExpression [JSIdentifier \"i\"])] [JSIdentifier \"y\"]]],JSLiteral \"\"])")
8296513 @alanz Close issue #5 by correcting the lexical analyser for DecimalLiteral. Ve...
authored
343
f2115d2 @alanz Builds and runs tests. Need to make test pass.
authored
344 ]
345
3b4db7d @alanz Starting to work in actual Javascript grammar.
authored
346 srcHelloWorld = "Hello"
1561235 @alanz Investigating issue #2. The given test case passes?
authored
347 caseHelloWorld =
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
348 "JSSourceElementsTop [JSExpression [JSIdentifier \"Hello\"],JSLiteral \"\"]"
2dc267c @alanz Simplifying AST to work more cleanly with hjsmin.
authored
349 -- @=? (show $ parse srcHelloWorld "src")
46a565c @alanz Now passing all tests, by ignoring location. Time to work in tests for l...
authored
350 @=? (showStripped $ readJs srcHelloWorld)
1561235 @alanz Investigating issue #2. The given test case passes?
authored
351
28faefb @alanz Making progress on literals.
authored
352
353 -- ---------------------------------------------------------------------
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
354
edc4c0b @alanz Progress on tests
authored
355 commentSuite :: Test
356 commentSuite = testGroup "Comments"
357 [
358 testCase "helloWorld" caseHelloWorld
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
359 , testCase "LiteralNull" (testLiteralC "/*a*/null" "Right (NS (JSLiteral \"null\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"])")
360 , testCase "LiteralFalse" (testLiteralC "/*b*/false" "Right (NS (JSLiteral \"false\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*b*/\"])")
edc4c0b @alanz Progress on tests
authored
361 , testCase "LiteralTrue" (testLiteralC "true" "Right (NS (JSLiteral \"true\") (TokenPn 0 1 1) [NoComment])")
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
362 , testCase "LiteralTrue" (testLiteralC "/*c*/true" "Right (NS (JSLiteral \"true\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*c*/\"])")
edc4c0b @alanz Progress on tests
authored
363
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
364 , testCase "LiteralHexInteger" (testLiteralC "/*d*/0x1234fF" "Right (NS (JSHexInteger \"0x1234fF\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*d*/\"])")
365 , testCase "LiteralDecimal" (testLiteralC "/*e*/1.0e4" "Right (NS (JSDecimal \"1.0e4\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*e*/\"])")
991d05e @aszlig Implement parsing for octal numbers.
aszlig authored
366 , testCase "LiteralOctal" (testLiteralC "/*x*/011" "Right (NS (JSOctal \"011\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*x*/\"])")
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
367 , testCase "LiteralString1" (testLiteralC "/*f*/\"hello\\nworld\"" "Right (NS (JSStringLiteral '\"' \"hello\\\\nworld\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*f*/\"])")
368 , testCase "LiteralString2" (testLiteralC "/*g*/'hello\\nworld'" "Right (NS (JSStringLiteral '\\'' \"hello\\\\nworld\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*g*/\"])")
edc4c0b @alanz Progress on tests
authored
369
370
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
371 , testCase "LiteralThis" (testPEC "/*h*/this" "Right (NS (JSLiteral \"this\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*h*/\"])")
edc4c0b @alanz Progress on tests
authored
372
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
373 , testCase "LiteralRegex1" (testPEC "/*i*//blah/" "Right (NS (JSRegEx \"/blah/\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*i*/\"])")
edc4c0b @alanz Progress on tests
authored
374
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
375 , testCase "Identifier2" (testPEC "//j\nthis_" "Right (NS (JSIdentifier \"this_\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"//j\"])")
edc4c0b @alanz Progress on tests
authored
376
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
377 , testCase "ArrayLiteral1" (testPEC "/*a*/[/*b*/]" "Right (NS (JSArrayLiteral []) (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\",CommentA (TokenPn 6 1 7) \"/*b*/\"])")
378 , testCase "ArrayLiteral2" (testPEC "/*a*/[/*b*/,/*c*/]" "Right (NS (JSArrayLiteral [NS (JSElision []) (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]]) (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\",CommentA (TokenPn 12 1 13) \"/*c*/\"])")
379 , testCase "ArrayLiteral3" (testPEC "/*a*/[/*b*/,/*c*/,/*d*/]" "Right (NS (JSArrayLiteral [NS (JSElision []) (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"],NS (JSElision []) (TokenPn 12 1 13) [CommentA (TokenPn 12 1 13) \"/*c*/\"]]) (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\",CommentA (TokenPn 18 1 19) \"/*d*/\"])")
380 , testCase "ArrayLiteral4" (testPEC "/*a*/[/*b/*,/*c*/,/*d*/x/*e*/]" "Right (NS (JSArrayLiteral [NS (JSElision []) (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b/*,/*c*/\"],NS (JSIdentifier \"x\") (TokenPn 18 1 19) [CommentA (TokenPn 18 1 19) \"/*d*/\"]]) (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\",CommentA (TokenPn 24 1 25) \"/*e*/\"])")
381 , testCase "ArrayLiteral5" (testPEC "/*a*/[/*b*/,/*c*/,/*d*/x/*e*/]" "Right (NS (JSArrayLiteral [NS (JSElision []) (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"],NS (JSElision []) (TokenPn 12 1 13) [CommentA (TokenPn 12 1 13) \"/*c*/\"],NS (JSIdentifier \"x\") (TokenPn 18 1 19) [CommentA (TokenPn 18 1 19) \"/*d*/\"]]) (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\",CommentA (TokenPn 24 1 25) \"/*e*/\"])")
382 , testCase "ArrayLiteral6" (testPEC "/*a*/[/*b*/,/*c*/x/*d*/,/*e*/,/*f*/x/*g*/]" "Right (NS (JSArrayLiteral [NS (JSElision []) (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"],NS (JSIdentifier \"x\") (TokenPn 12 1 13) [CommentA (TokenPn 12 1 13) \"/*c*/\"],NS (JSElision []) (TokenPn 18 1 19) [CommentA (TokenPn 18 1 19) \"/*d*/\"],NS (JSElision []) (TokenPn 24 1 25) [CommentA (TokenPn 24 1 25) \"/*e*/\"],NS (JSIdentifier \"x\") (TokenPn 30 1 31) [CommentA (TokenPn 30 1 31) \"/*f*/\"]]) (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\",CommentA (TokenPn 36 1 37) \"/*g*/\"])")
383 , testCase "ArrayLiteral7" (testPEC "/*a*/[/*b*/x/*c*/]" "Right (NS (JSArrayLiteral [NS (JSIdentifier \"x\") (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]]) (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\",CommentA (TokenPn 12 1 13) \"/*c*/\"])")
384 , testCase "ArrayLiteral8" (testPEC "/*a*/[/*b*/x/*c*/,/*d*/]" "Right (NS (JSArrayLiteral [NS (JSIdentifier \"x\") (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"],NS (JSLiteral \",\") (TokenPn 17 1 18) [CommentA (TokenPn 12 1 13) \"/*c*/\"]]) (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\",CommentA (TokenPn 18 1 19) \"/*d*/\"])")
edc4c0b @alanz Progress on tests
authored
385
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
386 , testCase "ObjectLiteral1" (testPEC "/*a*/{/*b*/}" "Right (NS (JSObjectLiteral []) (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\",CommentA (TokenPn 6 1 7) \"/*b*/\"])")
387 , testCase "ObjectLiteral2" (testPEC "/*a*/{/*b*/x/*c*/:/*d*/1/*e*/}" "Right (NS (JSObjectLiteral [NS (JSPropertyNameandValue (NS (JSIdentifier \"x\") (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]) [NS (JSDecimal \"1\") (TokenPn 18 1 19) [CommentA (TokenPn 18 1 19) \"/*d*/\"]]) (TokenPn 12 1 13) [CommentA (TokenPn 12 1 13) \"/*c*/\"]]) (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\",CommentA (TokenPn 24 1 25) \"/*e*/\"])")
388 , testCase "ObjectLiteral3" (testPEC "/*a*/{/*b*/x/*c*/:/*d*/1/*e*/,/*f*/y/*g*/:/*h*/2/*i*/}" "Right (NS (JSObjectLiteral [NS (JSPropertyNameandValue (NS (JSIdentifier \"x\") (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]) [NS (JSDecimal \"1\") (TokenPn 18 1 19) [CommentA (TokenPn 18 1 19) \"/*d*/\"]]) (TokenPn 12 1 13) [CommentA (TokenPn 12 1 13) \"/*c*/\"],NS (JSPropertyNameandValue (NS (JSIdentifier \"y\") (TokenPn 30 1 31) [CommentA (TokenPn 30 1 31) \"/*f*/\"]) [NS (JSDecimal \"2\") (TokenPn 42 1 43) [CommentA (TokenPn 42 1 43) \"/*h*/\"]]) (TokenPn 36 1 37) [CommentA (TokenPn 24 1 25) \"/*e*/\",CommentA (TokenPn 36 1 37) \"/*g*/\"]]) (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\",CommentA (TokenPn 48 1 49) \"/*i*/\"])")
edc4c0b @alanz Progress on tests
authored
389
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
390 , testCase "ObjectLiteral5" (testPEC "/*a*/{/*b*/x/*c*/:/*d*/1/*e*/,/*f*/}" "Right (NS (JSObjectLiteral [NS (JSPropertyNameandValue (NS (JSIdentifier \"x\") (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]) [NS (JSDecimal \"1\") (TokenPn 18 1 19) [CommentA (TokenPn 18 1 19) \"/*d*/\"]]) (TokenPn 12 1 13) [CommentA (TokenPn 12 1 13) \"/*c*/\"],NS (JSLiteral \",\") (TokenPn 29 1 30) [CommentA (TokenPn 24 1 25) \"/*e*/\"]]) (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\",CommentA (TokenPn 30 1 31) \"/*f*/\"])")
edc4c0b @alanz Progress on tests
authored
391
db38d58 @alanz More tests.
authored
392 -- Edition 5 extensions
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
393 , testCase "ObjectLiteral7" (testProgC "/*a*/x/*b*/=/*c*/{/*d*/get/*e*/ foo/*f*/(/*g*/)/*h*/ {/*i*/return/*j*/ 1/*k*/}/*l*/,/*m*/set/*n*/ foo/*o*/(/*p*/a/*q*/) /*r*/{/*s*/x/*t*/=/*u*/a/*v*/}/*w*/}" "Right (NS (JSSourceElementsTop [NS (JSExpression [NS (JSIdentifier \"x\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"],NS (JSOperator \"=\") (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"],NS (JSObjectLiteral [NS (JSPropertyAccessor \"get\" (NS (JSIdentifier \"foo\") (TokenPn 26 1 27) [CommentA (TokenPn 26 1 27) \"/*e*/\"]) [] (NS (JSFunctionBody [NS (JSSourceElements [NS (JSReturn [NS (JSExpression [NS (JSDecimal \"1\") (TokenPn 65 1 66) [CommentA (TokenPn 65 1 66) \"/*j*/\"]]) (TokenPn 65 1 66) [],NS (JSLiteral \"\") (TokenPn 0 0 0) []]) (TokenPn 54 1 55) [CommentA (TokenPn 54 1 55) \"/*i*/\"]]) (TokenPn 54 1 55) []]) (TokenPn 54 1 55) [])) (TokenPn 18 1 19) [CommentA (TokenPn 18 1 19) \"/*d*/\",CommentA (TokenPn 35 1 36) \"/*f*/\",CommentA (TokenPn 41 1 42) \"/*g*/\",CommentA (TokenPn 47 1 48) \"/*h*/\",CommentA (TokenPn 72 1 73) \"/*k*/\"],NS (JSPropertyAccessor \"set\" (NS (JSIdentifier \"foo\") (TokenPn 92 1 93) [CommentA (TokenPn 92 1 93) \"/*n*/\"]) [NS (JSIdentifier \"a\") (TokenPn 107 1 108) [CommentA (TokenPn 107 1 108) \"/*p*/\"]] (NS (JSFunctionBody [NS (JSSourceElements [NS (JSExpression [NS (JSIdentifier \"x\") (TokenPn 126 1 127) [CommentA (TokenPn 126 1 127) \"/*s*/\"],NS (JSOperator \"=\") (TokenPn 132 1 133) [CommentA (TokenPn 132 1 133) \"/*t*/\"],NS (JSIdentifier \"a\") (TokenPn 138 1 139) [CommentA (TokenPn 138 1 139) \"/*u*/\"]]) (TokenPn 126 1 127) []]) (TokenPn 126 1 127) []]) (TokenPn 126 1 127) [])) (TokenPn 84 1 85) [CommentA (TokenPn 78 1 79) \"/*l*/\",CommentA (TokenPn 84 1 85) \"/*m*/\",CommentA (TokenPn 101 1 102) \"/*o*/\",CommentA (TokenPn 113 1 114) \"/*q*/\",CommentA (TokenPn 120 1 121) \"/*r*/\",CommentA (TokenPn 144 1 145) \"/*v*/\"]]) (TokenPn 12 1 13) [CommentA (TokenPn 12 1 13) \"/*c*/\",CommentA (TokenPn 150 1 151) \"/*w*/\"]]) (TokenPn 0 1 1) []]) (TokenPn 0 1 1) [])")
edc4c0b @alanz Progress on tests
authored
394
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
395 , testCase "ExpressionParen" (testPEC "/*a*/(/*b*/56/*c*/)" "Right (NS (JSExpressionParen (NS (JSExpression [NS (JSDecimal \"56\") (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]]) (TokenPn 6 1 7) [])) (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\",CommentA (TokenPn 13 1 14) \"/*c*/\"])")
edc4c0b @alanz Progress on tests
authored
396
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
397 , testCase "Statement1" (testStmtC "/*a*/x" "Right (NS (JSExpression [NS (JSIdentifier \"x\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"]]) (TokenPn 0 1 1) [])")
edc4c0b @alanz Progress on tests
authored
398
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
399 , testCase "Statement2" (testStmtC "/*a*/null" "Right (NS (JSExpression [NS (JSLiteral \"null\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"]]) (TokenPn 0 1 1) [])")
edc4c0b @alanz Progress on tests
authored
400
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
401 , testCase "Statement3" (testStmtC "/*a*/true/*b*/?/*c*/1/*d*/:/*e*/2" "Right (NS (JSExpression [NS (JSExpressionTernary [NS (JSLiteral \"true\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"]] [NS (JSDecimal \"1\") (TokenPn 15 1 16) [CommentA (TokenPn 15 1 16) \"/*c*/\"]] [NS (JSDecimal \"2\") (TokenPn 27 1 28) [CommentA (TokenPn 27 1 28) \"/*e*/\"]]) (TokenPn 9 1 10) [CommentA (TokenPn 9 1 10) \"/*b*/\",CommentA (TokenPn 21 1 22) \"/*d*/\"]]) (TokenPn 9 1 10) [])")
edc4c0b @alanz Progress on tests
authored
402
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
403 , testCase "Statement4" (testStmtC "/*a*/x/*b*/||/*c*/y" "Right (NS (JSExpression [NS (JSExpressionBinary \"||\" [NS (JSIdentifier \"x\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"]] [NS (JSIdentifier \"y\") (TokenPn 13 1 14) [CommentA (TokenPn 13 1 14) \"/*c*/\"]]) (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]]) (TokenPn 6 1 7) [])")
edc4c0b @alanz Progress on tests
authored
404
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
405 , testCase "Statement5" (testStmtC "/*a*/x/*b*/&&/*c*/y" "Right (NS (JSExpression [NS (JSExpressionBinary \"&&\" [NS (JSIdentifier \"x\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"]] [NS (JSIdentifier \"y\") (TokenPn 13 1 14) [CommentA (TokenPn 13 1 14) \"/*c*/\"]]) (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]]) (TokenPn 6 1 7) [])")
edc4c0b @alanz Progress on tests
authored
406
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
407 , testCase "Statement6a" (testStmtC "/*a*/x/*b*/|/*c*/y" "Right (NS (JSExpression [NS (JSExpressionBinary \"|\" [NS (JSIdentifier \"x\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"]] [NS (JSIdentifier \"y\") (TokenPn 12 1 13) [CommentA (TokenPn 12 1 13) \"/*c*/\"]]) (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]]) (TokenPn 6 1 7) [])")
edc4c0b @alanz Progress on tests
authored
408
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
409 , testCase "Statement6b" (testStmtC "/*a*/x/*b*/^/*c*/y" "Right (NS (JSExpression [NS (JSExpressionBinary \"^\" [NS (JSIdentifier \"x\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"]] [NS (JSIdentifier \"y\") (TokenPn 12 1 13) [CommentA (TokenPn 12 1 13) \"/*c*/\"]]) (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]]) (TokenPn 6 1 7) [])")
db38d58 @alanz More tests.
authored
410
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
411 , testCase "Statement7" (testStmtC "/*a*/x/*b*/&/*c*/y" "Right (NS (JSExpression [NS (JSExpressionBinary \"&\" [NS (JSIdentifier \"x\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"]] [NS (JSIdentifier \"y\") (TokenPn 12 1 13) [CommentA (TokenPn 12 1 13) \"/*c*/\"]]) (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]]) (TokenPn 6 1 7) [])")
db38d58 @alanz More tests.
authored
412
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
413 , testCase "Statement8" (testStmtC "/*a*/x/*b*/==/*c*/y" "Right (NS (JSExpression [NS (JSExpressionBinary \"==\" [NS (JSIdentifier \"x\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"]] [NS (JSIdentifier \"y\") (TokenPn 13 1 14) [CommentA (TokenPn 13 1 14) \"/*c*/\"]]) (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]]) (TokenPn 6 1 7) [])")
db38d58 @alanz More tests.
authored
414
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
415 , testCase "Statement9" (testStmtC "/*a*/x/*b*/!=/*c*/y" "Right (NS (JSExpression [NS (JSExpressionBinary \"!=\" [NS (JSIdentifier \"x\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"]] [NS (JSIdentifier \"y\") (TokenPn 13 1 14) [CommentA (TokenPn 13 1 14) \"/*c*/\"]]) (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]]) (TokenPn 6 1 7) [])")
db38d58 @alanz More tests.
authored
416
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
417 , testCase "Statement10" (testStmtC "/*a*/x/*b*/===/*c*/y" "Right (NS (JSExpression [NS (JSExpressionBinary \"===\" [NS (JSIdentifier \"x\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"]] [NS (JSIdentifier \"y\") (TokenPn 14 1 15) [CommentA (TokenPn 14 1 15) \"/*c*/\"]]) (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]]) (TokenPn 6 1 7) [])")
db38d58 @alanz More tests.
authored
418
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
419 , testCase "Statement11" (testStmtC "/*a*/x/*b*/!==/*c*/y" "Right (NS (JSExpression [NS (JSExpressionBinary \"!==\" [NS (JSIdentifier \"x\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"]] [NS (JSIdentifier \"y\") (TokenPn 14 1 15) [CommentA (TokenPn 14 1 15) \"/*c*/\"]]) (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]]) (TokenPn 6 1 7) [])")
db38d58 @alanz More tests.
authored
420
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
421 , testCase "Statement12a" (testStmtC "/*a*/x/*b*/</*c*/y" "Right (NS (JSExpression [NS (JSExpressionBinary \"<\" [NS (JSIdentifier \"x\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"]] [NS (JSIdentifier \"y\") (TokenPn 12 1 13) [CommentA (TokenPn 12 1 13) \"/*c*/\"]]) (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]]) (TokenPn 6 1 7) [])")
db38d58 @alanz More tests.
authored
422
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
423 , testCase "Statement12b" (testStmtC "/*a*/x/*b*/>/*c*/y" "Right (NS (JSExpression [NS (JSExpressionBinary \">\" [NS (JSIdentifier \"x\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"]] [NS (JSIdentifier \"y\") (TokenPn 12 1 13) [CommentA (TokenPn 12 1 13) \"/*c*/\"]]) (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]]) (TokenPn 6 1 7) [])")
db38d58 @alanz More tests.
authored
424
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
425 , testCase "Statement12c" (testStmtC "/*a*/x/*b*/<=/*c*/y" "Right (NS (JSExpression [NS (JSExpressionBinary \"<=\" [NS (JSIdentifier \"x\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"]] [NS (JSIdentifier \"y\") (TokenPn 13 1 14) [CommentA (TokenPn 13 1 14) \"/*c*/\"]]) (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]]) (TokenPn 6 1 7) [])")
db38d58 @alanz More tests.
authored
426
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
427 , testCase "Statement12d" (testStmtC "/*a*/x/*b*/>=/*c*/y" "Right (NS (JSExpression [NS (JSExpressionBinary \">=\" [NS (JSIdentifier \"x\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"]] [NS (JSIdentifier \"y\") (TokenPn 13 1 14) [CommentA (TokenPn 13 1 14) \"/*c*/\"]]) (TokenPn 6 1 7) [CommentA (TokenPn 6 1 7) \"/*b*/\"]]) (TokenPn 6 1 7) [])")
db38d58 @alanz More tests.
authored
428
b96b185 @alanz Make sure the JSNode position is the earlier of the comment or the subtr...
authored
429 , testCase "Statement12e" (testStmtC "/*a*/x /*b*/instanceof /*c*/y" "Right (NS (JSExpression [NS (JSExpressionBinary \" instanceof \" [NS (JSIdentifier \"x\") (TokenPn 0 1 1) [CommentA (TokenPn 0 1 1) \"/*a*/\"]] [NS (JSIdentifier \"y\") (TokenPn 23 1 24) [CommentA (TokenPn 23 1 24) \"/*c*/\"]]) (TokenPn 7 1 8) [CommentA (TokenPn 7 1 8) \"/*b*/\"]]) (TokenPn 7 1 8) [])")
db38d58 @alanz More tests.
authored
430
edc4c0b @alanz Progress on tests
authored
431 ]
432
433 -- ---------------------------------------------------------------------
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
434
435 commentPrintSuite :: Test
436 commentPrintSuite = testGroup "Comments"
437 [
803c73d @alanz Making progress.
authored
438 testCase "Multi-comment" (testRoundTrip "/*a*/\n//foo\nnull")
439
440
441 , testCase "LiteralNull" (testRoundTrip "/*a*/null")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
442 , testCase "LiteralFalse" (testRoundTrip "/*b*/false")
443 , testCase "LiteralTrue" (testRoundTrip "true")
444 , testCase "LiteralTrue" (testRoundTrip "/*c*/true")
445
446 , testCase "LiteralHexInteger" (testRoundTrip "/*d*/0x1234fF")
447 , testCase "LiteralDecimal" (testRoundTrip "/*e*/1.0e4")
991d05e @aszlig Implement parsing for octal numbers.
aszlig authored
448 , testCase "LiteralOctal" (testRoundTrip "/*x*/011")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
449 , testCase "LiteralString1" (testRoundTrip "/*f*/\"hello\\nworld\"")
450 , testCase "LiteralString2" (testRoundTrip "/*g*/'hello\\nworld'")
451
452
453 , testCase "LiteralThis" (testRoundTrip "/*h*/this")
454
455 , testCase "LiteralRegex1" (testRoundTrip "/*i*//blah/")
456
457 , testCase "Identifier2" (testRoundTrip "//j\nthis_")
458
459 , testCase "ArrayLiteral1" (testRoundTrip "/*a*/[/*b*/]")
460 , testCase "ArrayLiteral2" (testRoundTrip "/*a*/[/*b*/,/*c*/]")
461 , testCase "ArrayLiteral3" (testRoundTrip "/*a*/[/*b*/,/*c*/,/*d*/]")
462 , testCase "ArrayLiteral4" (testRoundTrip "/*a*/[/*b/*,/*c*/,/*d*/x/*e*/]")
463 , testCase "ArrayLiteral5" (testRoundTrip "/*a*/[/*b*/,/*c*/,/*d*/x/*e*/]")
464 , testCase "ArrayLiteral6" (testRoundTrip "/*a*/[/*b*/,/*c*/x/*d*/,/*e*/,/*f*/x/*g*/]")
465 , testCase "ArrayLiteral7" (testRoundTrip "/*a*/[/*b*/x/*c*/]")
466 , testCase "ArrayLiteral8" (testRoundTrip "/*a*/[/*b*/x/*c*/,/*d*/]")
467
468 , testCase "ObjectLiteral1" (testRoundTrip "/*a*/{/*b*/}")
469 , testCase "ObjectLiteral2" (testRoundTrip "/*a*/{/*b*/x/*c*/:/*d*/1/*e*/}")
4335e58 @alanz Progress
authored
470 , testCase "ObjectLiteral3" (testRoundTrip "x=/*a*/{/*b*/x/*c*/:/*d*/1/*e*/,/*f*/y/*g*/:/*h*/2/*i*/}")
80f48b6 @alanz WIP
authored
471 , testCase "ObjectLiteral3a" (testRoundTrip "x=/*a*/{/*b*/x/*c*/:/*d*/1/*e*/,/*f*/y/*g*/:/*h*/2/*i*/,/*j*/z/*k*/:/*l*/3/*m*/}")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
472
80f48b6 @alanz WIP
authored
473 , testCase "ObjectLiteral5" (testRoundTrip "a=/*a*/{/*b*/x/*c*/:/*d*/1/*e*/,/*f*/}")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
474
475 -- Edition 5 extensions
476 , testCase "ObjectLiteral7" (testRoundTrip "/*a*/x/*b*/=/*c*/{/*d*/get/*e*/ foo/*f*/(/*g*/)/*h*/ {/*i*/return/*j*/ 1/*k*/}/*l*/,/*m*/set/*n*/ foo/*o*/(/*p*/a/*q*/) /*r*/{/*s*/x/*t*/=/*u*/a/*v*/}/*w*/}")
477
478 , testCase "ExpressionParen" (testRoundTrip "/*a*/(/*b*/56/*c*/)")
479
480 , testCase "Statement1" (testRoundTrip "/*a*/x")
481
482 , testCase "Statement2" (testRoundTrip "/*a*/null")
483
484 , testCase "Statement3" (testRoundTrip "/*a*/true/*b*/?/*c*/1/*d*/:/*e*/2")
485
486 , testCase "Statement4" (testRoundTrip "/*a*/x/*b*/||/*c*/y")
487
488 , testCase "Statement5" (testRoundTrip "/*a*/x/*b*/&&/*c*/y")
489
490 , testCase "Statement6a" (testRoundTrip "/*a*/x/*b*/|/*c*/y")
491
492 , testCase "Statement6b" (testRoundTrip "/*a*/x/*b*/^/*c*/y")
493
494 , testCase "Statement7" (testRoundTrip "/*a*/x/*b*/&/*c*/y")
495
496 , testCase "Statement8" (testRoundTrip "/*a*/x/*b*/==/*c*/y")
497
498 , testCase "Statement9" (testRoundTrip "/*a*/x/*b*/!=/*c*/y")
499
500 , testCase "Statement10" (testRoundTrip "/*a*/x/*b*/===/*c*/y")
501
502 , testCase "Statement11" (testRoundTrip "/*a*/x/*b*/!==/*c*/y")
503
504 , testCase "Statement12a" (testRoundTrip "/*a*/x/*b*/</*c*/y")
505
506 , testCase "Statement12b" (testRoundTrip "/*a*/x/*b*/>/*c*/y")
507
508 , testCase "Statement12c" (testRoundTrip "/*a*/x/*b*/<=/*c*/y")
509
510 , testCase "Statement12d" (testRoundTrip "/*a*/x/*b*/>=/*c*/y")
511
512 , testCase "Statement12e" (testRoundTrip "/*a*/x /*b*/instanceof /*c*/y")
513
514
515
87774e4 @alanz WIP
authored
516 , testCase "Statement13" (testRoundTrip "x<<y")
517 , testCase "Statement13" (testRoundTrip "x>>y")
518 , testCase "Statement13" (testRoundTrip "x>>>y")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
519
87774e4 @alanz WIP
authored
520 , testCase "Statement14" (testRoundTrip "x+y")
521 , testCase "Statement14" (testRoundTrip "x-y")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
522
87774e4 @alanz WIP
authored
523 , testCase "Statement15" (testRoundTrip "x*y")
524 , testCase "Statement16" (testRoundTrip "x/y")
525 , testCase "Statement17" (testRoundTrip "x%y")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
526
87774e4 @alanz WIP
authored
527 , testCase "Statement18" (testRoundTrip "delete y")
528 , testCase "Statement19" (testRoundTrip "void y")
529 , testCase "Statement20" (testRoundTrip "typeof y")
530 , testCase "Statement21" (testRoundTrip "++y")
531 , testCase "Statement22" (testRoundTrip "--y")
532 , testCase "Statement23" (testRoundTrip "+y")
533 , testCase "Statement24" (testRoundTrip "-y")
534 , testCase "Statement25" (testRoundTrip "~y")
535 , testCase "Statement26" (testRoundTrip "!y")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
536
87774e4 @alanz WIP
authored
537 , testCase "Statement27" (testRoundTrip "y++")
538 , testCase "Statement28" (testRoundTrip "y--")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
539
540 -- Member Expressions
01e8617 @alanz Proper UTF8 output
authored
541 , testCase "MemberExpression1a" (testRoundTrip "function(){}")
542 , testCase "MemberExpression1b" (testRoundTrip "function(a){}")
543 , testCase "MemberExpression1c" (testRoundTrip "function(a,b){}")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
544
01e8617 @alanz Proper UTF8 output
authored
545 , testCase "MemberExpression1d" (testRoundTrip "x[y]")
546 , testCase "MemberExpression1e" (testRoundTrip "x[y][z]")
547 , testCase "MemberExpression1f" (testRoundTrip "x.y")
548 , testCase "MemberExpression1g" (testRoundTrip "x.y.z")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
549
01e8617 @alanz Proper UTF8 output
authored
550 , testCase "MemberExpression1h" (testRoundTrip "new x()")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
551
87774e4 @alanz WIP
authored
552 , testCase "NewExpression1" (testRoundTrip "new x.y")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
553
87774e4 @alanz WIP
authored
554 , testCase "CallExpression1" (testRoundTrip "x()")
555 , testCase "CallExpression2" (testRoundTrip "x()()")
556 , testCase "CallExpression3" (testRoundTrip "x()[4]")
557 , testCase "CallExpression4" (testRoundTrip "x().x")
558 , testCase "CallExpression5" (testRoundTrip "x(a,b=2).x")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
559
87774e4 @alanz WIP
authored
560 , testCase "AssignExpression1" (testRoundTrip "x=1")
561 , testCase "AssignExpression1" (testRoundTrip "x*=1")
562 , testCase "AssignExpression1" (testRoundTrip "x/=1")
563 , testCase "AssignExpression1" (testRoundTrip "x%=1")
564 , testCase "AssignExpression1" (testRoundTrip "x+=1")
565 , testCase "AssignExpression1" (testRoundTrip "x-=1")
566 , testCase "AssignExpression1" (testRoundTrip "x<<=1")
567 , testCase "AssignExpression1" (testRoundTrip "x>>=1")
568 , testCase "AssignExpression1" (testRoundTrip "x>>>=1")
569 , testCase "AssignExpression1" (testRoundTrip "x&=1")
570 , testCase "AssignExpression1" (testRoundTrip "x^=1")
571 , testCase "AssignExpression1" (testRoundTrip "x|=1")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
572
573
87774e4 @alanz WIP
authored
574 , testCase "Block1" (testRoundTrip "{}")
575 , testCase "Block2" (testRoundTrip "{x=1}")
576 , testCase "Block3" (testRoundTrip "{x=1;y=2}")
577 , testCase "Block4" (testRoundTrip "{{}}")
578 , testCase "Block5" (testRoundTrip "{{{}}}")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
579
580
87774e4 @alanz WIP
authored
581 , testCase "If1" (testRoundTrip "if (1) {}")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
582
87774e4 @alanz WIP
authored
583 , testCase "IfElse1" (testRoundTrip "if (1) {} else {}")
584 , testCase "IfElse2" (testRoundTrip "if (1) x=1; else {}")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
585
87774e4 @alanz WIP
authored
586 , testCase "DoWhile1" (testRoundTrip "do {x=1} while (true);")
587 , testCase "While1" (testRoundTrip "while(true);")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
588
87774e4 @alanz WIP
authored
589 , testCase "For1" (testRoundTrip "for(;;);")
590 , testCase "For2" (testRoundTrip "for(x=1;x<10;x++);")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
591
87774e4 @alanz WIP
authored
592 , testCase "ForVar1" (testRoundTrip "for(var x;;);")
593 , testCase "ForVar2" (testRoundTrip "for(var x=1;;);")
594 , testCase "ForVar2" (testRoundTrip "for(var x;y;z){}")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
595
87774e4 @alanz WIP
authored
596 , testCase "ForIn1" (testRoundTrip "for(x in 5){}")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
597
87774e4 @alanz WIP
authored
598 , testCase "ForVarIn1" (testRoundTrip "for(var x in 5){}")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
599
87774e4 @alanz WIP
authored
600 , testCase "Var1" (testRoundTrip "var x=1;")
601 , testCase "Var2" (testRoundTrip "const x=1,y=2;")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
602
603
87774e4 @alanz WIP
authored
604 , testCase "Continue1" (testRoundTrip "continue;")
605 , testCase "Continue2" (testRoundTrip "continue x;")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
606
87774e4 @alanz WIP
authored
607 , testCase "Break1" (testRoundTrip "break;")
608 , testCase "Break2" (testRoundTrip "break x;")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
609
87774e4 @alanz WIP
authored
610 , testCase "Return1" (testRoundTrip "return;")
611 , testCase "Return2" (testRoundTrip "return x;")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
612
87774e4 @alanz WIP
authored
613 , testCase "With1" (testRoundTrip "with (x) {};")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
614
87774e4 @alanz WIP
authored
615 , testCase "Labelled1" (testRoundTrip "abc:x=1")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
616
87774e4 @alanz WIP
authored
617 , testCase "Switch1" (testRoundTrip "switch (x) {}")
618 , testCase "Switch2" (testRoundTrip "switch (x) {case 1:break;}")
619 , testCase "Switch3" (testRoundTrip "switch (x) {case 0:\ncase 1:break;}")
620 , testCase "Switch4" (testRoundTrip "switch (x) {default:break;}")
621 , testCase "Switch5" (testRoundTrip "switch (x) {default:\ncase 1:break;}")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
622
87774e4 @alanz WIP
authored
623 , testCase "Throw1" (testRoundTrip "throw 1")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
624
87774e4 @alanz WIP
authored
625 , testCase "Try1" (testRoundTrip "try{}catch(a){}")
626 , testCase "Try2" (testRoundTrip "try{}finally{}")
627 , testCase "Try3" (testRoundTrip "try{}catch(a){}finally{}")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
628
87774e4 @alanz WIP
authored
629 , testCase "Try4" (testRoundTrip "try{}catch(a){}catch(b){}finally{}")
630 , testCase "Try5" (testRoundTrip "try{}catch(a){}catch(b){}")
631 , testCase "Try6" (testRoundTrip "try{}catch(a if true){}catch(b){}")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
632
87774e4 @alanz WIP
authored
633 , testCase "Function1" (testRoundTrip "function a(){}")
634 , testCase "Function2" (testRoundTrip "function a(b,c){}")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
635
636
87774e4 @alanz WIP
authored
637 , testCase "Comment1" (testRoundTrip "//blah\nx=1;//foo\na")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
638
87774e4 @alanz WIP
authored
639 , testCase "Comment2" (testRoundTrip "/*x=1\ny=2\n*/z=2;//foo\na")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
640
87774e4 @alanz WIP
authored
641 , testCase "min_100_animals1" (testRoundTrip "function Animal(name){if(!name)throw new Error('Must specify an animal name');this.name=name};Animal.prototype.toString=function(){return this.name};o=new Animal(\"bob\");o.toString()==\"bob\"")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
642
87774e4 @alanz WIP
authored
643 , testCase "min_100_animals2" (testRoundTrip "Animal=function(){return this.name};")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
644
87774e4 @alanz WIP
authored
645 , testCase "min_100_animals3" (testRoundTrip "if(a)x=1;y=2")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
646
87774e4 @alanz WIP
authored
647 , testCase "min_100_animals4" (testRoundTrip "if(a)x=a()y=2")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
648
87774e4 @alanz WIP
authored
649 , testCase "05_regex" (testRoundTrip "newlines=spaces.match(/\\n/g)")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
650
87774e4 @alanz WIP
authored
651 , testCase "05_regex2" (testRoundTrip "x=/\\n/g")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
652
87774e4 @alanz WIP
authored
653 , testCase "05_regex3" (testRoundTrip "x=i(/[?|^&(){}\\[\\]+\\-*\\/\\.]/g,\"\\\\$&\")")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
654
87774e4 @alanz WIP
authored
655 , testCase "05_regex4" (testRoundTrip "x=i(/^$/g,\"\\\\$&\")")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
656
87774e4 @alanz WIP
authored
657 , testCase "05_regex5" (testRoundTrip "if(/^[a-z]/.test(t)){consts+=t.toUpperCase();keywords[t]=i}else consts+=(/^\\W/.test(t)?opTypeNames[t]:t);")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
658
87774e4 @alanz WIP
authored
659 , testCase "if_semi" (testRoundTrip "if(x);x=1")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
660
87774e4 @alanz WIP
authored
661 , testCase "67_bob" (testRoundTrip "(match = /^\"(?:\\\\.|[^\"])*\"|^'(?:[^']|\\\\.)*'/(input))")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
662
87774e4 @alanz WIP
authored
663 , testCase "122_jsexec" (testRoundTrip "v = getValue(execute(n[0], x)) in getValue(execute(n[1], x));")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
664
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
665 , testCase "bug1a" (testRoundTrip "/* */\nfunction f() {\n/* */\n}")
666 , testCase "bug1b" (testRoundTrip "/* **/\nfunction f() {\n/* */\n}")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
667
dd8c858 @alanz Cleaning up AST
authored
668 , testCase "unicode1-ws" (testRoundTrip "a \f\v\t\r\n=\x00a0\x1680\x180e\x2000\x2001\x2002\x2003\x2004\x2005\x2006\x2007\x2008\x2009\x200a\x2028\x2029\x202f\x205f\x3000\&1;")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
669
87774e4 @alanz WIP
authored
670 , testCase "unicode2-lt" (testRoundTrip "//comment\x000Ax=1;")
671 , testCase "unicode3-lt" (testRoundTrip "//comment\x000Dx=1;")
672 , testCase "unicode4-lt" (testRoundTrip "//comment\x2028x=1;")
673 , testCase "unicode5-lt" (testRoundTrip "//comment\x2029x=1;")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
674
87774e4 @alanz WIP
authored
675 , testCase "unicode2" (testRoundTrip "àáâãäå = 1;")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
676
87774e4 @alanz WIP
authored
677 , testCase "unicode3" (testRoundTrip "$aà = 1;_b=2;\0065a=2")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
678
87774e4 @alanz WIP
authored
679 , testCase "unicode4" (testRoundTrip "x=\"àáâãäå\";y='\3012a\0068'")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
680
87774e4 @alanz WIP
authored
681 -- , testCase "unicode5" (testFile "./test/Unicode.js")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
682
87774e4 @alanz WIP
authored
683 , testCase "bug2.a" (testRoundTrip "function() {\nz = function /*z*/(o) {\nreturn r;\n};}")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
684
87774e4 @alanz WIP
authored
685 , testCase "bug2.b" (testRoundTrip "function() {\nz = function z(o) {\nreturn r;\n};}")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
686
87774e4 @alanz WIP
authored
687 -- https://github.com/alanz/hjsmin/issues/#issue/3
688 , testCase "bug3" (testRoundTrip "var myLatlng = new google.maps.LatLng(56.8379100, 60.5806664);")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
689
87774e4 @alanz WIP
authored
690 -- https://github.com/alanz/hjsmin/issues/#issue/4
691 , testCase "bug4" (testRoundTrip "/* * geolocation. пытаемся определить свое местоположение * если не получается то используем defaultLocation * @Param {object} map экземпляр карты * @Param {object LatLng} defaultLocation Координаты центра по умолчанию * @Param {function} callbackAfterLocation Фу-ия которая вызывается после * геолокации. Т.к запрос геолокации асинхронен */x")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
692
87774e4 @alanz WIP
authored
693 , testCase "02_sm.js" (testRoundTrip "{zero}\none1;two\n{three\nfour;five;\n{\nsix;{seven;}\n}\n}")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
694
87774e4 @alanz WIP
authored
695 , testCase "02_sm.js.2" (testRoundTrip "{zero}\nget;two\n{three\nfour;set;\n{\nsix;{seven;}\n}\n}")
696
697 , testCase "loc1" (testRoundTrip "x = 1\n y=2;")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
698
699 -- https://github.com/alanz/language-javascript/issues/2
87774e4 @alanz WIP
authored
700 , testCase "issue2" (testRoundTrip "var img = document.createElement('img');\nimg.src = \"mylogo.jpg\";\n$(img).click(function() {\n alert('clicked!');\n});")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
701
702
703 -- Working in ECMASCRIPT 5.1 changes
87774e4 @alanz WIP
authored
704 , testCase "lineTerminatorInString1" (testRoundTrip "x='abc\\\ndef';")
705 , testCase "lineTerminatorInString2" (testRoundTrip "x=\"abc\\\ndef\";")
706 , testCase "lineTerminatorInString3" (testRoundTrip "x=\"abc\\\rdef\";")
707 , testCase "lineTerminatorInString4" (testRoundTrip "x=\"abc\\\x2028 def\";")
708 , testCase "lineTerminatorInString5" (testRoundTrip "x=\"abc\\\x2029 def\";")
709 , testCase "lineTerminatorInString6" (testRoundTrip "x=\"abc\\\r\ndef\";")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
710
711
712 -- https://github.com/alanz/language-javascript/issues/4
87774e4 @alanz WIP
authored
713 , testCase "issue4ok" (testRoundTrip "var k = {\ny: somename\n}")
714 , testCase "issue4bug1" (testRoundTrip "var k = {\ny: code\n}")
715 , testCase "issue4bug2" (testRoundTrip "var k = {\ny: mode\n}")
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
716
717 -- https://github.com/alanz/language-javascript/issues/5
87774e4 @alanz WIP
authored
718 , testCase "issue5bug1" (testRoundTrip "x = { y: 1e8 }")
719 , testCase "issue5ok2" (testRoundTrip "{ y: 1e8 }")
720 , testCase "issue5ok3" (testRoundTrip "{ y: 18 }")
721 , testCase "issue5ok4" (testRoundTrip "x = { y: 18 }")
722
dd8c858 @alanz Cleaning up AST
authored
723 -- function body
724 , testCase "functionbody" (testRoundTrip "function foo(a,b,c)\n{x=1;}")
725 , testCase "functionexpression" (testRoundTrip "function foo(a,b,c)\n{x=1;}")
726
727 , testCase "fn1" (testRoundTrip "function foo() { return 5; }")
728 , testCase "fn2" (testRoundTrip "var foo = function() { return 5; }")
729 , testCase "fn3" (testRoundTrip "var foo = function foo() { return 5; }")
730
e8c28c1 @alanz Fixed silly error where parsing mode was not set correctly if whitespace...
authored
731 -- Parse failure in hjsmin
732 , testCase "parsefail" (testRoundTrip "switch(t){case DIV: v = u / v; break;}")
77bd381 @alanz Fixed bug where lexer does switches to regexp mode after a ']' char, rep...
authored
733
734 -- https://github.com/alanz/language-javascript/issues/14
735 , testCase "issue14" (testRoundTrip "var z = x[i] / y;")
aed80f7 @alanz Test and fix for #15. Fix based on @erikd fork.
authored
736
737 -- https://github.com/alanz/language-javascript/issues/15
738 , testCase "issue15" (testRoundTrip "x\t=1;")
739
c8a74d6 @erikd Fix handling of empty file and file containing only comments. Tests
erikd authored
740 , testCase "comment-only" (testRoundTrip "// comment\n\n")
741 , testCase "empty-src" (testRoundTrip "")
aed80f7 @alanz Test and fix for #15. Fix based on @erikd fork.
authored
742 ]
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
743
744 -- ---------------------------------------------------------------------
28faefb @alanz Making progress on literals.
authored
745 -- Test utilities
746
9be3f38 @alanz Parser in good shape, working the pretty printer output.
authored
747 testRoundTrip str = str @=? (renderToString $ readJs str)
748
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
749 testLiteral :: String -> String -> Assertion
edc4c0b @alanz Progress on tests
authored
750 testLiteral literal expected = expected @=? (showStrippedMaybe $ parseUsing parseLiteral literal "src")
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
751 testLiteralC :: String -> String -> Assertion
edc4c0b @alanz Progress on tests
authored
752 testLiteralC literal expected = expected @=? (show $ parseUsing parseLiteral literal "src")
753
f2115d2 @alanz Builds and runs tests. Need to make test pass.
authored
754
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
755 testPE :: String -> String -> Assertion
edc4c0b @alanz Progress on tests
authored
756 testPE str expected = expected @=? (showStrippedMaybe $ parseUsing parsePrimaryExpression str "src")
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
757 testPEC :: String -> String -> Assertion
edc4c0b @alanz Progress on tests
authored
758 testPEC str expected = expected @=? (show $ parseUsing parsePrimaryExpression str "src")
1b88772 @alanz Starting to work in PrimaryExpression.
authored
759
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
760 testStmt :: String -> String -> Assertion
db38d58 @alanz More tests.
authored
761 testStmt str expected = expected @=? (showStrippedMaybe $ parseUsing parseStatement str "src")
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
762 testStmtC :: String -> String -> Assertion
db38d58 @alanz More tests.
authored
763 testStmtC str expected = expected @=? (show $ parseUsing parseStatement str "src")
46a565c @alanz Now passing all tests, by ignoring location. Time to work in tests for l...
authored
764
765 --testProg str expected = expected @=? (show $ parseUsing parseProgram str "src")
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
766 testProg :: String -> String -> Assertion
db38d58 @alanz More tests.
authored
767 testProg str expected = expected @=? (showStrippedMaybe $ parseUsing parseProgram str "src")
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
768 testProgC :: String -> String -> Assertion
db38d58 @alanz More tests.
authored
769 testProgC str expected = expected @=? (show $ parseUsing parseProgram str "src")
eaa4a80 @alanz Working in fuller grammar.
authored
770
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
771 testProgUn :: String -> String -> Assertion
1ffcdca @alanz Preparing for 0.4.0. Updated JSNode to include location information, an...
authored
772 testProgUn str expected = expected @=? (show $ parseUsing parseProgram str "src")
773
b4f405f @alanz All parser productions implemented, and comment processing included in L...
authored
774
092cee0 @alanz Time to keep track of whitespace too. Maybe merge comments and ws.
authored
775 testFile :: FilePath -> String -> IO ()
370c4fb @alanz Worked in unicode spaces and line separators.
authored
776 testFile fileName expected = do
777 res <- parseFile fileName
778 -- expected @=? (liftM show $ parseFile fileName)
46a565c @alanz Now passing all tests, by ignoring location. Time to work in tests for l...
authored
779 (expected @=? (showStripped res))
370c4fb @alanz Worked in unicode spaces and line separators.
authored
780
98e5bfe @alanz Introduce parseFileUtf8 to explicitly use utf8 for parsing a file, and u...
authored
781 testFileUtf8 :: FilePath -> String -> IO ()
782 testFileUtf8 fileName expected = do
783 res <- parseFileUtf8 fileName
784 -- expected @=? (liftM show $ parseFile fileName)
785 (expected @=? (showStripped res))
786
370c4fb @alanz Worked in unicode spaces and line separators.
authored
787
788 -- Set emacs mode
1561235 @alanz Investigating issue #2. The given test case passes?
authored
789 -- Local Variables:
370c4fb @alanz Worked in unicode spaces and line separators.
authored
790 -- coding: utf-8
1561235 @alanz Investigating issue #2. The given test case passes?
authored
791 -- End:
1b88772 @alanz Starting to work in PrimaryExpression.
authored
792
f2115d2 @alanz Builds and runs tests. Need to make test pass.
authored
793 -- EOF
Something went wrong with that request. Please try again.