Sha256: fdd3f849072f2ee4d2560da4228fb2a960b5859235ece4fc3daf24e16cc99073

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

require File.join(File.dirname(__FILE__), %w[.. spec_helper])

require TireSwing.path(%w(spec grammars assignments))

describe AssignmentsLanguage::Grammar do

  it "has nodes defined" do
    consts = AssignmentsLanguage::Grammar.constants
    consts.should include("Assignments")
    consts.should include("Assignment")
    consts.should include("BlankLine")
  end

end

describe AssignmentsLanguage::Parser, ".parse" do

  before(:each) do
    @input = File.read(TireSwing.path(%w(spec fixtures assignments.txt)))
  end

  it "parses a file and returns a TireSwing AST" do
    AssignmentsLanguage::Parser.parse(@input).should be_a_kind_of(TireSwing::Node)
  end

end

describe AssignmentsLanguage do
  it "has a string visitor defined" do
    AssignmentsLanguage.const_get("StringVisitor").ancestors.should include(TireSwing::Visitor)
  end
end

describe AssignmentsLanguage::StringVisitor do
  before(:each) do
    @input = File.read(TireSwing.path(%w(spec fixtures assignments.txt)))
    @ast = AssignmentsLanguage::Parser.parse(@input)
  end

  describe "#visit" do
    it "traverses the AST and collects the values" do
      AssignmentsLanguage::StringVisitor.visit(@ast).should == "foo = bar\nbaz = blech\nno = way\n"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
aniero-tire_swing-0.0.2 spec/integration/assignments_spec.rb
aniero-tire_swing-0.0.3 spec/integration/assignments_spec.rb
aniero-tire_swing-0.0.4 spec/integration/assignments_spec.rb
aniero-tire_swing-0.0.5 spec/integration/assignments_spec.rb
aniero-tire_swing-0.0.6 spec/integration/assignments_spec.rb