Sha256: e2590dab13b97d724edc4b6098b912aca4301e60f55650e293682d9e5b8c5a90
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
require 'spec_helper' module Sexpr describe Many, "eat" do let(:term){ Terminal.new(/^[a-z]+$/) } let(:rule){ Many.new term, min, max } context "when set for *" do let(:min){ 0 } let(:max){ nil } it 'returns the subarray when zero match' do rule.eat([nil, "world", "then"]).should eq([nil, "world", "then"]) end it 'returns the subarray when one match' do rule.eat(["world", nil, "then"]).should eq([nil, "then"]) end it 'returns the subarray when multiple matches' do rule.eat(["world", "then"]).should eq([]) end end # * context "when set for +" do let(:min){ 1 } let(:max){ nil } it 'returns nil zero match' do rule.eat([nil, "world", "then"]).should be_nil end it 'returns the subarray when one match' do rule.eat(["world", nil, "then"]).should eq([nil, "then"]) end it 'returns the subarray when multiple matches' do rule.eat(["world", "then"]).should eq([]) end end # + context "when set for ?" do let(:min){ 0 } let(:max){ 1 } it 'returns the subarray when zero match' do rule.eat([nil, "world", "then"]).should eq([nil, "world", "then"]) end it 'returns the subarray when one match' do rule.eat(["world", "then"]).should eq(["then"]) end end # ? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sexpr-0.2.0 | spec/many/test_eat.rb |