Sha256: 1343de49c31d32e1f23bdd8fbc06e4dc6881ba07185de0583c6657d49e327f91

Contents?: true

Size: 725 Bytes

Versions: 6

Compression:

Stored size: 725 Bytes

Contents

require File.join(File.dirname(__FILE__), '..', 'test_helper')

class ParsingRuleTest < CompilerTestCase

  testing_grammar %{
    grammar Foo
      rule bar
        "baz"
      end
    end
  }

  test "node cache storage and retrieval" do
    parser = FooParser.new
    parser.send(:prepare_to_parse, 'baz')
    node_cache = parser.send(:node_cache)
    
    node_cache[:bar][0].should be_nil
    
    parser._nt_bar
    
    cached_node = node_cache[:bar][0]        
    cached_node.should be_an_instance_of(Runtime::SyntaxNode)
    cached_node.text_value.should == 'baz'
    
    parser.instance_eval { @index = 0 }
    parser._nt_bar.should equal(cached_node)
    parser.index.should == cached_node.interval.end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
treetop-1.0.0 test/compiler/parsing_rule_test.rb
treetop-1.1.2 test/compiler/parsing_rule_test.rb
treetop-1.0.1 test/compiler/parsing_rule_test.rb
treetop-1.0.2 test/compiler/parsing_rule_test.rb
treetop-1.1.0 test/compiler/parsing_rule_test.rb
treetop-1.1.1 test/compiler/parsing_rule_test.rb