@@ -3191,6 +3191,71 @@ exports.test_data = {
3191
3191
input : 'switch(x){case -1:break;case !y:{break;}}' ,
3192
3192
output : 'switch (x) {\n{{c}}case -1:\n{{c}} break;\n{{c}}case !y: {\n{{c}} break;\n{{c}}\}\n}'
3193
3193
} ,
3194
+ {
3195
+ comment : "Issue #1622 - basic class with function definitions" ,
3196
+ input : [
3197
+ 'class blah {' ,
3198
+ ' constructor() {' ,
3199
+ ' this.doStuff()' ,
3200
+ ' }' ,
3201
+ ' doStuff() {' ,
3202
+ ' console.log("stuff")' ,
3203
+ ' }' ,
3204
+ '}'
3205
+ ] ,
3206
+ output : [
3207
+ 'class blah {' ,
3208
+ ' constructor{{nf}}() {' ,
3209
+ ' this.doStuff()' ,
3210
+ ' }' ,
3211
+ ' doStuff{{nf}}() {' ,
3212
+ ' console.log("stuff")' ,
3213
+ ' }' ,
3214
+ '}'
3215
+ ]
3216
+ } ,
3217
+ {
3218
+ comment : "Issue #1622 - class with extends and function definitions" ,
3219
+ input : [
3220
+ 'class blah extends something {' ,
3221
+ ' constructor() {' ,
3222
+ ' this.zz = 2 + 2;' ,
3223
+ ' }' ,
3224
+ ' someOtherFunction() {' ,
3225
+ 'this.y = 1;' ,
3226
+ ' }' ,
3227
+ '}'
3228
+ ] ,
3229
+ output : [
3230
+ 'class blah extends something {' ,
3231
+ ' constructor{{nf}}() {' ,
3232
+ ' this.zz = 2 + 2;' ,
3233
+ ' }' ,
3234
+ ' someOtherFunction{{nf}}() {' ,
3235
+ ' this.y = 1;' ,
3236
+ ' }' ,
3237
+ '}'
3238
+ ]
3239
+ } ,
3240
+ {
3241
+ comment : "Issue #1622 - class/extends as a property" ,
3242
+ input : [
3243
+ 'var a.class = {' ,
3244
+ ' ...abc(),' ,
3245
+ '}' ,
3246
+ 'b.extends({' ,
3247
+ ' bb.s(),' ,
3248
+ '})'
3249
+ ] ,
3250
+ output : [
3251
+ 'var a.class = {' ,
3252
+ ' ...abc(),' ,
3253
+ '}' ,
3254
+ 'b.extends({' ,
3255
+ ' bb.s(),' ,
3256
+ '})'
3257
+ ]
3258
+ } ,
3194
3259
{
3195
3260
comment : 'typical greasemonkey start' ,
3196
3261
fragment : true ,
@@ -3302,6 +3367,24 @@ exports.test_data = {
3302
3367
' });' ,
3303
3368
'var test = 1;'
3304
3369
]
3370
+ } , {
3371
+ comment : "Issue #772" ,
3372
+ input : [
3373
+ 'this.initAttributes([' ,
3374
+ '"name",' ,
3375
+ '["parent", null, "parentName"],' ,
3376
+ '"length",' ,
3377
+ '["id", this.name],' ,
3378
+ ']);'
3379
+ ] ,
3380
+ output : [
3381
+ 'this.initAttributes([' ,
3382
+ ' "name",' ,
3383
+ ' ["parent", null, "parentName"],' ,
3384
+ ' "length",' ,
3385
+ ' ["id", this.name],' ,
3386
+ ']);'
3387
+ ]
3305
3388
} , {
3306
3389
comment : "Issue #1663" ,
3307
3390
unchanged : [
@@ -3312,6 +3395,81 @@ exports.test_data = {
3312
3395
'}'
3313
3396
]
3314
3397
} ,
3398
+ {
3399
+ comment : "#1095 - Return without semicolon followed by prefix on a new line" ,
3400
+ input : [
3401
+ 'function x(){' ,
3402
+ 'return' ,
3403
+ '++a' ,
3404
+ '}' ,
3405
+ '' ,
3406
+ 'while(true) {' ,
3407
+ 'return' ,
3408
+ '--b' ,
3409
+ '}'
3410
+ ] ,
3411
+ output : [
3412
+ 'function x() {' ,
3413
+ ' return' ,
3414
+ ' ++a' ,
3415
+ '}' ,
3416
+ '' ,
3417
+ 'while (true) {' ,
3418
+ ' return' ,
3419
+ ' --b' ,
3420
+ '}'
3421
+ ]
3422
+ } ,
3423
+ {
3424
+ comment : "#1095" ,
3425
+ input : [
3426
+ 'function test(){' ,
3427
+ 'if(x) return' ,
3428
+ '++x' ,
3429
+ 'var y= 1;' ,
3430
+ '}' ,
3431
+ 'function t1(){' ,
3432
+ 'if(cc) return;' ,
3433
+ 'else return' ,
3434
+ '--cc' ,
3435
+ '}'
3436
+ ] ,
3437
+ output : [
3438
+ 'function test() {' ,
3439
+ ' if (x) return' ,
3440
+ ' ++x' ,
3441
+ ' var y = 1;' ,
3442
+ '}' ,
3443
+ '' ,
3444
+ 'function t1() {' ,
3445
+ ' if (cc) return;' ,
3446
+ ' else return' ,
3447
+ ' --cc' ,
3448
+ '}'
3449
+ ]
3450
+ } ,
3451
+ {
3452
+ comment : "#1095 - Return with semicolon followed by a prefix on a new line" ,
3453
+ input : [
3454
+ 'function x(){' ,
3455
+ 'return; ++a' ,
3456
+ '}' ,
3457
+ '' ,
3458
+ 'while(true){return; --b' ,
3459
+ '}'
3460
+ ] ,
3461
+ output : [
3462
+ 'function x() {' ,
3463
+ ' return;' ,
3464
+ ' ++a' ,
3465
+ '}' ,
3466
+ '' ,
3467
+ 'while (true) {' ,
3468
+ ' return;' ,
3469
+ ' --b' ,
3470
+ '}'
3471
+ ]
3472
+ } ,
3315
3473
{
3316
3474
comment : "#1838 - handle class and interface word as an object property" ,
3317
3475
unchanged : [
@@ -4627,6 +4785,99 @@ exports.test_data = {
4627
4785
' }' ,
4628
4786
')'
4629
4787
]
4788
+ } ,
4789
+ {
4790
+ comment : "Issue ##1846 - in keyword in class method causes indentation problem" ,
4791
+ input : [
4792
+ 'class {' ,
4793
+ ' get a() {' ,
4794
+ '\n' ,
4795
+ ' }' ,
4796
+ '\n' ,
4797
+ ' in() {' ,
4798
+ '\n' ,
4799
+ ' }' ,
4800
+ '\n' ,
4801
+ ' b() {' ,
4802
+ '\n' ,
4803
+ ' }' ,
4804
+ '}'
4805
+ ] ,
4806
+ output : [
4807
+ 'class {' ,
4808
+ ' get a() {' ,
4809
+ '\n' ,
4810
+ ' }' ,
4811
+ '\n' ,
4812
+ ' in() {' ,
4813
+ '\n' ,
4814
+ ' }' ,
4815
+ '\n' ,
4816
+ ' b() {' ,
4817
+ '\n' ,
4818
+ ' }' ,
4819
+ '}'
4820
+ ]
4821
+ } ,
4822
+ {
4823
+ comment : "Related to Issue ##1846 - Do not indent 'in' keyword if not a class method" ,
4824
+ input : [
4825
+ 'function test() {' ,
4826
+ 'for x in nums {}' ,
4827
+ '"make" in car' ,
4828
+ '3 in number;' ,
4829
+ '}'
4830
+ ] ,
4831
+ output : [
4832
+ 'function test() {' ,
4833
+ ' for x in nums {}' ,
4834
+ ' "make" in car' ,
4835
+ ' 3 in number;' ,
4836
+ '}'
4837
+ ]
4838
+ } ,
4839
+ {
4840
+ comment : "Related to Issue ##1846 - of keyword in class method causes indentation problem" ,
4841
+ input : [
4842
+ 'class {' ,
4843
+ ' get a() {' ,
4844
+ '\n' ,
4845
+ ' }' ,
4846
+ '\n' ,
4847
+ ' of() {' ,
4848
+ '\n' ,
4849
+ ' }' ,
4850
+ '\n' ,
4851
+ ' b() {' ,
4852
+ '\n' ,
4853
+ ' }' ,
4854
+ '}'
4855
+ ] ,
4856
+ output : [
4857
+ 'class {' ,
4858
+ ' get a() {' ,
4859
+ '\n' ,
4860
+ ' }' ,
4861
+ '\n' ,
4862
+ ' of() {' ,
4863
+ '\n' ,
4864
+ ' }' ,
4865
+ '\n' ,
4866
+ ' b() {' ,
4867
+ '\n' ,
4868
+ ' }' ,
4869
+ '}'
4870
+ ]
4871
+ } ,
4872
+ {
4873
+ comment : 'Issue #1950: Do not remove whitespace after number - test scenario: number before a dot' ,
4874
+ input : '1000000000000001000 .toFixed(0)!==1000000000000001024' ,
4875
+ output : '1000000000000001000 .toFixed(0) !== 1000000000000001024'
4876
+ } ,
4877
+ {
4878
+ comment : 'Issue #1950: Do not remove whitespace after number - test scenario: variable ends with a number before a dot' ,
4879
+ input : 'a.b21 . performAction()' ,
4880
+ output : 'a.b21.performAction()'
4630
4881
}
4631
4882
]
4632
4883
} , {
0 commit comments