forked from nathansobo/treetop
-
Notifications
You must be signed in to change notification settings - Fork 1
/
nonterminal_symbol_spec.rb
40 lines (33 loc) · 1008 Bytes
/
nonterminal_symbol_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require 'spec_helper'
module NonterminalSymbolSpec
describe "A nonterminal symbol followed by a block" 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
module TestModule
def a_method
end
end
describe "a non-terminal followed by a module declaration" do
testing_expression 'foo <NonterminalSymbolSpec::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
end