@@ -333,89 +333,52 @@ fn test_nullish() {
333
333
334
334
#[ test]
335
335
fn test_string ( ) {
336
- // No `minify` option
337
-
338
- // Prints double-quoted strings as in original
339
- test ( "let x = \" \" " , "let x = \" \" ;\n " ) ;
340
- test ( "let x = \" abc\" " , "let x = \" abc\" ;\n " ) ;
341
- test ( "let x = \" \t \" " , "let x = \" \t \" ;\n " ) ;
342
- test ( "let x = \" \\ t\" " , "let x = \" \\ t\" ;\n " ) ;
343
-
344
- // Converts single quote to double
345
336
test ( "let x = ''" , "let x = \" \" ;\n " ) ;
346
- test ( "let x = 'abc'" , "let x = \" abc\" ;\n " ) ;
347
- test ( "let x = '\" '" , "let x = \" \\ \" \" ;\n " ) ;
348
- test ( "let x = 'abc\" '" , "let x = \" abc\\ \" \" ;\n " ) ;
349
- test ( "let x = 'abc\" \" \" '" , "let x = \" abc\\ \" \\ \" \\ \" \" ;\n " ) ;
350
- test ( "let x = '\" def'" , "let x = \" \\ \" def\" ;\n " ) ;
351
- test ( "let x = '\" \" \" def'" , "let x = \" \\ \" \\ \" \\ \" def\" ;\n " ) ;
352
- test ( "let x = 'abc\" def'" , "let x = \" abc\\ \" def\" ;\n " ) ;
353
- test ( "let x = 'abc\" \" \" def\" \" \" ghi'" , "let x = \" abc\\ \" \\ \" \\ \" def\\ \" \\ \" \\ \" ghi\" ;\n " ) ;
354
- // Does not double-escape already-escaped quotes
355
- test ( "let x = '\\ \" '" , "let x = \" \\ \" \" ;\n " ) ;
356
- test ( "let x = 'abc\\ \" \\ \" '" , "let x = \" abc\\ \" \\ \" \" ;\n " ) ;
357
- test ( "let x = '\\ \" \\ \" def'" , "let x = \" \\ \" \\ \" def\" ;\n " ) ;
358
- test ( "let x = 'abc\\ \" \\ \" def'" , "let x = \" abc\\ \" \\ \" def\" ;\n " ) ;
359
- test ( "let x = '\\ r\\ n\" '" , "let x = \" \\ r\\ n\\ \" \" ;\n " ) ;
360
- test ( "let x = '\\ \\ \" '" , "let x = \" \\ \\ \\ \" \" ;\n " ) ;
361
- test ( "let x = '\\ \\ \\ \" '" , "let x = \" \\ \\ \\ \" \" ;\n " ) ;
362
- // Does not escape other characters
337
+ test ( "let x = '\\ b'" , "let x = \" \\ b\" ;\n " ) ;
338
+ test ( "let x = '\\ f'" , "let x = \" \\ f\" ;\n " ) ;
363
339
test ( "let x = '\t '" , "let x = \" \t \" ;\n " ) ;
364
- // Prints other escapes as in original
365
- test ( "let x = '\\ t'" , "let x = \" \\ t\" ;\n " ) ;
366
- test ( "let x = '\\ x41'" , "let x = \" \\ x41\" ;\n " ) ;
367
- test ( "let x = '\\ u{41}'" , "let x = \" \\ u{41}\" ;\n " ) ;
368
- test ( "let x = '\\ uD800'" , "let x = \" \\ uD800\" ;\n " ) ;
369
- test ( "let x = '\\ uD801\\ uDC02'" , "let x = \" \\ uD801\\ uDC02\" ;\n " ) ;
370
-
371
- // `minify` option
372
-
373
- // Escapes characters and chooses best quote character
374
- test_minify ( "let x = ''" , "let x=``;" ) ;
375
- test_minify ( "let x = '\\ b'" , "let x=`\\ b`;" ) ;
376
- test_minify ( "let x = '\\ f'" , "let x=`\\ f`;" ) ;
377
- test_minify ( "let x = '\t '" , "let x=`\t `;" ) ;
378
- test_minify ( "let x = '\\ v'" , "let x=`\\ v`;" ) ;
379
- test_minify ( "let x = '\\ n'" , "let x=`\n `;" ) ;
380
- test_minify ( "let x = '\\ r'" , "let x=`\\ r`;" ) ;
381
- test_minify ( "let x = '\\ r\\ n'" , "let x=`\\ r\n `;" ) ;
382
- test_minify ( "let x = '\\ ''" , "let x=`'`;" ) ;
383
- test_minify ( "let x = '\" '" , "let x=`\" `;" ) ;
384
- test_minify ( "let x = '`'" , "let x=\" `\" ;" ) ;
385
- test_minify ( "let x = '\\ '\" '" , "let x=`'\" `;" ) ;
386
- test_minify ( "let x = '\\ '`'" , "let x=\" '`\" ;" ) ;
387
- test_minify ( "let x = '\" `'" , "let x='\" `';" ) ;
388
- test_minify ( "let x = '\\ \\ '" , "let x=`\\ \\ `;" ) ;
389
- test_minify ( "let x = '\x00 '" , "let x=`\\ 0`;" ) ;
390
- test_minify ( "let x = '\x00 !'" , "let x=`\\ 0!`;" ) ;
391
- test_minify ( "let x = '\x00 1'" , "let x=`\\ x001`;" ) ;
392
- test_minify ( "let x = '\\ 0'" , "let x=`\\ 0`;" ) ;
393
- test_minify ( "let x = '\\ 0!'" , "let x=`\\ 0!`;" ) ;
394
- test_minify ( "let x = '\x07 '" , "let x=`\\ x07`;" ) ;
395
- test_minify ( "let x = '\x07 !'" , "let x=`\\ x07!`;" ) ;
396
- test_minify ( "let x = '\x07 1'" , "let x=`\\ x071`;" ) ;
397
- test_minify ( "let x = '\\ 7'" , "let x=`\\ x07`;" ) ;
398
- test_minify ( "let x = '\\ 7!'" , "let x=`\\ x07!`;" ) ;
399
- test_minify ( "let x = '\\ 01'" , "let x=`\x01 `;" ) ;
400
- test_minify ( "let x = '\x10 '" , "let x=`\x10 `;" ) ;
401
- test_minify ( "let x = '\\ x10'" , "let x=`\x10 `;" ) ;
402
- test_minify ( "let x = '\x1B '" , "let x=`\\ x1B`;" ) ;
403
- test_minify ( "let x = '\\ x1B'" , "let x=`\\ x1B`;" ) ;
404
- test_minify ( "let x = '\\ x41'" , "let x=`A`;" ) ;
405
- test_minify ( "let x = '\u{ABCD} '" , "let x=`\u{ABCD} `;" ) ;
406
- test_minify ( "let x = '\\ uABCD'" , "let x=`\u{ABCD} `;" ) ;
407
- test_minify ( "let x = '\\ U000123AB'" , "let x=`U000123AB`;" ) ;
408
- test_minify ( "let x = '\\ u{123AB}'" , "let x=`\u{123ab} `;" ) ;
409
- test_minify ( "let x = '\\ u{41}'" , "let x=`A`;" ) ;
410
- test_minify ( "let x = '\\ uD808\\ uDFAB'" , "let x=`\u{123ab} `;" ) ;
411
- test_minify ( "let x = '\\ uD808'" , "let x=`\\ ud808`;" ) ; // lone surrogate
412
- test_minify ( "let x = '\\ uD808X'" , "let x=`\\ ud808X`;" ) ;
413
- test_minify ( "let x = '\\ uDFAB'" , "let x=`\\ udfab`;" ) ;
414
- test_minify ( "let x = '\\ uDFABX'" , "let x=`\\ udfabX`;" ) ;
415
- test_minify ( "let x = '\\ x80'" , "let x=`\u{80} `;" ) ;
416
- test_minify ( "let x = '\\ xFF'" , "let x=`ÿ`;" ) ;
417
- test_minify ( "let x = '\\ xF0\\ x9F\\ x8D\\ x95'" , "let x=`ð\u{9f} \u{8d} \u{95} `;" ) ;
418
- test_minify ( "let x = '\\ uD801\\ uDC02\\ uDC03\\ uD804'" , "let x=`𐐂\\ udc03\\ ud804`;" ) ; // surrogates
340
+ test ( "let x = '\\ v'" , "let x = \" \\ v\" ;\n " ) ;
341
+ test ( "let x = '\\ n'" , "let x = \" \\ n\" ;\n " ) ;
342
+ test ( "let x = '\\ r'" , "let x = \" \\ r\" ;\n " ) ;
343
+ test ( "let x = '\\ r\\ n'" , "let x = \" \\ r\\ n\" ;\n " ) ;
344
+ test ( "let x = '\\ ''" , "let x = \" '\" ;\n " ) ;
345
+ test ( "let x = '\" '" , "let x = \" \\ \" \" ;\n " ) ;
346
+ test ( "let x = '`'" , "let x = \" `\" ;\n " ) ;
347
+ test ( "let x = '\\ '\" '" , "let x = \" '\\ \" \" ;\n " ) ;
348
+ test ( "let x = '\\ '`'" , "let x = \" '`\" ;\n " ) ;
349
+ test ( "let x = '\" `'" , "let x = \" \\ \" `\" ;\n " ) ;
350
+ test ( "let x = '\\ \\ '" , "let x = \" \\ \\ \" ;\n " ) ;
351
+ test ( "let x = '\x00 '" , "let x = \" \\ 0\" ;\n " ) ;
352
+ test ( "let x = '\x00 !'" , "let x = \" \\ 0!\" ;\n " ) ;
353
+ test ( "let x = '\x00 1'" , "let x = \" \\ x001\" ;\n " ) ;
354
+ test ( "let x = '\\ 0'" , "let x = \" \\ 0\" ;\n " ) ;
355
+ test ( "let x = '\\ 0!'" , "let x = \" \\ 0!\" ;\n " ) ;
356
+ test ( "let x = '\x07 '" , "let x = \" \\ x07\" ;\n " ) ;
357
+ test ( "let x = '\x07 !'" , "let x = \" \\ x07!\" ;\n " ) ;
358
+ test ( "let x = '\x07 1'" , "let x = \" \\ x071\" ;\n " ) ;
359
+ test ( "let x = '\\ 7'" , "let x = \" \\ x07\" ;\n " ) ;
360
+ test ( "let x = '\\ 7!'" , "let x = \" \\ x07!\" ;\n " ) ;
361
+ test ( "let x = '\\ 01'" , "let x = \" \x01 \" ;\n " ) ;
362
+ test ( "let x = '\x10 '" , "let x = \" \x10 \" ;\n " ) ;
363
+ test ( "let x = '\\ x10'" , "let x = \" \x10 \" ;\n " ) ;
364
+ test ( "let x = '\x1B '" , "let x = \" \\ x1B\" ;\n " ) ;
365
+ test ( "let x = '\\ x1B'" , "let x = \" \\ x1B\" ;\n " ) ;
366
+ test ( "let x = '\\ x41'" , "let x = \" A\" ;\n " ) ;
367
+ test ( "let x = '\u{ABCD} '" , "let x = \" \u{ABCD} \" ;\n " ) ;
368
+ test ( "let x = '\\ uABCD'" , "let x = \" \u{ABCD} \" ;\n " ) ;
369
+ test ( "let x = '\\ U000123AB'" , "let x = \" U000123AB\" ;\n " ) ;
370
+ test ( "let x = '\\ u{123AB}'" , "let x = \" \u{123ab} \" ;\n " ) ;
371
+ test ( "let x = '\\ u{41}'" , "let x = \" A\" ;\n " ) ;
372
+ test ( "let x = '\\ uD808\\ uDFAB'" , "let x = \" \u{123ab} \" ;\n " ) ;
373
+ test ( "let x = '\\ uD808'" , "let x = \" \\ ud808\" ;\n " ) ; // lone surrogate
374
+ test ( "let x = '\\ uD808X'" , "let x = \" \\ ud808X\" ;\n " ) ;
375
+ test ( "let x = '\\ uDFAB'" , "let x = \" \\ udfab\" ;\n " ) ;
376
+ test ( "let x = '\\ uDFABX'" , "let x = \" \\ udfabX\" ;\n " ) ;
377
+
378
+ test ( "let x = '\\ x80'" , "let x = \" \u{80} \" ;\n " ) ;
379
+ test ( "let x = '\\ xFF'" , "let x = \" ÿ\" ;\n " ) ;
380
+ test ( "let x = '\\ xF0\\ x9F\\ x8D\\ x95'" , "let x = \" ð\u{9f} \u{8d} \u{95} \" ;\n " ) ;
381
+ test ( "let x = '\\ uD801\\ uDC02\\ uDC03\\ uD804'" , "let x = \" 𐐂\\ udc03\\ ud804\" ;\n " ) ; // surrogates
419
382
}
420
383
421
384
#[ test]
0 commit comments