Sha256: c61e326b474d50a3e4d90d8b3864362fd328f04140508359f72af73a9c996227

Contents?: true

Size: 970 Bytes

Versions: 3

Compression:

Stored size: 970 Bytes

Contents

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

describe "A nonterminal symbol followed by a block", :extend => CompilerTestCase do
  testing_expression 'foo { def a_method; end }'
  
  parser_class_under_test.class_eval do
    def _nt_foo
      '_nt_foo called'
    end
  end
  
  it "compiles to a method call, extending its results with the anonymous module for the block" do
    result = parse('')
    result.should == '_nt_foo called'
    result.should respond_to(:a_method)
  end
end

class NonterminalWithModuleDeclationTest < CompilerTestCase
  module TestModule
    def a_method
    end
  end
  
  testing_expression 'foo <TestModule>'
  
  parser_class_under_test.class_eval do
    def _nt_foo
      '_nt_foo called'
    end
  end
  
  it "compiles to a method call, extending its results with the anonymous module for the block" do
    result = parse('')
    result.should == '_nt_foo called'
    result.should respond_to(:a_method)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
treetop-1.1.0 test/compiler/nonterminal_symbol_test.rb
treetop-1.1.1 test/compiler/nonterminal_symbol_test.rb
treetop-1.1.2 test/compiler/nonterminal_symbol_test.rb