coffeescript-router 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/.gitignore +3 -0
  2. data/Cakefile +122 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +22 -0
  5. data/LICENSE.txt +19 -0
  6. data/README.md +18 -0
  7. data/Rakefile +2 -0
  8. data/SpecRunner.html +25 -0
  9. data/coffeescript-router.gemspec +19 -0
  10. data/lib/CoffeeScript.png +0 -0
  11. data/lib/coffeescript-router/version.rb +5 -0
  12. data/lib/jasmine-1.0.2/MIT.LICENSE +20 -0
  13. data/lib/jasmine-1.0.2/jasmine-html.js +188 -0
  14. data/lib/jasmine-1.0.2/jasmine.css +166 -0
  15. data/lib/jasmine-1.0.2/jasmine.js +2421 -0
  16. data/node_modules/.bin/cake +7 -0
  17. data/node_modules/.bin/coffee +7 -0
  18. data/node_modules/.bin/uglifyjs +212 -0
  19. data/node_modules/coffee-script/.npmignore +11 -0
  20. data/node_modules/coffee-script/LICENSE +22 -0
  21. data/node_modules/coffee-script/README +48 -0
  22. data/node_modules/coffee-script/Rakefile +78 -0
  23. data/node_modules/coffee-script/bin/cake +7 -0
  24. data/node_modules/coffee-script/bin/coffee +7 -0
  25. data/node_modules/coffee-script/lib/browser.js +75 -0
  26. data/node_modules/coffee-script/lib/cake.js +76 -0
  27. data/node_modules/coffee-script/lib/coffee-script.js +107 -0
  28. data/node_modules/coffee-script/lib/command.js +274 -0
  29. data/node_modules/coffee-script/lib/grammar.js +591 -0
  30. data/node_modules/coffee-script/lib/helpers.js +66 -0
  31. data/node_modules/coffee-script/lib/index.js +8 -0
  32. data/node_modules/coffee-script/lib/lexer.js +650 -0
  33. data/node_modules/coffee-script/lib/nodes.js +2230 -0
  34. data/node_modules/coffee-script/lib/optparse.js +111 -0
  35. data/node_modules/coffee-script/lib/parser.js +676 -0
  36. data/node_modules/coffee-script/lib/repl.js +114 -0
  37. data/node_modules/coffee-script/lib/rewriter.js +359 -0
  38. data/node_modules/coffee-script/lib/scope.js +120 -0
  39. data/node_modules/coffee-script/package.json +27 -0
  40. data/node_modules/growl/History.md +16 -0
  41. data/node_modules/growl/Readme.md +74 -0
  42. data/node_modules/growl/lib/growl.js +82 -0
  43. data/node_modules/growl/package.json +6 -0
  44. data/node_modules/growl/test.js +17 -0
  45. data/node_modules/uglify-js/.gitignore +4 -0
  46. data/node_modules/uglify-js/README.html +825 -0
  47. data/node_modules/uglify-js/README.org +431 -0
  48. data/node_modules/uglify-js/bin/uglifyjs +212 -0
  49. data/node_modules/uglify-js/docstyle.css +75 -0
  50. data/node_modules/uglify-js/lib/parse-js.js +1319 -0
  51. data/node_modules/uglify-js/lib/process.js +1614 -0
  52. data/node_modules/uglify-js/lib/squeeze-more.js +22 -0
  53. data/node_modules/uglify-js/package.json +22 -0
  54. data/node_modules/uglify-js/test/beautify.js +28 -0
  55. data/node_modules/uglify-js/test/testparser.js +402 -0
  56. data/node_modules/uglify-js/test/unit/compress/expected/array1.js +1 -0
  57. data/node_modules/uglify-js/test/unit/compress/expected/array2.js +1 -0
  58. data/node_modules/uglify-js/test/unit/compress/expected/array3.js +1 -0
  59. data/node_modules/uglify-js/test/unit/compress/expected/array4.js +1 -0
  60. data/node_modules/uglify-js/test/unit/compress/expected/assignment.js +1 -0
  61. data/node_modules/uglify-js/test/unit/compress/expected/concatstring.js +1 -0
  62. data/node_modules/uglify-js/test/unit/compress/expected/const.js +1 -0
  63. data/node_modules/uglify-js/test/unit/compress/expected/empty-blocks.js +1 -0
  64. data/node_modules/uglify-js/test/unit/compress/expected/forstatement.js +1 -0
  65. data/node_modules/uglify-js/test/unit/compress/expected/if.js +1 -0
  66. data/node_modules/uglify-js/test/unit/compress/expected/ifreturn.js +1 -0
  67. data/node_modules/uglify-js/test/unit/compress/expected/issue10.js +1 -0
  68. data/node_modules/uglify-js/test/unit/compress/expected/issue11.js +1 -0
  69. data/node_modules/uglify-js/test/unit/compress/expected/issue13.js +1 -0
  70. data/node_modules/uglify-js/test/unit/compress/expected/issue14.js +1 -0
  71. data/node_modules/uglify-js/test/unit/compress/expected/issue16.js +1 -0
  72. data/node_modules/uglify-js/test/unit/compress/expected/issue17.js +1 -0
  73. data/node_modules/uglify-js/test/unit/compress/expected/issue20.js +1 -0
  74. data/node_modules/uglify-js/test/unit/compress/expected/issue21.js +1 -0
  75. data/node_modules/uglify-js/test/unit/compress/expected/issue25.js +1 -0
  76. data/node_modules/uglify-js/test/unit/compress/expected/issue27.js +1 -0
  77. data/node_modules/uglify-js/test/unit/compress/expected/issue28.js +1 -0
  78. data/node_modules/uglify-js/test/unit/compress/expected/issue29.js +1 -0
  79. data/node_modules/uglify-js/test/unit/compress/expected/issue30.js +1 -0
  80. data/node_modules/uglify-js/test/unit/compress/expected/issue34.js +1 -0
  81. data/node_modules/uglify-js/test/unit/compress/expected/issue4.js +1 -0
  82. data/node_modules/uglify-js/test/unit/compress/expected/issue48.js +1 -0
  83. data/node_modules/uglify-js/test/unit/compress/expected/issue50.js +1 -0
  84. data/node_modules/uglify-js/test/unit/compress/expected/issue53.js +1 -0
  85. data/node_modules/uglify-js/test/unit/compress/expected/issue54.1.js +1 -0
  86. data/node_modules/uglify-js/test/unit/compress/expected/issue68.js +1 -0
  87. data/node_modules/uglify-js/test/unit/compress/expected/issue69.js +1 -0
  88. data/node_modules/uglify-js/test/unit/compress/expected/issue9.js +1 -0
  89. data/node_modules/uglify-js/test/unit/compress/expected/strict-equals.js +1 -0
  90. data/node_modules/uglify-js/test/unit/compress/expected/var.js +1 -0
  91. data/node_modules/uglify-js/test/unit/compress/test/array1.js +3 -0
  92. data/node_modules/uglify-js/test/unit/compress/test/array2.js +4 -0
  93. data/node_modules/uglify-js/test/unit/compress/test/array3.js +4 -0
  94. data/node_modules/uglify-js/test/unit/compress/test/array4.js +6 -0
  95. data/node_modules/uglify-js/test/unit/compress/test/assignment.js +20 -0
  96. data/node_modules/uglify-js/test/unit/compress/test/concatstring.js +3 -0
  97. data/node_modules/uglify-js/test/unit/compress/test/const.js +5 -0
  98. data/node_modules/uglify-js/test/unit/compress/test/empty-blocks.js +4 -0
  99. data/node_modules/uglify-js/test/unit/compress/test/forstatement.js +10 -0
  100. data/node_modules/uglify-js/test/unit/compress/test/if.js +6 -0
  101. data/node_modules/uglify-js/test/unit/compress/test/ifreturn.js +9 -0
  102. data/node_modules/uglify-js/test/unit/compress/test/issue10.js +1 -0
  103. data/node_modules/uglify-js/test/unit/compress/test/issue11.js +3 -0
  104. data/node_modules/uglify-js/test/unit/compress/test/issue13.js +1 -0
  105. data/node_modules/uglify-js/test/unit/compress/test/issue14.js +1 -0
  106. data/node_modules/uglify-js/test/unit/compress/test/issue16.js +1 -0
  107. data/node_modules/uglify-js/test/unit/compress/test/issue17.js +4 -0
  108. data/node_modules/uglify-js/test/unit/compress/test/issue20.js +1 -0
  109. data/node_modules/uglify-js/test/unit/compress/test/issue21.js +6 -0
  110. data/node_modules/uglify-js/test/unit/compress/test/issue25.js +7 -0
  111. data/node_modules/uglify-js/test/unit/compress/test/issue27.js +1 -0
  112. data/node_modules/uglify-js/test/unit/compress/test/issue28.js +3 -0
  113. data/node_modules/uglify-js/test/unit/compress/test/issue29.js +1 -0
  114. data/node_modules/uglify-js/test/unit/compress/test/issue30.js +3 -0
  115. data/node_modules/uglify-js/test/unit/compress/test/issue34.js +3 -0
  116. data/node_modules/uglify-js/test/unit/compress/test/issue4.js +3 -0
  117. data/node_modules/uglify-js/test/unit/compress/test/issue48.js +1 -0
  118. data/node_modules/uglify-js/test/unit/compress/test/issue50.js +9 -0
  119. data/node_modules/uglify-js/test/unit/compress/test/issue53.js +1 -0
  120. data/node_modules/uglify-js/test/unit/compress/test/issue54.1.js +3 -0
  121. data/node_modules/uglify-js/test/unit/compress/test/issue68.js +5 -0
  122. data/node_modules/uglify-js/test/unit/compress/test/issue69.js +1 -0
  123. data/node_modules/uglify-js/test/unit/compress/test/issue9.js +4 -0
  124. data/node_modules/uglify-js/test/unit/compress/test/strict-equals.js +3 -0
  125. data/node_modules/uglify-js/test/unit/compress/test/var.js +3 -0
  126. data/node_modules/uglify-js/test/unit/scripts.js +46 -0
  127. data/node_modules/uglify-js/uglify-js.js +2 -0
  128. data/src/coffeescript/coffeescript-router.js.coffee +31 -0
  129. data/test/coffeescript/routerSpec.coffee +47 -0
  130. data/vendor/assets/javascripts/coffeescript-router.min.js +1 -0
  131. metadata +187 -0
