Sha256: 03e0bab97a2319b9c277d31276f6500d6e7bdaceec07037db46ad04bca2b9365

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require 'test/unit'

require File.join(File.dirname(__FILE__), "java")

# We test the grammar in several logical "chunks" below with one TestCase 
# for each logical chunk.

class ATestJavaType < Test::Unit::TestCase
  def assert_parse(exp, str, startSymbol)
    res = Java::Parser.parse_string(str, startSymbol)
    assert_equal(exp, res)
  end

  include Java::Grammar::ASTs

  def test_01_resulttype_void
    assert_parse([:ResultType, "void"], "void", :ResultType)
    assert_parse([:ResultType, Type[[:TypeName, "byte"], nil]], 
                 "byte", :ResultType)
    assert_parse([:ResultType, Type[[:TypeName, "byte"], ["[]"]]], 
                 "byte[]", :ResultType)
    assert_parse([:ResultType, Type[[:TypeName, "short"], ["[]", "[]"]]], 
                 "short[][]", :ResultType)
  end

  def test_02_symbols
    # Note! We should make each grammar be its own class so that constants
    # are defined within that scope!
    JavaSymbols.each do |name, symbol_str|
      assert_parse(symbol_str, symbol_str, :Symbol)
    end
  end

  def test_03
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rockit-0.7.2 tests/acceptance/packrat/java/atest_java.rb