antlr3 /runtime/Ruby/test/unit/test-recognizers.rb

Language Ruby Lines 55
MD5 Hash b2610c4daa8374872dcddf0dfcd239c0 Estimated Cost $1,041 (why?)
Repository https://bitbucket.org/jwalton/antlr3.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/ruby
# encoding: utf-8

require 'antlr3'
require 'test/unit'
require 'spec'

include ANTLR3

class TestTokenSource < Test::Unit::TestCase
  TrivialToken = Struct.new(:type) do
    include Token
  end
  class TestSource
    include TokenSource
    def initialize
      @tokens = (1..4).map { |i| TrivialToken[i] }
      @tokens << TrivialToken[EOF]
    end
    
    def next_token
      @tokens.shift
    end
  end
  
  def test_iterator_interface
    src = TestSource.new
    tokens = []
    src.each do |token|
      tokens << token.type
    end
    tokens.should == [1,2,3,4]
  end
  
end

class TestLexer < Test::Unit::TestCase
  class TLexer < Lexer
    @antlr_version = ANTLR3::ANTLR_VERSION.dup
  end
  def test_init
    stream = StringStream.new('foo')
    TLexer.new(stream)
  end
end

__END__
testrecognizers.py                           | LN | STATUS
---------------------------------------------+----+--------------
class TestBaseRecognizer(unittest.TestCase)  | 07 | [x]
    def testGetRuleInvocationStack(self)     | 10 | [x]
class TestTokenSource(unittest.TestCase)     | 20 | [x]
    def testIteratorInterface(self)          | 24 | [x]
class TestLexer(unittest.TestCase)           | 54 | [x]
    def testInit(self)                       | 56 | [x]
Back to Top