Sha256: fe27c936224b5b1458b6a1082ae47f1029e7b241201b9a7eefad0731faa14a27
Contents?: true
Size: 1.5 KB
Versions: 4
Compression:
Stored size: 1.5 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "Nonterminal" do before (:each) do @n = Panini::Nonterminal.new end it "responds to #add_production" do @n.should respond_to(:add_production) end it "responds to #productions" do @n.should respond_to(:productions) end end describe "Nonterminal#add_production with a non-Array arument" do before (:each) do @n = Panini::Nonterminal.new end it "throws an error" do lambda { @n.add_production('a') }.should raise_error(ArgumentError, "The production must be an Array.") end end describe "Nonterminal#add_production with a single production" do before (:each) do @n = Panini::Nonterminal.new @p = @n.add_production(['a', 'b', 'c']) end it "returns nil" do @p.should be_nil end it "stores the production" do @n.productions.should have(1).item @n.productions[0].should == ['a', 'b', 'c'] end end describe "Nonterminal#add_production with two productions" do before (:each) do @n = Panini::Nonterminal.new @p1 = @n.add_production(['a', 'b', 'c']) @p2 = @n.add_production(['x', 'y', 'z']) end it "returns nil" do @p1.should be_nil @p2.should be_nil end it "stores the productions" do @n.productions.should have(2).items end it "stores the first one added first" do @n.productions[0].should == ['a', 'b', 'c'] end it "stores the second one added last" do @n.productions[1].should == ['x', 'y', 'z'] end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
panini-1.2.0 | spec/nonterminal_spec.rb |
panini-1.1.1 | spec/nonterminal_spec.rb |
panini-1.1.0 | spec/nonterminal_spec.rb |
panini-1.0.0 | spec/nonterminal_spec.rb |