Skip to content

Commit feb42e5

Browse files
committed
Add a test that tokens have locations that are in order
1 parent bd0024a commit feb42e5

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

test/location.coffee

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,25 @@ test "#3621: Multiline regex and manual `Regex` call with interpolation should
450450
eq tokenA.origin?[1], tokenB.origin?[1]
451451
eq tokenA.stringEnd, tokenB.stringEnd
452452

453+
test "Verify tokens have locations that are in order", ->
454+
source = '''
455+
a {
456+
b: ->
457+
return c d,
458+
if e
459+
f
460+
}
461+
g
462+
'''
463+
tokens = CoffeeScript.tokens source
464+
lastToken = null
465+
for token in tokens
466+
if lastToken
467+
ok token[2].first_line >= lastToken[2].last_line
468+
if token[2].first_line == lastToken[2].last_line
469+
ok token[2].first_column >= lastToken[2].last_column
470+
lastToken = token
471+
453472
test "Verify all tokens get a location", ->
454473
doesNotThrow ->
455474
tokens = CoffeeScript.tokens testScript

0 commit comments

Comments
 (0)