@@ -487,6 +487,47 @@ test "Verify OUTDENT tokens are located at the end of the previous token", ->
487
487
eq outdent[2 ].last_line , number[2 ].last_line
488
488
eq outdent[2 ].last_column , number[2 ].last_column
489
489
490
+ test " Verify OUTDENT and CALL_END tokens are located at the end of the previous token" , ->
491
+ source = '''
492
+ a = b {
493
+ c: ->
494
+ d e,
495
+ if f
496
+ g {},
497
+ if h
498
+ i {}
499
+ }
500
+ '''
501
+ tokens = CoffeeScript .tokens source
502
+ [... , closeCurly1, callEnd1, outdent1, outdent2, callEnd2, outdent3, outdent4,
503
+ callEnd3, outdent5, outdent6, closeCurly2, callEnd4, terminator] = tokens
504
+ eq closeCurly1[0 ], ' }'
505
+ assertAtCloseCurly = (token ) ->
506
+ eq token[2 ].first_line , closeCurly1[2 ].last_line
507
+ eq token[2 ].first_column , closeCurly1[2 ].last_column
508
+ eq token[2 ].last_line , closeCurly1[2 ].last_line
509
+ eq token[2 ].last_column , closeCurly1[2 ].last_column
510
+
511
+ for token in [outdent1, outdent2, outdent3, outdent4, outdent5, outdent6]
512
+ eq token[0 ], ' OUTDENT'
513
+ assertAtCloseCurly (token)
514
+ for token in [callEnd1, callEnd2, callEnd3]
515
+ eq token[0 ], ' CALL_END'
516
+ assertAtCloseCurly (token)
517
+
518
+ test " Verify real CALL_END tokens have the right position" , ->
519
+ source = '''
520
+ a()
521
+ '''
522
+ tokens = CoffeeScript .tokens source
523
+ [identifier , callStart , callEnd , terminator ] = tokens
524
+ startIndex = identifier[2 ].first_column
525
+ eq identifier[2 ].last_column , startIndex
526
+ eq callStart[2 ].first_column , startIndex + 1
527
+ eq callStart[2 ].last_column , startIndex + 1
528
+ eq callEnd[2 ].first_column , startIndex + 2
529
+ eq callEnd[2 ].last_column , startIndex + 2
530
+
490
531
test " Verify all tokens get a location" , ->
491
532
doesNotThrow ->
492
533
tokens = CoffeeScript .tokens testScript
0 commit comments