@@ -206,39 +206,69 @@ describe("bin/uglifyjs", function() {
206
206
} , 1000 ) ;
207
207
} ) ;
208
208
it ( "Should work with --keep-fargs (mangle only)" , function ( done ) {
209
- var command = uglifyjscmd + ' test/input/issue-1431/sample.js --keep-fargs -m' ;
209
+ var command = [
210
+ uglifyjscmd ,
211
+ "test/input/issue-1431/sample.js" ,
212
+ "--keep-fargs" ,
213
+ "--mangle" ,
214
+ "--no-module" ,
215
+ ] . join ( " " ) ;
210
216
exec ( command , function ( err , stdout ) {
211
217
if ( err ) throw err ;
212
218
assert . strictEqual ( stdout , "function f(x){return function(){function n(a){return a*a}return x(n)}}function g(op){return op(1)+op(2)}console.log(f(g)()==5);\n" ) ;
213
219
done ( ) ;
214
220
} ) ;
215
221
} ) ;
216
222
it ( "Should work with --keep-fargs (mangle & compress)" , function ( done ) {
217
- var command = uglifyjscmd + ' test/input/issue-1431/sample.js --keep-fargs -m -c' ;
223
+ var command = [
224
+ uglifyjscmd ,
225
+ "test/input/issue-1431/sample.js" ,
226
+ "--keep-fargs" ,
227
+ "--mangle" ,
228
+ "--no-module" ,
229
+ "--compress" ,
230
+ ] . join ( " " ) ;
218
231
exec ( command , function ( err , stdout ) {
219
232
if ( err ) throw err ;
220
233
assert . strictEqual ( stdout , "function f(x){return function(){return x(function(a){return a*a})}}function g(op){return op(1)+op(2)}console.log(5==f(g)());\n" ) ;
221
234
done ( ) ;
222
235
} ) ;
223
236
} ) ;
224
237
it ( "Should work with keep_fargs under mangler options" , function ( done ) {
225
- var command = uglifyjscmd + ' test/input/issue-1431/sample.js -m keep_fargs=true' ;
238
+ var command = [
239
+ uglifyjscmd ,
240
+ "test/input/issue-1431/sample.js" ,
241
+ "--mangle" , "keep_fargs=true" ,
242
+ "--no-module" ,
243
+ ] . join ( " " ) ;
226
244
exec ( command , function ( err , stdout ) {
227
245
if ( err ) throw err ;
228
246
assert . strictEqual ( stdout , "function f(x){return function(){function n(a){return a*a}return x(n)}}function g(op){return op(1)+op(2)}console.log(f(g)()==5);\n" ) ;
229
247
done ( ) ;
230
248
} ) ;
231
249
} ) ;
232
250
it ( "Should work with --keep-fnames (mangle only)" , function ( done ) {
233
- var command = uglifyjscmd + ' test/input/issue-1431/sample.js --keep-fnames -m' ;
251
+ var command = [
252
+ uglifyjscmd ,
253
+ "test/input/issue-1431/sample.js" ,
254
+ "--keep-fnames" ,
255
+ "--mangle" ,
256
+ ] . join ( " " ) ;
234
257
exec ( command , function ( err , stdout ) {
235
258
if ( err ) throw err ;
236
259
assert . strictEqual ( stdout , "function f(r){return function(){function n(n){return n*n}return r(n)}}function g(n){return n(1)+n(2)}console.log(f(g)()==5);\n" ) ;
237
260
done ( ) ;
238
261
} ) ;
239
262
} ) ;
240
263
it ( "Should work with --keep-fnames (mangle & compress)" , function ( done ) {
241
- var command = uglifyjscmd + ' test/input/issue-1431/sample.js --keep-fnames -m -c' ;
264
+ var command = [
265
+ uglifyjscmd ,
266
+ "test/input/issue-1431/sample.js" ,
267
+ "--keep-fnames" ,
268
+ "--mangle" ,
269
+ "--no-module" ,
270
+ "--compress" ,
271
+ ] . join ( " " ) ;
242
272
exec ( command , function ( err , stdout ) {
243
273
if ( err ) throw err ;
244
274
assert . strictEqual ( stdout , "function f(n){return function(){return n(function n(r){return r*r})}}function g(n){return n(1)+n(2)}console.log(5==f(g)());\n" ) ;
@@ -557,7 +587,11 @@ describe("bin/uglifyjs", function() {
557
587
} ) ;
558
588
} ) ;
559
589
it ( "Should throw syntax error (delete x)" , function ( done ) {
560
- var command = uglifyjscmd + " test/input/invalid/delete.js" ;
590
+ var command = [
591
+ uglifyjscmd ,
592
+ "test/input/invalid/delete.js" ,
593
+ "--no-module" ,
594
+ ] . join ( " " ) ;
561
595
exec ( command , function ( err , stdout , stderr ) {
562
596
assert . ok ( err ) ;
563
597
assert . strictEqual ( stdout , "" ) ;
@@ -571,7 +605,11 @@ describe("bin/uglifyjs", function() {
571
605
} ) ;
572
606
} ) ;
573
607
it ( "Should throw syntax error (function g(arguments))" , function ( done ) {
574
- var command = uglifyjscmd + " test/input/invalid/function_1.js" ;
608
+ var command = [
609
+ uglifyjscmd ,
610
+ "test/input/invalid/function_1.js" ,
611
+ "--no-module" ,
612
+ ] . join ( " " ) ;
575
613
exec ( command , function ( err , stdout , stderr ) {
576
614
assert . ok ( err ) ;
577
615
assert . strictEqual ( stdout , "" ) ;
@@ -585,7 +623,11 @@ describe("bin/uglifyjs", function() {
585
623
} ) ;
586
624
} ) ;
587
625
it ( "Should throw syntax error (function eval())" , function ( done ) {
588
- var command = uglifyjscmd + " test/input/invalid/function_2.js" ;
626
+ var command = [
627
+ uglifyjscmd ,
628
+ "test/input/invalid/function_2.js" ,
629
+ "--no-module" ,
630
+ ] . join ( " " ) ;
589
631
exec ( command , function ( err , stdout , stderr ) {
590
632
assert . ok ( err ) ;
591
633
assert . strictEqual ( stdout , "" ) ;
@@ -599,7 +641,11 @@ describe("bin/uglifyjs", function() {
599
641
} ) ;
600
642
} ) ;
601
643
it ( "Should throw syntax error (iife arguments())" , function ( done ) {
602
- var command = uglifyjscmd + " test/input/invalid/function_3.js" ;
644
+ var command = [
645
+ uglifyjscmd ,
646
+ "test/input/invalid/function_3.js" ,
647
+ "--no-module" ,
648
+ ] . join ( " " ) ;
603
649
exec ( command , function ( err , stdout , stderr ) {
604
650
assert . ok ( err ) ;
605
651
assert . strictEqual ( stdout , "" ) ;
@@ -613,7 +659,11 @@ describe("bin/uglifyjs", function() {
613
659
} ) ;
614
660
} ) ;
615
661
it ( "Should throw syntax error (catch (eval))" , function ( done ) {
616
- var command = uglifyjscmd + " test/input/invalid/try.js" ;
662
+ var command = [
663
+ uglifyjscmd ,
664
+ "test/input/invalid/try.js" ,
665
+ "--no-module" ,
666
+ ] . join ( " " ) ;
617
667
exec ( command , function ( err , stdout , stderr ) {
618
668
assert . ok ( err ) ;
619
669
assert . strictEqual ( stdout , "" ) ;
@@ -627,7 +677,11 @@ describe("bin/uglifyjs", function() {
627
677
} ) ;
628
678
} ) ;
629
679
it ( "Should throw syntax error (var eval)" , function ( done ) {
630
- var command = uglifyjscmd + " test/input/invalid/var.js" ;
680
+ var command = [
681
+ uglifyjscmd ,
682
+ "test/input/invalid/var.js" ,
683
+ "--no-module" ,
684
+ ] . join ( " " ) ;
631
685
exec ( command , function ( err , stdout , stderr ) {
632
686
assert . ok ( err ) ;
633
687
assert . strictEqual ( stdout , "" ) ;
@@ -641,7 +695,11 @@ describe("bin/uglifyjs", function() {
641
695
} ) ;
642
696
} ) ;
643
697
it ( "Should throw syntax error (var { eval })" , function ( done ) {
644
- var command = uglifyjscmd + " test/input/invalid/destructured_var.js" ;
698
+ var command = [
699
+ uglifyjscmd ,
700
+ "test/input/invalid/destructured_var.js" ,
701
+ "--no-module" ,
702
+ ] . join ( " " ) ;
645
703
exec ( command , function ( err , stdout , stderr ) {
646
704
assert . ok ( err ) ;
647
705
assert . strictEqual ( stdout , "" ) ;
@@ -807,7 +865,8 @@ describe("bin/uglifyjs", function() {
807
865
var command = [
808
866
uglifyjscmd ,
809
867
"test/input/issue-2310/input.js" ,
810
- "-c" ,
868
+ "--compress" ,
869
+ "--no-module" ,
811
870
"--source-map" , "url=inline" ,
812
871
] . join ( " " ) ;
813
872
exec ( command , function ( err , stdout , stderr ) {
@@ -840,15 +899,25 @@ describe("bin/uglifyjs", function() {
840
899
} ) ;
841
900
} ) ;
842
901
it ( "Should work with --mangle reserved=[]" , function ( done ) {
843
- var command = uglifyjscmd + " test/input/issue-505/input.js -m reserved=[callback]" ;
902
+ var command = [
903
+ uglifyjscmd ,
904
+ "test/input/issue-505/input.js" ,
905
+ "--mangle" , "reserved=[callback]" ,
906
+ "--no-module" ,
907
+ ] . join ( " " ) ;
844
908
exec ( command , function ( err , stdout ) {
845
909
if ( err ) throw err ;
846
910
assert . strictEqual ( stdout , 'function test(callback){"aaaaaaaaaaaaaaaa";callback(err,data);callback(err,data)}\n' ) ;
847
911
done ( ) ;
848
912
} ) ;
849
913
} ) ;
850
914
it ( "Should work with --mangle reserved=false" , function ( done ) {
851
- var command = uglifyjscmd + " test/input/issue-505/input.js -m reserved=false" ;
915
+ var command = [
916
+ uglifyjscmd ,
917
+ "test/input/issue-505/input.js" ,
918
+ "--mangle" , "reserved=false" ,
919
+ "--no-module" ,
920
+ ] . join ( " " ) ;
852
921
exec ( command , function ( err , stdout ) {
853
922
if ( err ) throw err ;
854
923
assert . strictEqual ( stdout , 'function test(a){"aaaaaaaaaaaaaaaa";a(err,data);a(err,data)}\n' ) ;
@@ -865,7 +934,12 @@ describe("bin/uglifyjs", function() {
865
934
} ) ;
866
935
} ) ;
867
936
it ( "Should work with mangle.properties.regex from --config-file" , function ( done ) {
868
- var command = uglifyjscmd + " test/input/issue-3315/input.js --config-file test/input/issue-3315/config.json" ;
937
+ var command = [
938
+ uglifyjscmd ,
939
+ "test/input/issue-3315/input.js" ,
940
+ "--config-file" , "test/input/issue-3315/config.json" ,
941
+ "--no-module" ,
942
+ ] . join ( " " ) ;
869
943
exec ( command , function ( err , stdout ) {
870
944
if ( err ) throw err ;
871
945
assert . strictEqual ( stdout , 'function f(){"aaaaaaaaaa";var a={prop:1,t:2};return a.prop+a.t}\n' ) ;
@@ -882,31 +956,54 @@ describe("bin/uglifyjs", function() {
882
956
} ) ;
883
957
} ) ;
884
958
it ( "Should work with explicit --rename" , function ( done ) {
885
- var command = uglifyjscmd + " test/input/rename/input.js --rename" ;
959
+ var command = [
960
+ uglifyjscmd ,
961
+ "test/input/rename/input.js" ,
962
+ "--no-module" ,
963
+ "--rename" ,
964
+ ] . join ( " " ) ;
886
965
exec ( command , function ( err , stdout , stderr ) {
887
966
if ( err ) throw err ;
888
967
assert . strictEqual ( stdout , "function f(a){return b(a);function b(c){return c+c}}\n" ) ;
889
968
done ( ) ;
890
969
} ) ;
891
970
} ) ;
892
971
it ( "Should work with explicit --no-rename" , function ( done ) {
893
- var command = uglifyjscmd + " test/input/rename/input.js -mc passes=2 --no-rename" ;
972
+ var command = [
973
+ uglifyjscmd ,
974
+ "test/input/rename/input.js" ,
975
+ "--compress" , "passes=2" ,
976
+ "--mangle" ,
977
+ "--no-module" ,
978
+ "--no-rename" ,
979
+ ] . join ( " " ) ;
894
980
exec ( command , function ( err , stdout , stderr ) {
895
981
if ( err ) throw err ;
896
982
assert . strictEqual ( stdout , "function f(n){return function(n){return n+n}(n)}\n" ) ;
897
983
done ( ) ;
898
984
} ) ;
899
985
} ) ;
900
986
it ( "Should work with implicit --rename" , function ( done ) {
901
- var command = uglifyjscmd + " test/input/rename/input.js -mc passes=2" ;
987
+ var command = [
988
+ uglifyjscmd ,
989
+ "test/input/rename/input.js" ,
990
+ "--compress" , "passes=2" ,
991
+ "--mangle" ,
992
+ "--no-module" ,
993
+ ] . join ( " " ) ;
902
994
exec ( command , function ( err , stdout , stderr ) {
903
995
if ( err ) throw err ;
904
996
assert . strictEqual ( stdout , "function f(n){return n+n}\n" ) ;
905
997
done ( ) ;
906
998
} ) ;
907
999
} ) ;
908
1000
it ( "Should work with implicit --no-rename" , function ( done ) {
909
- var command = uglifyjscmd + " test/input/rename/input.js -c passes=2" ;
1001
+ var command = [
1002
+ uglifyjscmd ,
1003
+ "test/input/rename/input.js" ,
1004
+ "--compress" , "passes=2" ,
1005
+ "--no-module" ,
1006
+ ] . join ( " " ) ;
910
1007
exec ( command , function ( err , stdout , stderr ) {
911
1008
if ( err ) throw err ;
912
1009
assert . strictEqual ( stdout , "function f(x){return function(x){return x+x}(x)}\n" ) ;
@@ -971,12 +1068,7 @@ describe("bin/uglifyjs", function() {
971
1068
] ) . join ( "\n" ) ;
972
1069
exec ( uglifyjscmd + " -mc" , function ( err , stdout ) {
973
1070
if ( err ) throw err ;
974
- assert . strictEqual ( stdout , [
975
- "console.log(function(){" ,
976
- "var p={p:25},n={p:121},o={p:1024};" ,
977
- "return p.p+n.p+o.p" ,
978
- "}());\n" ,
979
- ] . join ( "" ) ) ;
1071
+ assert . strictEqual ( stdout , "console.log({p:25}.p+{p:121}.p+{p:1024}.p);\n" ) ;
980
1072
assert . strictEqual ( run_code ( stdout ) , run_code ( code ) ) ;
981
1073
done ( ) ;
982
1074
} ) . stdin . end ( code ) ;
0 commit comments