@@ -185,6 +185,12 @@ test "destructuring assignment with splats", ->
185
185
arrayEq [b,c,d], y
186
186
eq e, z
187
187
188
+ # Should not trigger implicit call, e.g. rest ... => rest(...)
189
+ [x ,y ... ,z ] = [a,b,c,d,e]
190
+ eq a, x
191
+ arrayEq [b,c,d], y
192
+ eq e, z
193
+
188
194
test " deep destructuring assignment with splats" , ->
189
195
a = {}; b = {}; c = {}; d = {}; e = {}; f = {}; g = {}; h = {}; i = {}
190
196
[u , [v , w ... , x ], y ... , z ] = [a, [b, c, d, e], f, g, h, i]
@@ -229,6 +235,11 @@ test "destructuring assignment with objects and splats", ->
229
235
eq a, y
230
236
arrayEq [b,c,d], z
231
237
238
+ # Should not trigger implicit call, e.g. rest ... => rest(...)
239
+ {a : b : [y , z ... ]} = obj
240
+ eq a, y
241
+ arrayEq [b,c,d], z
242
+
232
243
test " destructuring assignment against an expression" , ->
233
244
a = {}; b = {}
234
245
[y , z ] = if true then [a, b] else [b, a]
@@ -263,6 +274,15 @@ test "destructuring assignment with splats and default values", ->
263
274
eq b, 1
264
275
deepEqual d, {}
265
276
277
+ # Should not trigger implicit call, e.g. rest ... => rest(...)
278
+ {
279
+ a : {b } = c
280
+ d ...
281
+ } = obj
282
+
283
+ eq b, 1
284
+ deepEqual d, {}
285
+
266
286
test " destructuring assignment with splat with default value" , ->
267
287
obj = {}
268
288
c = {val : 1 }
@@ -276,6 +296,18 @@ test "destructuring assignment with multiple splats in different objects", ->
276
296
deepEqual a, val : 1
277
297
deepEqual b, val : 2
278
298
299
+ # Should not trigger implicit call, e.g. rest ... => rest(...)
300
+ {
301
+ a : {
302
+ a ...
303
+ }
304
+ b : {
305
+ b ...
306
+ }
307
+ } = obj
308
+ deepEqual a, val : 1
309
+ deepEqual b, val : 2
310
+
279
311
test " destructuring assignment with dynamic keys and splats" , ->
280
312
i = 0
281
313
foo = -> ++ i
@@ -299,6 +331,15 @@ test "destructuring assignment with objects and splats: Babel tests", ->
299
331
n = { x, y, z... }
300
332
deepEqual n, { x : 1 , y : 2 , a : 3 , b : 4 }
301
333
334
+ # Should not trigger implicit call, e.g. rest ... => rest(...)
335
+ { x , y , z ... } = { x : 1 , y : 2 , a : 3 , b : 4 }
336
+ eq x, 1
337
+ eq y, 2
338
+ deepEqual z, { a : 3 , b : 4 }
339
+
340
+ n = { x, y, z ... }
341
+ deepEqual n, { x : 1 , y : 2 , a : 3 , b : 4 }
342
+
302
343
test " deep destructuring assignment with objects: ES2015" , ->
303
344
a1 = {}; b1 = {}; c1 = {}; d1 = {}
304
345
obj = {
@@ -320,6 +361,13 @@ test "deep destructuring assignment with objects: ES2015", ->
320
361
eq bb, b1
321
362
eq r2 .b2 , obj .b2
322
363
364
+ # Should not trigger implicit call, e.g. rest ... => rest(...)
365
+ {a : w , b : {c : {d : {b1 : bb , r1 ... }}}, r2 ... } = obj
366
+ eq r1 .e , c1
367
+ eq r2 .b , undefined
368
+ eq bb, b1
369
+ eq r2 .b2 , obj .b2
370
+
323
371
test " deep destructuring assignment with defaults: ES2015" , ->
324
372
obj =
325
373
b : { c : 1 , baz : ' qux' }
@@ -343,16 +391,55 @@ test "deep destructuring assignment with defaults: ES2015", ->
343
391
eq hello, ' world'
344
392
deepEqual h, some : ' prop'
345
393
394
+ # Should not trigger implicit call, e.g. rest ... => rest(...)
395
+ {
396
+ a ...
397
+ b : {
398
+ c,
399
+ d ...
400
+ }
401
+ e : {
402
+ f : hello
403
+ g : {
404
+ h ...
405
+ } = i
406
+ } = j
407
+ } = obj
408
+
409
+ deepEqual a, foo : ' bar'
410
+ eq c, 1
411
+ deepEqual d, baz : ' qux'
412
+ eq hello, ' world'
413
+ deepEqual h, some : ' prop'
414
+
346
415
test " object spread properties: ES2015" , ->
347
416
obj = {a : 1 , b : 2 , c : 3 , d : 4 , e : 5 }
348
417
obj2 = {obj... , c : 9 }
349
418
eq obj2 .c , 9
350
419
eq obj .a , obj2 .a
351
420
421
+ # Should not trigger implicit call, e.g. rest ... => rest(...)
422
+ obj2 = {
423
+ obj ...
424
+ c : 9
425
+ }
426
+ eq obj2 .c , 9
427
+ eq obj .a , obj2 .a
428
+
352
429
obj2 = {obj... , a : 8 , c : 9 , obj... }
353
430
eq obj2 .c , 3
354
431
eq obj .a , obj2 .a
355
432
433
+ # Should not trigger implicit call, e.g. rest ... => rest(...)
434
+ obj2 = {
435
+ obj ...
436
+ a : 8
437
+ c : 9
438
+ obj ...
439
+ }
440
+ eq obj2 .c , 3
441
+ eq obj .a , obj2 .a
442
+
356
443
obj3 = {obj... , b : 7 , g : {obj2... , c : 1 }}
357
444
eq obj3 .g .c , 1
358
445
eq obj3 .b , 7
@@ -370,10 +457,42 @@ test "object spread properties: ES2015", ->
370
457
eq obj4 .f .g , 5
371
458
deepEqual obj4 .f , obj .c .f
372
459
460
+ # Should not trigger implicit call, e.g. rest ... => rest(...)
461
+ (({
462
+ a
463
+ b
464
+ r ...
465
+ }) ->
466
+ eq 1 , a
467
+ deepEqual r, {c : 3 , d : 44 , e : 55 }
468
+ ) {
469
+ obj2 ...
470
+ d : 44
471
+ e : 55
472
+ }
473
+
474
+ # Should not trigger implicit call, e.g. rest ... => rest(...)
475
+ obj4 = {
476
+ a : 10
477
+ obj .c ...
478
+ }
479
+ eq obj4 .a , 10
480
+ eq obj4 .d , 3
481
+ eq obj4 .f .g , 5
482
+ deepEqual obj4 .f , obj .c .f
483
+
373
484
obj5 = {obj... , ((k ) -> {b : k})(99 )... }
374
485
eq obj5 .b , 99
375
486
deepEqual obj5 .c , obj .c
376
487
488
+ # Should not trigger implicit call, e.g. rest ... => rest(...)
489
+ obj5 = {
490
+ obj ...
491
+ ((k ) -> {b : k})(99 ) ...
492
+ }
493
+ eq obj5 .b , 99
494
+ deepEqual obj5 .c , obj .c
495
+
377
496
fn = -> {c : {d : 33 , e : 44 , f : {g : 55 }}}
378
497
obj6 = {obj... , fn ()... }
379
498
eq obj6 .c .d , 33
@@ -382,7 +501,16 @@ test "object spread properties: ES2015", ->
382
501
obj7 = {obj... , fn ()... , {c : {d : 55 , e : 66 , f : {77 }}}... }
383
502
eq obj7 .c .d , 55
384
503
deepEqual obj6 .c , {d : 33 , e : 44 , f : {g : 55 }}
385
-
504
+
505
+ # Should not trigger implicit call, e.g. rest ... => rest(...)
506
+ obj7 = {
507
+ obj ...
508
+ fn () ...
509
+ {c : {d : 55 , e : 66 , f : {77 }}} ...
510
+ }
511
+ eq obj7 .c .d , 55
512
+ deepEqual obj6 .c , {d : 33 , e : 44 , f : {g : 55 }}
513
+
386
514
obj =
387
515
a :
388
516
b :
0 commit comments