1 require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
4 describe "A new terminal syntax node" do
8 @node = Runtime::SyntaxNode.new("input", 0...3)
11 it "reports itself as terminal" do
12 node.should be_terminal
13 node.should_not be_nonterminal
16 it "has a text value based on the input and the interval" do
17 node.text_value.should == "inp"
20 it "has itself as its only element" do
21 node.elements.should be_nil
25 describe "A new nonterminal syntax node" do
30 @elements = [Runtime::SyntaxNode.new('input', 0...3)]
31 @node = Runtime::SyntaxNode.new('input', 0...3, @elements)
34 it "reports itself as nonterminal" do
35 node.should be_nonterminal
36 node.should_not be_terminal
39 it "has a text value based on the input and the interval" do
40 node.text_value.should == "inp"
43 it "has the elements with which it was instantiated" do
44 node.elements.should == @elements
47 it "sets itself as the parent of its elements" do
48 node.elements.each do |element|
49 element.parent.should == node