@@ -103,18 +103,19 @@ describe 'Stacktrace', ->
103103 expect (event .newTrace ).toBe (trace)
104104
105105describe ' Frame' , ->
106- [frame ] = []
106+ [fixturePath ] = []
107107
108108 beforeEach ->
109109 fixturePath = path .join __dirname , ' fixtures' , ' context.txt'
110- frame = new Frame (' five' , fixturePath, 5 , ' something' )
111110
112111 it ' acquires n lines of context asynchronously' , ->
113- lines = null
112+ [lines , traceLine ] = []
113+ frame = new Frame (' five' , fixturePath, 5 , ' something' )
114114
115- frame .getContext 2 , (err , ls ) ->
115+ frame .getContext 2 , (err , ls , lnum ) ->
116116 throw err if err?
117117 lines = ls
118+ traceLine = lnum
118119
119120 waitsFor -> lines?
120121
@@ -125,3 +126,40 @@ describe 'Frame', ->
125126 expect (lines[2 ]).toEqual (' five' )
126127 expect (lines[3 ]).toEqual (' six' )
127128 expect (lines[4 ]).toEqual (' ' )
129+ expect (traceLine).toBe (2 )
130+
131+ it ' identifies the trace line if the beginning is cut off' , ->
132+ [lines , traceLine ] = []
133+ frame = new Frame (' two' , fixturePath, 2 , ' something' )
134+
135+ frame .getContext 3 , (err , ls , lnum ) ->
136+ throw err if err?
137+ lines = ls
138+ traceLine = lnum
139+
140+ waitsFor -> lines?
141+
142+ runs ->
143+ expect (lines .length ).toBe (5 )
144+ expect (lines[0 ]).toEqual (' one' )
145+ expect (lines[4 ]).toEqual (' five' )
146+ expect (traceLine).toBe (1 )
147+ expect (lines[1 ]).toEqual (' two' )
148+
149+ it ' identifies the trace line if the end is cut off' , ->
150+ [lines , traceLine ] = []
151+ frame = new Frame (' nine' , fixturePath, 9 , ' something' )
152+
153+ frame .getContext 3 , (err , ls , lnum ) ->
154+ throw err if err?
155+ lines = ls
156+ traceLine = lnum
157+
158+ waitsFor -> lines?
159+
160+ runs ->
161+ expect (lines .length ).toBe (6 )
162+ expect (lines[0 ]).toEqual (' six' )
163+ expect (lines[5 ]).toEqual (' ' )
164+ expect (traceLine).toBe (3 )
165+ expect (lines[3 ]).toEqual (' nine' )
0 commit comments