Sha256: c3a306eae72761c88edb3561cfbdb5cf82c9eb6b601a2cfddcadf531dc755615

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'
module Gisele::Language
  class Rewriter
    describe WorkOnNodes do

      let(:won){ WorkOnNodes.new }

      it 'extends input nodes' do
        node = [:hello, "world"]
        seen = won.call(:rw, node) do |_,n|
          n.should be_a(AST::Node)
          n
        end
        seen.should eq(node)
      end

      it 'extends output nodes' do
        node = [:hello, "world"]
        seen = won.call(:rw, node) do |_,n|
          n.should be_a(AST::Node)
          [:result]
        end
        seen.should eq([:result])
        seen.should be_a(AST::Node)
      end

      it 'does not require the output to be a node' do
        node = [:hello, "world"]
        seen = won.call(:rw, node) do |_,n|
          n.should be_a(AST::Node)
          "blah"
        end
        seen.should eq("blah")
        seen.should_not be_a(AST::Node)
      end

      it 'fails unless the input looks a node' do
        lambda{
          won.call(:rw, "blah") do |_,n| end
        }.should raise_error(ArgumentError, /blah/)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gisele-0.4.0 spec/unit/language/rewriter/test_work_on_nodes.rb
gisele-0.3.0 spec/unit/language/rewriter/test_work_on_nodes.rb