File tree 3 files changed +77
-12
lines changed
3 files changed +77
-12
lines changed Original file line number Diff line number Diff line change @@ -295,7 +295,15 @@ issue_186_beautify: {
295
295
else
296
296
bar ( ) ;
297
297
}
298
- expect_exact: 'var x = 3;\n\nif (foo()) do {\n do {\n alert(x);\n } while (--x);\n} while (x); else bar();'
298
+ expect_exact: [
299
+ 'var x = 3;' ,
300
+ '' ,
301
+ 'if (foo()) do {' ,
302
+ ' do {' ,
303
+ ' alert(x);' ,
304
+ ' } while (--x);' ,
305
+ '} while (x); else bar();' ,
306
+ ]
299
307
}
300
308
301
309
issue_186_beautify_ie8: {
@@ -314,7 +322,17 @@ issue_186_beautify_ie8: {
314
322
else
315
323
bar ( ) ;
316
324
}
317
- expect_exact: 'var x = 3;\n\nif (foo()) {\n do {\n do {\n alert(x);\n } while (--x);\n } while (x);\n} else bar();'
325
+ expect_exact: [
326
+ 'var x = 3;' ,
327
+ '' ,
328
+ 'if (foo()) {' ,
329
+ ' do {' ,
330
+ ' do {' ,
331
+ ' alert(x);' ,
332
+ ' } while (--x);' ,
333
+ ' } while (x);' ,
334
+ '} else bar();' ,
335
+ ]
318
336
}
319
337
320
338
issue_186_bracketize: {
@@ -374,7 +392,19 @@ issue_186_beautify_bracketize: {
374
392
else
375
393
bar ( ) ;
376
394
}
377
- expect_exact: 'var x = 3;\n\nif (foo()) {\n do {\n do {\n alert(x);\n } while (--x);\n } while (x);\n} else {\n bar();\n}'
395
+ expect_exact: [
396
+ 'var x = 3;' ,
397
+ '' ,
398
+ 'if (foo()) {' ,
399
+ ' do {' ,
400
+ ' do {' ,
401
+ ' alert(x);' ,
402
+ ' } while (--x);' ,
403
+ ' } while (x);' ,
404
+ '} else {' ,
405
+ ' bar();' ,
406
+ '}' ,
407
+ ]
378
408
}
379
409
380
410
issue_186_beautify_bracketize_ie8: {
@@ -394,5 +424,17 @@ issue_186_beautify_bracketize_ie8: {
394
424
else
395
425
bar ( ) ;
396
426
}
397
- expect_exact: 'var x = 3;\n\nif (foo()) {\n do {\n do {\n alert(x);\n } while (--x);\n } while (x);\n} else {\n bar();\n}'
427
+ expect_exact: [
428
+ 'var x = 3;' ,
429
+ '' ,
430
+ 'if (foo()) {' ,
431
+ ' do {' ,
432
+ ' do {' ,
433
+ ' alert(x);' ,
434
+ ' } while (--x);' ,
435
+ ' } while (x);' ,
436
+ '} else {' ,
437
+ ' bar();' ,
438
+ '}' ,
439
+ ]
398
440
}
Original file line number Diff line number Diff line change @@ -7,7 +7,13 @@ too_short: {
7
7
return { c : 42 , d : a ( ) , e : "foo" } ;
8
8
}
9
9
}
10
- expect_exact: 'function f(a){\nreturn{\nc:42,\nd:a(),\ne:"foo"}}'
10
+ expect_exact: [
11
+ 'function f(a){' ,
12
+ 'return{' ,
13
+ 'c:42,' ,
14
+ 'd:a(),' ,
15
+ 'e:"foo"}}' ,
16
+ ]
11
17
expect_warnings: [
12
18
"WARN: Output exceeds 10 characters"
13
19
]
@@ -22,7 +28,12 @@ just_enough: {
22
28
return { c : 42 , d : a ( ) , e : "foo" } ;
23
29
}
24
30
}
25
- expect_exact: 'function f(a){\nreturn{c:42,\nd:a(),e:"foo"}\n}'
31
+ expect_exact: [
32
+ 'function f(a){' ,
33
+ 'return{c:42,' ,
34
+ 'd:a(),e:"foo"}' ,
35
+ '}' ,
36
+ ]
26
37
expect_warnings: [
27
38
]
28
39
}
Original file line number Diff line number Diff line change @@ -214,6 +214,23 @@ function parse_test(file) {
214
214
} ) ) ;
215
215
}
216
216
217
+ function read_string ( stat ) {
218
+ if ( stat . TYPE === "SimpleStatement" ) {
219
+ var body = stat . body ;
220
+ out: switch ( body . TYPE ) {
221
+ case "String" :
222
+ return body . value ;
223
+ case "Array" :
224
+ return body . elements . map ( function ( element ) {
225
+ if ( element . TYPE !== "String" )
226
+ throw new Error ( "Should be array of strings" ) ;
227
+ return element . value ;
228
+ } ) . join ( "\n" ) ;
229
+ }
230
+ }
231
+ throw new Error ( "Should be string or array of strings" ) ;
232
+ }
233
+
217
234
function get_one_test ( name , block ) {
218
235
var test = { name : name , options : { } } ;
219
236
var tw = new U . TreeWalker ( function ( node , descend ) {
@@ -240,12 +257,7 @@ function parse_test(file) {
240
257
else if ( stat . body . length == 0 ) stat = new U . AST_EmptyStatement ( ) ;
241
258
}
242
259
if ( node . label . name === "expect_exact" ) {
243
- if ( ! ( stat . TYPE === "SimpleStatement" && stat . body . TYPE === "String" ) ) {
244
- throw new Error (
245
- "The value of the expect_exact clause should be a string, " +
246
- "like `expect_exact: \"some.exact.javascript;\"`" ) ;
247
- }
248
- test [ node . label . name ] = stat . body . start . value
260
+ test [ node . label . name ] = read_string ( stat ) ;
249
261
} else {
250
262
test [ node . label . name ] = stat ;
251
263
}
You can’t perform that action at this time.
0 commit comments