Skip to content

Commit

Permalink
Add tests of concatenated rule parsing with delimeters
Browse files Browse the repository at this point in the history
  • Loading branch information
maetl committed Jun 28, 2016
1 parent 7cce5cb commit 6b393e3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/production/concat_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
describe Calyx::Production::Concat do
it 'treats input with no delimiters as a concatenated production with a single atom' do
registry = double('registry')
concat = Calyx::Production::Concat.parse('one two three', registry)
expect(concat.evaluate).to eq([:concat, [[:atom, 'one two three']]])
end

it 'treats input with delimiters as a concatenated production with an expansion' do
registry = double('registry')
allow(registry).to receive(:expand).and_return(Calyx::Production::Terminal.new('ONE'))
concat = Calyx::Production::Concat.parse('{one} two three', registry)
expect(concat.evaluate).to eq([:concat, [[:atom, ''], [:one, [:atom, 'ONE']], [:atom, ' two three']]])
end
end

0 comments on commit 6b393e3

Please sign in to comment.