PageRenderTime 66ms CodeModel.GetById 32ms RepoModel.GetById 1ms app.codeStats 0ms

/antlr-3.4/runtime/Ruby/test/unit/test-recognizers.rb

https://bitbucket.org/cyanogenmod/android_external_antlr
Ruby | 55 lines | 45 code | 8 blank | 2 comment | 1 complexity | b2610c4daa8374872dcddf0dfcd239c0 MD5 | raw file
  1. #!/usr/bin/ruby
  2. # encoding: utf-8
  3. require 'antlr3'
  4. require 'test/unit'
  5. require 'spec'
  6. include ANTLR3
  7. class TestTokenSource < Test::Unit::TestCase
  8. TrivialToken = Struct.new(:type) do
  9. include Token
  10. end
  11. class TestSource
  12. include TokenSource
  13. def initialize
  14. @tokens = (1..4).map { |i| TrivialToken[i] }
  15. @tokens << TrivialToken[EOF]
  16. end
  17. def next_token
  18. @tokens.shift
  19. end
  20. end
  21. def test_iterator_interface
  22. src = TestSource.new
  23. tokens = []
  24. src.each do |token|
  25. tokens << token.type
  26. end
  27. tokens.should == [1,2,3,4]
  28. end
  29. end
  30. class TestLexer < Test::Unit::TestCase
  31. class TLexer < Lexer
  32. @antlr_version = ANTLR3::ANTLR_VERSION.dup
  33. end
  34. def test_init
  35. stream = StringStream.new('foo')
  36. TLexer.new(stream)
  37. end
  38. end
  39. __END__
  40. testrecognizers.py | LN | STATUS
  41. ---------------------------------------------+----+--------------
  42. class TestBaseRecognizer(unittest.TestCase) | 07 | [x]
  43. def testGetRuleInvocationStack(self) | 10 | [x]
  44. class TestTokenSource(unittest.TestCase) | 20 | [x]
  45. def testIteratorInterface(self) | 24 | [x]
  46. class TestLexer(unittest.TestCase) | 54 | [x]
  47. def testInit(self) | 56 | [x]