Sha256: b3d20fa47be06579ebdf79b4135805862344a9412111f3ce3058c82a42665fdb

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require "test_helper"
 
class TestCorrespondences < Test::Unit::TestCase

  include TestHelper
  include CodeModels
  include CodeModels::Java

  J = CodeModels::Java

  def test_correspondance_of_field
    code = "class A extends B { int fieldB; int getB(){ return fieldB; } }"
    nt = J::DefaultParser.node_tree_from_code(code)
    mt = J.parse_code(code)
    model_field = mt.types[0].members[0]
    node_field  = nt.types[0].members[0]
    assert_equal node_field, J::DefaultParser.corresponding_node(model_field,nt)
    assert_equal "int fieldB;", J::DefaultParser.corresponding_node(model_field,nt).to_s 
  end

  def test_corresponding_node_from_code
    code = "class A extends B { int fieldB; int getB(){ return fieldB; } }"
    nt = J::DefaultParser.node_tree_from_code(code)
    mt = J.parse_code(code)
    model_field = mt.types[0].members[0]
    node_field  = nt.types[0].members[0]
    assert_equal node_field, J::DefaultParser.corresponding_node_from_code(model_field,code)
    assert_equal "int fieldB;", J::DefaultParser.corresponding_node_from_code(model_field,code).to_s
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
codemodels-java-0.2.2-java test/test_correspondences.rb
codemodels-java-0.2.1-java test/test_correspondences.rb