@@ -0,0 +1,22 @@
1
+ var jsp = require("./parse-js"),
2
+ pro = require("./process"),
3
+ slice = jsp.slice,
4
+ member = jsp.member,
5
+ PRECEDENCE = jsp.PRECEDENCE,
6
+ OPERATORS = jsp.OPERATORS;
7
+
8
+ function ast_squeeze_more(ast) {
9
+ var w = pro.ast_walker(), walk = w.walk;
10
+ return w.with_walkers({
11
+ "call": function(expr, args) {
12
+ if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) {
13
+ // foo.toString() ==> foo+""
14
+ return [ "binary", "+", expr[1], [ "string", "" ]];
15
+ }
16
+ }
17
+ }, function() {
18
+ return walk(ast);
19
+ });
20
+ };
21
+
22
+ exports.ast_squeeze_more = ast_squeeze_more;
@@ -0,0 +1,22 @@
1
+ {
2
+ "name" : "uglify-js",
3
+
4
+ "author" : {
5
+ "name" : "Mihai Bazon",
6
+ "email" : "mihai.bazon@gmail.com",
7
+ "url" : "http://mihai.bazon.net/blog"
8
+ },
9
+
10
+ "version" : "1.0.1",
11
+
12
+ "main" : "./uglify-js.js",
13
+
14
+ "bin" : {
15
+ "uglifyjs" : "./bin/uglifyjs"
16
+ },
17
+
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git@github.com:mishoo/UglifyJS.git"
21
+ }
22
+ }
@@ -0,0 +1,28 @@
1
+ #! /usr/bin/env node
2
+
3
+ global.sys = require("sys");
4
+ var fs = require("fs");
5
+
6
+ var jsp = require("../lib/parse-js");
7
+ var pro = require("../lib/process");
8
+
9
+ var filename = process.argv[2];
10
+ fs.readFile(filename, "utf8", function(err, text){
11
+ try {
12
+ var ast = time_it("parse", function(){ return jsp.parse(text); });
13
+ ast = time_it("mangle", function(){ return pro.ast_mangle(ast); });
14
+ ast = time_it("squeeze", function(){ return pro.ast_squeeze(ast); });
15
+ var gen = time_it("generate", function(){ return pro.gen_code(ast, false); });
16
+ sys.puts(gen);
17
+ } catch(ex) {
18
+ sys.debug(ex.stack);
19
+ sys.debug(sys.inspect(ex));
20
+ sys.debug(JSON.stringify(ex));
21
+ }
22
+ });
23
+
24
+ function time_it(name, cont) {
25
+ var t1 = new Date().getTime();
26
+ try { return cont(); }
27
+ finally { sys.debug("// " + name + ": " + ((new Date().getTime() - t1) / 1000).toFixed(3) + " sec."); }
28
+ };
@@ -0,0 +1,402 @@
1
+ #! /usr/bin/env node
2
+
3
+ var parseJS = require("../lib/parse-js");
4
+ var sys = require("sys");
5
+
6
+ // write debug in a very straightforward manner
7
+ var debug = function(){
8
+ sys.log(Array.prototype.slice.call(arguments).join(', '));
9
+ };
10
+
11
+ ParserTestSuite(function(i, input, desc){
12
+ try {
13
+ parseJS.parse(input);
14
+ debug("ok " + i + ": " + desc);
15
+ } catch(e){
16
+ debug("FAIL " + i + " " + desc + " (" + e + ")");
17
+ }
18
+ });
19
+
20
+ function ParserTestSuite(callback){
21
+ var inps = [
22
+ ["var abc;", "Regular variable statement w/o assignment"],
23
+ ["var abc = 5;", "Regular variable statement with assignment"],
24
+ ["/* */;", "Multiline comment"],
25
+ ['/** **/;', 'Double star multiline comment'],
26
+ ["var f = function(){;};", "Function expression in var assignment"],
27
+ ['hi; // moo\n;', 'single line comment'],
28
+ ['var varwithfunction;', 'Dont match keywords as substrings'], // difference between `var withsomevar` and `"str"` (local search and lits)
29
+ ['a + b;', 'addition'],
30
+ ["'a';", 'single string literal'],
31
+ ["'a\\n';", 'single string literal with escaped return'],
32
+ ['"a";', 'double string literal'],
33
+ ['"a\\n";', 'double string literal with escaped return'],
34
+ ['"var";', 'string is a keyword'],
35
+ ['"variable";', 'string starts with a keyword'],
36
+ ['"somevariable";', 'string contains a keyword'],
37
+ ['"somevar";', 'string ends with a keyword'],
38
+ ['500;', 'int literal'],
39
+ ['500.;', 'float literal w/o decimals'],
40
+ ['500.432;', 'float literal with decimals'],
41
+ ['.432432;', 'float literal w/o int'],
42
+ ['(a,b,c);', 'parens and comma'],
43
+ ['[1,2,abc];', 'array literal'],
44
+ ['var o = {a:1};', 'object literal unquoted key'],
45
+ ['var o = {"b":2};', 'object literal quoted key'], // opening curly may not be at the start of a statement...
46
+ ['var o = {c:c};', 'object literal keyname is identifier'],
47
+ ['var o = {a:1,"b":2,c:c};', 'object literal combinations'],
48
+ ['var x;\nvar y;', 'two lines'],
49
+ ['var x;\nfunction n(){; }', 'function def'],
50
+ ['var x;\nfunction n(abc){; }', 'function def with arg'],
51
+ ['var x;\nfunction n(abc, def){ ;}', 'function def with args'],
52
+ ['function n(){ "hello"; }', 'function def with body'],
53
+ ['/a/;', 'regex literal'],
54
+ ['/a/b;', 'regex literal with flag'],
55
+ ['/a/ / /b/;', 'regex div regex'],
56
+ ['a/b/c;', 'triple division looks like regex'],
57
+ ['+function(){/regex/;};', 'regex at start of function body'],
58
+ // http://code.google.com/p/es-lab/source/browse/trunk/tests/parser/parsertests.js?r=86
59
+ // http://code.google.com/p/es-lab/source/browse/trunk/tests/parser/parsertests.js?r=430
60
+
61
+ // first tests for the lexer, should also parse as program (when you append a semi)
62
+
63
+ // comments
64
+ ['//foo!@#^&$1234\nbar;', 'single line comment'],
65
+ ['/* abcd!@#@$* { } && null*/;', 'single line multi line comment'],
66
+ ['/*foo\nbar*/;','multi line comment'],
67
+ ['/*x*x*/;','multi line comment with *'],
68
+ ['/**/;','empty comment'],
69
+ // identifiers
70
+ ["x;",'1 identifier'],
71
+ ["_x;",'2 identifier'],
72
+ ["xyz;",'3 identifier'],
73
+ ["$x;",'4 identifier'],
74
+ ["x$;",'5 identifier'],
75
+ ["_;",'6 identifier'],
76
+ ["x5;",'7 identifier'],
77
+ ["x_y;",'8 identifier'],
78
+ ["x+5;",'9 identifier'],
79
+ ["xyz123;",'10 identifier'],
80
+ ["x1y1z1;",'11 identifier'],
81
+ ["foo\\u00D8bar;",'12 identifier unicode escape'],
82
+ //["foo�bar;",'13 identifier unicode embedded (might fail)'],
83
+ // numbers
84
+ ["5;", '1 number'],
85
+ ["5.5;", '2 number'],
86
+ ["0;", '3 number'],
87
+ ["0.0;", '4 number'],
88
+ ["0.001;", '5 number'],
89
+ ["1.e2;", '6 number'],
90
+ ["1.e-2;", '7 number'],
91
+ ["1.E2;", '8 number'],
92
+ ["1.E-2;", '9 number'],
93
+ [".5;", '10 number'],
94
+ [".5e3;", '11 number'],
95
+ [".5e-3;", '12 number'],
96
+ ["0.5e3;", '13 number'],
97
+ ["55;", '14 number'],
98
+ ["123;", '15 number'],
99
+ ["55.55;", '16 number'],
100
+ ["55.55e10;", '17 number'],
101
+ ["123.456;", '18 number'],
102
+ ["1+e;", '20 number'],
103
+ ["0x01;", '22 number'],
104
+ ["0XCAFE;", '23 number'],
105
+ ["0x12345678;", '24 number'],
106
+ ["0x1234ABCD;", '25 number'],
107
+ ["0x0001;", '26 number'],
108
+ // strings
109
+ ["\"foo\";", '1 string'],
110
+ ["\'foo\';", '2 string'],
111
+ ["\"x\";", '3 string'],
112
+ ["\'\';", '4 string'],
113
+ ["\"foo\\tbar\";", '5 string'],
114
+ ["\"!@#$%^&*()_+{}[]\";", '6 string'],
115
+ ["\"/*test*/\";", '7 string'],
116
+ ["\"//test\";", '8 string'],
117
+ ["\"\\\\\";", '9 string'],
118
+ ["\"\\u0001\";", '10 string'],
119
+ ["\"\\uFEFF\";", '11 string'],
120
+ ["\"\\u10002\";", '12 string'],
121
+ ["\"\\x55\";", '13 string'],
122
+ ["\"\\x55a\";", '14 string'],
123
+ ["\"a\\\\nb\";", '15 string'],
124
+ ['";"', '16 string: semi in a string'],
125
+ ['"a\\\nb";', '17 string: line terminator escape'],
126
+ // literals
127
+ ["null;", "null"],
128
+ ["true;", "true"],
129
+ ["false;", "false"],
130
+ // regex
131
+ ["/a/;", "1 regex"],
132
+ ["/abc/;", "2 regex"],
133
+ ["/abc[a-z]*def/g;", "3 regex"],
134
+ ["/\\b/;", "4 regex"],
135
+ ["/[a-zA-Z]/;", "5 regex"],
136
+
137
+ // program tests (for as far as they havent been covered above)
138
+
139
+ // regexp
140
+ ["/foo(.*)/g;", "another regexp"],
141
+ // arrays
142
+ ["[];", "1 array"],
143
+ ["[ ];", "2 array"],
144
+ ["[1];", "3 array"],
145
+ ["[1,2];", "4 array"],
146
+ ["[1,2,,];", "5 array"],
147
+ ["[1,2,3];", "6 array"],
148
+ ["[1,2,3,,,];", "7 array"],
149
+ // objects
150
+ ["{};", "1 object"],
151
+ ["({x:5});", "2 object"],
152
+ ["({x:5,y:6});", "3 object"],
153
+ ["({x:5,});", "4 object"],
154
+ ["({if:5});", "5 object"],
155
+ ["({ get x() {42;} });", "6 object"],
156
+ ["({ set y(a) {1;} });", "7 object"],
157
+ // member expression
158
+ ["o.m;", "1 member expression"],
159
+ ["o['m'];", "2 member expression"],
160
+ ["o['n']['m'];", "3 member expression"],
161
+ ["o.n.m;", "4 member expression"],
162
+ ["o.if;", "5 member expression"],
163
+ // call and invoke expressions
164
+ ["f();", "1 call/invoke expression"],
165
+ ["f(x);", "2 call/invoke expression"],
166
+ ["f(x,y);", "3 call/invoke expression"],
167
+ ["o.m();", "4 call/invoke expression"],
168
+ ["o['m'];", "5 call/invoke expression"],
169
+ ["o.m(x);", "6 call/invoke expression"],
170
+ ["o['m'](x);", "7 call/invoke expression"],
171
+ ["o.m(x,y);", "8 call/invoke expression"],
172
+ ["o['m'](x,y);", "9 call/invoke expression"],
173
+ ["f(x)(y);", "10 call/invoke expression"],
174
+ ["f().x;", "11 call/invoke expression"],
175
+
176
+ // eval
177
+ ["eval('x');", "1 eval"],
178
+ ["(eval)('x');", "2 eval"],
179
+ ["(1,eval)('x');", "3 eval"],
180
+ ["eval(x,y);", "4 eval"],
181
+ // new expression
182
+ ["new f();", "1 new expression"],
183
+ ["new o;", "2 new expression"],
184
+ ["new o.m;", "3 new expression"],
185
+ ["new o.m(x);", "4 new expression"],
186
+ ["new o.m(x,y);", "5 new expression"],
187
+ // prefix/postfix
188
+ ["++x;", "1 pre/postfix"],
189
+ ["x++;", "2 pre/postfix"],
190
+ ["--x;", "3 pre/postfix"],
191
+ ["x--;", "4 pre/postfix"],
192
+ ["x ++;", "5 pre/postfix"],
193
+ ["x /* comment */ ++;", "6 pre/postfix"],
194
+ ["++ /* comment */ x;", "7 pre/postfix"],
195
+ // unary operators
196
+ ["delete x;", "1 unary operator"],
197
+ ["void x;", "2 unary operator"],
198
+ ["+ x;", "3 unary operator"],
199
+ ["-x;", "4 unary operator"],
200
+ ["~x;", "5 unary operator"],
201
+ ["!x;", "6 unary operator"],
202
+ // meh
203
+ ["new Date++;", "new date ++"],
204
+ ["+x++;", " + x ++"],
205
+ // expression expressions
206
+ ["1 * 2;", "1 expression expressions"],
207
+ ["1 / 2;", "2 expression expressions"],
208
+ ["1 % 2;", "3 expression expressions"],
209
+ ["1 + 2;", "4 expression expressions"],
210
+ ["1 - 2;", "5 expression expressions"],
211
+ ["1 << 2;", "6 expression expressions"],
212
+ ["1 >>> 2;", "7 expression expressions"],
213
+ ["1 >> 2;", "8 expression expressions"],
214
+ ["1 * 2 + 3;", "9 expression expressions"],
215
+ ["(1+2)*3;", "10 expression expressions"],
216
+ ["1*(2+3);", "11 expression expressions"],
217
+ ["x<y;", "12 expression expressions"],
218
+ ["x>y;", "13 expression expressions"],
219
+ ["x<=y;", "14 expression expressions"],
220
+ ["x>=y;", "15 expression expressions"],
221
+ ["x instanceof y;", "16 expression expressions"],
222
+ ["x in y;", "17 expression expressions"],
223
+ ["x&y;", "18 expression expressions"],
224
+ ["x^y;", "19 expression expressions"],
225
+ ["x|y;", "20 expression expressions"],
226
+ ["x+y<z;", "21 expression expressions"],
227
+ ["x<y+z;", "22 expression expressions"],
228
+ ["x+y+z;", "23 expression expressions"],
229
+ ["x+y<z;", "24 expression expressions"],
230
+ ["x<y+z;", "25 expression expressions"],
231
+ ["x&y|z;", "26 expression expressions"],
232
+ ["x&&y;", "27 expression expressions"],
233
+ ["x||y;", "28 expression expressions"],
234
+ ["x&&y||z;", "29 expression expressions"],
235
+ ["x||y&&z;", "30 expression expressions"],
236
+ ["x<y?z:w;", "31 expression expressions"],
237
+ // assignment
238
+ ["x >>>= y;", "1 assignment"],
239
+ ["x <<= y;", "2 assignment"],
240
+ ["x = y;", "3 assignment"],
241
+ ["x += y;", "4 assignment"],
242
+ ["x /= y;", "5 assignment"],
243
+ // comma
244
+ ["x, y;", "comma"],
245
+ // block
246
+ ["{};", "1 block"],
247
+ ["{x;};", "2 block"],
248
+ ["{x;y;};", "3 block"],
249
+ // vars
250
+ ["var x;", "1 var"],
251
+ ["var x,y;", "2 var"],
252
+ ["var x=1,y=2;", "3 var"],
253
+ ["var x,y=2;", "4 var"],
254
+ // empty
255
+ [";", "1 empty"],
256
+ ["\n;", "2 empty"],
257
+ // expression statement
258
+ ["x;", "1 expression statement"],
259
+ ["5;", "2 expression statement"],
260
+ ["1+2;", "3 expression statement"],
261
+ // if
262
+ ["if (c) x; else y;", "1 if statement"],
263
+ ["if (c) x;", "2 if statement"],
264
+ ["if (c) {} else {};", "3 if statement"],
265
+ ["if (c1) if (c2) s1; else s2;", "4 if statement"],
266
+ // while
267
+ ["do s; while (e);", "1 while statement"],
268
+ ["do { s; } while (e);", "2 while statement"],
269
+ ["while (e) s;", "3 while statement"],
270
+ ["while (e) { s; };", "4 while statement"],
271
+ // for
272
+ ["for (;;) ;", "1 for statement"],
273
+ ["for (;c;x++) x;", "2 for statement"],
274
+ ["for (i;i<len;++i){};", "3 for statement"],
275
+ ["for (var i=0;i<len;++i) {};", "4 for statement"],
276
+ ["for (var i=0,j=0;;){};", "5 for statement"],
277
+ //["for (x in b; c; u) {};", "6 for statement"],
278
+ ["for ((x in b); c; u) {};", "7 for statement"],
279
+ ["for (x in a);", "8 for statement"],
280
+ ["for (var x in a){};", "9 for statement"],
281
+ ["for (var x=5 in a) {};", "10 for statement"],
282
+ ["for (var x = a in b in c) {};", "11 for statement"],
283
+ ["for (var x=function(){a+b;}; a<b; ++i) some;", "11 for statement, testing for parsingForHeader reset with the function"],
284
+ ["for (var x=function(){for (x=0; x<15; ++x) alert(foo); }; a<b; ++i) some;", "11 for statement, testing for parsingForHeader reset with the function"],
285
+ // flow statements
286
+ ["while(1){ continue; }", "1 flow statement"],
287
+ ["label: while(1){ continue label; }", "2 flow statement"],
288
+ ["while(1){ break; }", "3 flow statement"],
289
+ ["somewhere: while(1){ break somewhere; }", "4 flow statement"],
290
+ ["while(1){ continue /* comment */ ; }", "5 flow statement"],
291
+ ["while(1){ continue \n; }", "6 flow statement"],
292
+ ["(function(){ return; })()", "7 flow statement"],
293
+ ["(function(){ return 0; })()", "8 flow statement"],
294
+ ["(function(){ return 0 + \n 1; })()", "9 flow statement"],
295
+ // with
296
+ ["with (e) s;", "with statement"],
297
+ // switch
298
+ ["switch (e) { case x: s; };", "1 switch statement"],
299
+ ["switch (e) { case x: s1;s2; default: s3; case y: s4; };", "2 switch statement"],
300
+ ["switch (e) { default: s1; case x: s2; case y: s3; };", "3 switch statement"],
301
+ ["switch (e) { default: s; };", "4 switch statement"],
302
+ ["switch (e) { case x: s1; case y: s2; };", "5 switch statement"],
303
+ // labels
304
+ ["foo : x;", " flow statement"],
305
+ // throw
306
+ ["throw x;", "1 throw statement"],
307
+ ["throw x\n;", "2 throw statement"],
308
+ // try catch finally
309
+ ["try { s1; } catch (e) { s2; };", "1 trycatchfinally statement"],
310
+ ["try { s1; } finally { s2; };", "2 trycatchfinally statement"],
311
+ ["try { s1; } catch (e) { s2; } finally { s3; };", "3 trycatchfinally statement"],
312
+ // debugger
313
+ ["debugger;", "debuger statement"],
314
+ // function decl
315
+ ["function f(x) { e; return x; };", "1 function declaration"],
316
+ ["function f() { x; y; };", "2 function declaration"],
317
+ ["function f(x,y) { var z; return x; };", "3 function declaration"],
318
+ // function exp
319
+ ["(function f(x) { return x; });", "1 function expression"],
320
+ ["(function empty() {;});", "2 function expression"],
321
+ ["(function empty() {;});", "3 function expression"],
322
+ ["(function (x) {; });", "4 function expression"],
323
+ // program
324
+ ["var x; function f(){;}; null;", "1 program"],
325
+ [";;", "2 program"],
326
+ ["{ x; y; z; }", "3 program"],
327
+ ["function f(){ function g(){;}};", "4 program"],
328
+ ["x;\n/*foo*/\n ;", "5 program"],
329
+
330
+ // asi
331
+ ["foo: while(1){ continue \n foo; }", "1 asi"],
332
+ ["foo: while(1){ break \n foo; }", "2 asi"],
333
+ ["(function(){ return\nfoo; })()", "3 asi"],
334
+ ["var x; { 1 \n 2 } 3", "4 asi"],
335
+ ["ab /* hi */\ncd", "5 asi"],
336
+ ["ab/*\n*/cd", "6 asi (multi line multilinecomment counts as eol)"],
337
+ ["foo: while(1){ continue /* wtf \n busta */ foo; }", "7 asi illegal with multi line comment"],
338
+ ["function f() { s }", "8 asi"],
339
+ ["function f() { return }", "9 asi"],
340
+
341
+ // use strict
342
+ // XXX: some of these should actually fail?
343
+ // no support for "use strict" yet...
344
+ ['"use strict"; \'bla\'\n; foo;', "1 directive"],
345
+ ['(function() { "use strict"; \'bla\';\n foo; });', "2 directive"],
346
+ ['"use\\n strict";', "3 directive"],
347
+ ['foo; "use strict";', "4 directive"],
348
+
349
+ // tests from http://es5conform.codeplex.com/
350
+
351
+ ['"use strict"; var o = { eval: 42};', "8.7.2-3-1-s: the use of eval as property name is allowed"],
352
+ ['({foo:0,foo:1});', 'Duplicate property name allowed in not strict mode'],
353
+ ['function foo(a,a){}', 'Duplicate parameter name allowed in not strict mode'],
354
+ ['(function foo(eval){})', 'Eval allowed as parameter name in non strict mode'],
355
+ ['(function foo(arguments){})', 'Arguments allowed as parameter name in non strict mode'],
356
+
357
+ // empty programs
358
+
359
+ ['', '1 Empty program'],
360
+ ['// test', '2 Empty program'],
361
+ ['//test\n', '3 Empty program'],
362
+ ['\n// test', '4 Empty program'],
363
+ ['\n// test\n', '5 Empty program'],
364
+ ['/* */', '6 Empty program'],
365
+ ['/*\ns,fd\n*/', '7 Empty program'],
366
+ ['/*\ns,fd\n*/\n', '8 Empty program'],
367
+ [' ', '9 Empty program'],
368
+ [' /*\nsmeh*/ \n ', '10 Empty program'],
369
+
370
+ // trailing whitespace
371
+
372
+ ['a ', '1 Trailing whitespace'],
373
+ ['a /* something */', '2 Trailing whitespace'],
374
+ ['a\n // hah', '3 Trailing whitespace'],
375
+ ['/abc/de//f', '4 Trailing whitespace'],
376
+ ['/abc/de/*f*/\n ', '5 Trailing whitespace'],
377
+
378
+ // things the parser tripped over at one point or the other (prevents regression bugs)
379
+ ['for (x;function(){ a\nb };z) x;', 'for header with function body forcing ASI'],
380
+ ['c=function(){return;return};', 'resetting noAsi after literal'],
381
+ ['d\nd()', 'asi exception causing token overflow'],
382
+ ['for(;;){x=function(){}}', 'function expression in a for header'],
383
+ ['for(var k;;){}', 'parser failing due to ASI accepting the incorrect "for" rule'],
384
+ ['({get foo(){ }})', 'getter with empty function body'],
385
+ ['\nreturnr', 'eol causes return statement to ignore local search requirement'],
386
+ [' / /', '1 whitespace before regex causes regex to fail?'],
387
+ ['/ // / /', '2 whitespace before regex causes regex to fail?'],
388
+ ['/ / / / /', '3 whitespace before regex causes regex to fail?'],
389
+
390
+ ['\n\t// Used for trimming whitespace\n\ttrimLeft = /^\\s+/;\n\ttrimRight = /\\s+$/;\t\n','turned out this didnt crash (the test below did), but whatever.'],
391
+ ['/[\\/]/;', 'escaped forward slash inside class group (would choke on fwd slash)'],
392
+ ['/[/]/;', 'also broke but is valid in es5 (not es3)'],
393
+ ['({get:5});','get property name thats not a getter'],
394
+ ['({set:5});','set property name thats not a setter'],
395
+ ['l !== "px" && (d.style(h, c, (k || 1) + l), j = (k || 1) / f.cur() * j, d.style(h, c, j + l)), i[1] && (k = (i[1] === "-=" ? -1 : 1) * k + j), f.custom(j, k, l)', 'this choked regex/div at some point'],
396
+ ['(/\'/g, \'\\\\\\\'\') + "\'";', 'the sequence of escaped characters confused the tokenizer']
397
+ ];
398
+
399
+ for (var i=0; i<inps.length; ++i) {
400
+ callback(i, inps[i][0], inps[i][1]);
401
+ };
402
+ };