Sha256: 2d137e1ef726ed4bd08402d2b839040bf763cd5ecadb3e4993ba28911eefa28f

Contents?: true

Size: 1.28 KB

Versions: 38

Compression:

Stored size: 1.28 KB

Contents

require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")

module SyntaxNodeSpec
  describe "A new terminal syntax node" do
    attr_reader :node

    before do
      @node = Runtime::SyntaxNode.new("input", 0...3)
    end
  
    it "reports itself as terminal" do
      node.should be_terminal
      node.should_not be_nonterminal
    end
  
    it "has a text value based on the input and the interval" do
      node.text_value.should == "inp"
    end
  
    it "has itself as its only element" do
      node.elements.should be_nil
    end
  end

  describe "A new nonterminal syntax node" do
    attr_reader :node

    before do
      @input = 'test input'
      @elements = [Runtime::SyntaxNode.new('input', 0...3)]
      @node = Runtime::SyntaxNode.new('input', 0...3, @elements)
    end

    it "reports itself as nonterminal" do
      node.should be_nonterminal
      node.should_not be_terminal
    end
  
    it "has a text value based on the input and the interval" do
      node.text_value.should == "inp"
    end
  
    it "has the elements with which it was instantiated" do
      node.elements.should == @elements
    end

    it "sets itself as the parent of its elements" do
      node.elements.each do |element|
        element.parent.should == node
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 6 rubygems

Version Path
cloudhead-less-1.0.16 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
cloudhead-less-1.1.0 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
cloudhead-less-1.1.1 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
cloudhead-less-1.1.10 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
cloudhead-less-1.1.11 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
cloudhead-less-1.1.12 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
cloudhead-less-1.1.13 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
cloudhead-less-1.1.2 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
cloudhead-less-1.1.3 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
cloudhead-less-1.1.4 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
cloudhead-less-1.1.5 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
cloudhead-less-1.1.6 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
cloudhead-less-1.1.7 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
cloudhead-less-1.1.8 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
cloudhead-less-1.1.9 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
cloudhead-less-1.2.0 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
cloudhead-less-1.2.1 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
cloudhead-less-1.2.2 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
cloudhead-less-1.2.3 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb
nirvdrum-less-1.1.4 lib/vendor/treetop/spec/runtime/syntax_node_spec.rb