spec/rley/parser/parse_entry_spec.rb in rley-0.7.07 vs spec/rley/parser/parse_entry_spec.rb in rley-0.7.08

- old
+ new

@@ -50,11 +50,11 @@ end it 'should know the origin value' do expect(subject.origin).to eq(origin_val) end - + it 'should have not antecedent at creation' do expect(subject.antecedents).to be_empty expect(subject).to be_orphan end end # context @@ -89,17 +89,17 @@ expect(subject).not_to be_end_entry instance = ParseEntry.new(GFG::EndVertex.new('NT.'), 3) expect(instance).to be_end_entry end - + it 'should know if the entry is a dotted item vertex' do expect(subject).not_to be_dotted_entry instance = ParseEntry.new(GFG::ItemVertex.new('P => S.'), 3) expect(instance).to be_dotted_entry - end + end it 'should know if the vertex is at end of production (if any)' do # Case: start vertex instance1 = ParseEntry.new(GFG::StartVertex.new('.NT'), 3) expect(instance1).not_to be_exit_entry @@ -118,76 +118,76 @@ v2 = double('vertex-at-end') expect(v2).to receive(:complete?).and_return(true) instance4 = ParseEntry.new(v2, 3) expect(instance4).to be_exit_entry end - + it 'should know if the vertex is at begin of production (if any)' do # Case: start vertex instance1 = ParseEntry.new(GFG::StartVertex.new('.NT'), 3) expect(instance1).not_to be_entry_entry # Case: end vertex instance2 = ParseEntry.new(GFG::EndVertex.new('NT.'), 3) expect(instance2).not_to be_entry_entry # Case: item vertex not at begin of rhs - d1 = Base::DottedItem.new(sample_prod, 1) + d1 = Base::DottedItem.new(sample_prod, 1) v1 = GFG::ItemVertex.new(d1) instance3 = ParseEntry.new(v1, 3) expect(instance3).not_to be_entry_entry # Case: item vertex at end of rhs - d2 = Base::DottedItem.new(sample_prod, 0) - v2 = GFG::ItemVertex.new(d2) + d2 = Base::DottedItem.new(sample_prod, 0) + v2 = GFG::ItemVertex.new(d2) instance4 = ParseEntry.new(v2, 3) expect(instance4).to be_entry_entry - end + end it 'should know the symbol before the dot (if any)' do # Case: start vertex instance1 = ParseEntry.new(GFG::StartVertex.new('.NT'), 3) expect(instance1.prev_symbol).to be_nil # Case: end vertex instance2 = ParseEntry.new(GFG::EndVertex.new('NT.'), 3) expect(instance2.prev_symbol).to be_nil # Really correct? - + # Case: item vertex not at start of rhs v1 = double('vertex-not-at-start') expect(v1).to receive(:prev_symbol).and_return('symbol') instance3 = ParseEntry.new(v1, 3) - expect(instance3.prev_symbol).to eq('symbol') + expect(instance3.prev_symbol).to eq('symbol') # Case: item vertex at start of rhs v2 = double('vertex-at-start') expect(v2).to receive(:prev_symbol).and_return(nil) instance4 = ParseEntry.new(v2, 0) - expect(instance4.prev_symbol).to be_nil + expect(instance4.prev_symbol).to be_nil end - + it 'should know the next expected symbol (if any)' do # Case: start vertex instance1 = ParseEntry.new(GFG::StartVertex.new('.NT'), 3) expect(instance1.next_symbol).to be_nil # Case: end vertex instance2 = ParseEntry.new(GFG::EndVertex.new('NT.'), 3) expect(instance2.next_symbol).to be_nil - + # Case: item vertex not at end of rhs v1 = double('vertex-not-at-end') expect(v1).to receive(:next_symbol).and_return('symbol') instance3 = ParseEntry.new(v1, 3) - expect(instance3.next_symbol).to eq('symbol') + expect(instance3.next_symbol).to eq('symbol') # Case: item vertex at end of rhs v2 = double('vertex-at-end') expect(v2).to receive(:next_symbol).and_return(nil) instance4 = ParseEntry.new(v2, 3) - expect(instance4.next_symbol).to be_nil - end + expect(instance4.next_symbol).to be_nil + end it 'should accept antecedents' do antecedent = ParseEntry.new(vertex2, origin_val) subject.add_antecedent(antecedent) expect(subject.antecedents).to eql([antecedent]) @@ -196,22 +196,22 @@ it 'should know its text representation' do expected = '.sentence | 3' expect(subject.to_s).to eq(expected) end - + it 'should be inspectable' do subject.add_antecedent(subject) # Cheat for the good cause... # expected = '.sentence | 3' prefix = /^#<Rley::Parser::ParseEntry:\d+ @vertex/ expect(subject.inspect).to match(prefix) pattern = /@vertex=<Rley::GFG::StartVertex:\d+ label=\.sentence/ expect(subject.inspect).to match(pattern) pattern2 = /@origin=3 @antecedents=\[/ expect(subject.inspect).to match(pattern2) suffix = /<Rley::GFG::StartVertex:\d+ label=\.sentence> @origin=3\]>$/ - expect(subject.inspect).to match(suffix) - end + expect(subject.inspect).to match(suffix) + end end # context end # describe end # module end # module