Broke dependency on facets and trying to coexist with Rails.
[treetop.git] / spec / runtime / syntax_node_spec.rb
blobf7c62d396a711f9eacdbf26803ac700344f06c9b
1 require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
3 module SyntaxNodeSpec
4   describe "A new terminal syntax node" do
5     attr_reader :node
7     before do
8       @node = Runtime::SyntaxNode.new("input", 0...3)
9     end
10   
11     it "reports itself as terminal" do
12       node.should be_terminal
13       node.should_not be_nonterminal
14     end
15   
16     it "has a text value based on the input and the interval" do
17       node.text_value.should == "inp"
18     end
19   
20     it "has itself as its only element" do
21       node.elements.should be_nil
22     end
23   end
25   describe "A new nonterminal syntax node" do
26     attr_reader :node
28     before do
29       @input = 'test input'
30       @elements = [Runtime::SyntaxNode.new('input', 0...3)]
31       @node = Runtime::SyntaxNode.new('input', 0...3, @elements)
32     end
34     it "reports itself as nonterminal" do
35       node.should be_nonterminal
36       node.should_not be_terminal
37     end
38   
39     it "has a text value based on the input and the interval" do
40       node.text_value.should == "inp"
41     end
42   
43     it "has the elements with which it was instantiated" do
44       node.elements.should == @elements
45     end
47     it "sets itself as the parent of its elements" do
48       node.elements.each do |element|
49         element.parent.should == node
50       end
51     end
52   end
53 end