Home | History | Annotate | Download | only in unit

Lines Matching refs:stream

13     @stream = StringStream.new( "oh\nhey!\n" )
17 @stream.size.should == 8
21 @stream.index.should == 0
25 @stream.consume # o
26 @stream.index.should == 1
27 @stream.column.should == 1
28 @stream.line.should == 1
30 @stream.consume # h
31 @stream.index.should == 2
32 @stream.column.should == 2
33 @stream.line.should == 1
35 @stream.consume # \n
36 @stream.index.should == 3
37 @stream.column.should == 0
38 @stream.line.should == 2
40 @stream.consume # h
41 @stream.index.should == 4
42 @stream.column.should == 1
43 @stream.line.should == 2
45 @stream.consume # e
46 @stream.index.should == 5
47 @stream.column.should == 2
48 @stream.line.should == 2
50 @stream.consume # y
51 @stream.index.should == 6
52 @stream.column.should == 3
53 @stream.line.should == 2
55 @stream.consume # !
56 @stream.index.should == 7
57 @stream.column.should == 4
58 @stream.line.should == 2
60 @stream.consume # \n
61 @stream.index.should == 8
62 @stream.column.should == 0
63 @stream.line.should == 3
65 @stream.consume # EOF
66 @stream.index.should == 8
67 @stream.column.should == 0
68 @stream.line.should == 3
70 @stream.consume # EOF
71 @stream.index.should == 8
72 @stream.column.should == 0
73 @stream.line.should == 3
77 2.times { @stream.consume }
78 @stream.reset
79 @stream.index.should == 0
80 @stream.line.should == 1
81 @stream.column.should == 0
82 @stream.peek(1).should == ?o.ord
86 @stream.look(1).should == 'o'
87 @stream.look(2).should == 'h'
88 @stream.look(3).should == "\n"
89 @stream.peek(1).should == ?o.ord
90 @stream.peek(2).should == ?h.ord
91 @stream.peek(3).should == ?\n.ord
93 6.times { @stream.consume }
94 @stream.look(1).should == '!'
95 @stream.look(2).should == "\n"
96 @stream.look(3).should be_nil
97 @stream.peek(1).should == ?!.ord
98 @stream.peek(2).should == ?\n.ord
99 @stream.peek(3).should == EOF
103 @stream.substring(0,0).should == 'o'
104 @stream.substring(0,1).should == 'oh'
105 @stream.substring(0,8).should == "oh\nhey!\n"
106 @stream.substring(3,6).should == "hey!"
110 @stream.seek(3)
111 @stream.index.should == 3
112 @stream.line.should == 2
113 @stream.column.should == 0
114 @stream.peek(1).should == ?h.ord
118 @stream.seek(4)
119 marker = @stream.mark
122 2.times { @stream.consume }
123 marker = @stream.mark
129 @stream.seek(4)
130 marker1 = @stream.mark
132 2.times { @stream.consume }
133 marker2 = @stream.mark
135 @stream.release
136 @stream.mark_depth.should == 2
137 @stream.release
138 @stream.mark_depth.should == 1
142 @stream.seek(4)
143 marker1 = @stream.mark()
145 @stream.consume()
146 marker2 = @stream.mark()
148 @stream.consume()
149 marker3 = @stream.mark()
151 @stream.release(marker2)
152 @stream.mark_depth.should == 2
157 @stream.seek(4)
159 marker = @stream.mark
160 @stream.consume
161 @stream.consume
163 @stream.rewind
164 @stream.mark_depth.should == 1
165 @stream.index.should == 4
166 @stream.line.should == 2
167 @stream.column.should == 1
168 @stream.peek(1).should == ?e.ord
173 @stream.through( 2 ).should == 'oh'
174 @stream.through( -2 ).should == ''
175 @stream.seek( 5 )
176 @stream.through( 0 ).should == ''
177 @stream.through( 1 ).should == 'y'
178 @stream.through( -2 ).should == 'he'
179 @stream.through( 5 ).should == "y!\n"
183 @stream.seek(4)
184 marker1 = @stream.mark()
186 @stream.consume
187 marker2 = @stream.mark
189 @stream.consume
190 marker3 = @stream.mark
192 @stream.rewind(marker2)
193 @stream.mark_depth.should == 2
194 @stream.index().should == 5
195 @stream.line.should == 2
196 @stream.column.should == 2
197 @stream.peek(1).should == ?y.ord
206 path = File.join(File.dirname(__FILE__), 'sample-input/file-stream-1')
207 @stream = FileStream.new(path)
209 @stream.seek(4)
210 marker1 = @stream.mark()
212 @stream.consume()
213 marker2 = @stream.mark()
215 @stream.consume()
216 marker3 = @stream.mark()
218 @stream.rewind(marker2)
219 @stream.index().should == 5
220 @stream.line.should == 2
221 @stream.column.should == 1
222 @stream.mark_depth.should == 2
223 @stream.look(1).should == 'a'
224 @stream.peek(1).should == ?a.ord
257 @stream = CommonTokenStream.new( @source )
258 @stream.position.should == 0
265 @stream = CommonTokenStream.new( @source1 )
267 @stream.position.should == 0
268 @stream.tokens.length.should == 0
270 @stream.rebuild( @source2 )
271 @stream.token_source.should == @source2
272 @stream.position.should == 1
273 @stream.tokens.should have( 2 ).things
278 @stream = CommonTokenStream.new(@source)
279 @stream.look.should == ANTLR3::EOF_TOKEN
285 @stream = CommonTokenStream.new(@source)
286 @stream.look(1).type.should == 12
294 @stream = CommonTokenStream.new(@source)
295 @stream.look(1).type.should == 13
303 @stream = CommonTokenStream.new(@source)
304 @stream.look(2).type.should == EOF
310 @stream = CommonTokenStream.new(@source)
311 @stream.consume
313 @stream.look(-1).type.should == 12
319 @stream = CommonTokenStream.new(@source)
321 @stream.consume
322 @stream.look(-1).type.should == 12
329 @stream = CommonTokenStream.new(@source)
330 @stream.look(0).should == nil
339 @stream = CommonTokenStream.new(@source)
341 @stream.look(-1).should == nil
342 2.times { @stream.consume }
343 @stream.look(-3).should == nil
349 @stream = CommonTokenStream.new(@source)
351 @stream.instance_variable_get(:@tokens).length.should == 3
352 @stream.tokens[0].type.should == 12
353 @stream.tokens[1].type.should == 13
354 @stream.tokens[2].type.should == 14
360 @stream = CommonTokenStream.new(@source)
361 @stream.peek.should == 12
362 @stream.consume
363 @stream.peek.should == 13
364 @stream.consume
365 @stream.peek.should == EOF
366 @stream.consume
367 @stream.peek.should == EOF
373 @stream = CommonTokenStream.new(@source)
375 @stream.peek(1).should == 12
376 @stream.seek(2).peek.should == EOF
377 @stream.seek(0).peek.should == 12
378 @stream.seek(-3).position.should == 0
379 @stream.seek(10).position.should == 2
385 @stream = CommonTokenStream.new(@source)
386 @stream.consume
387 marker = @stream.mark
388 @stream.consume
389 @stream.rewind(marker)
390 @stream.peek(1).should == 13
398 @stream = CommonTokenStream.new(@source)
399 @stream.to_s.should == "foobargnurzblarz"
400 @stream.to_s(1,2).should == 'bargnurz'
401 @stream.to_s(@stream[1], @stream[-2]).should == 'bargnurz'