 verifyTokens = (displayLayer) ->
   containingTags = []
 
+  for tokens in getTokenLines(displayLayer)
+    for {closeTags, openTags, text} in tokens
+      for tag in closeTags
+        mostRecentOpenTag = containingTags.pop()
+        expect(mostRecentOpenTag).toBe(tag)
+      containingTags.push(openTags...)
+
+    expect(containingTags).toEqual([])
+
+  expect(containingTags).toEqual([])
+
+verifyPositionTranslations = (displayLayer) ->
   lineScreenStart = Point.ZERO
   lineBufferStart = Point.ZERO
 

  for i in [0...1] by 1
    do ->
      seed = now + i
      seed = 1458149718164
      fit "updates the displayed text correctly when the underlying buffer changes: #{seed}", ->
        random = new Random(seed)
        buffer = new TextBuffer(text: buildRandomLines(random, 10))

            expect(displayLayer.clipScreenPosition(screenPosition, clipDirection: 'forward')).toEqual(tokenScreenEnd)
            expect(displayLayer.translateScreenPosition(screenPosition, clipDirection: 'backward')).toEqual(tokenBufferStart)
            expect(displayLayer.translateScreenPosition(screenPosition, clipDirection: 'forward')).toEqual(tokenBufferEnd)
            if comparePoints(bufferPosition, tokenBufferEnd) < 0
              expect(displayLayer.translateBufferPosition(bufferPosition, clipDirection: 'backward')).toEqual(tokenScreenStart)
              expect(displayLayer.translateBufferPosition(bufferPosition, clipDirection: 'forward')).toEqual(tokenScreenEnd)
        else unless token.metadata?.void
          expect(displayLayer.clipScreenPosition(screenPosition, clipDirection: 'backward')).toEqual(screenPosition)
          expect(displayLayer.clipScreenPosition(screenPosition, clipDirection: 'forward')).toEqual(screenPosition)
