Sha256: 81120d738f13d66d640e7d8dd37283674ae33b7a5c784ad6dedf40eeb4787d5e

Contents?: true

Size: 485 Bytes

Versions: 7

Compression:

Stored size: 485 Bytes

Contents

require 'spec_helper'
module Sexpr::Matcher
  describe Sequence, "eat" do

    let(:alt1){ Terminal.new(nil)          }
    let(:alt2){ Terminal.new(/^[a-z]+$/)   }
    let(:rule){ Sequence.new [alt1, alt2]  }

    it 'returns the subarray when match' do
      rule.eat([nil, "world", "then"]).should eq(["then"])
    end

    it 'returns nil when no match' do
      rule.eat([]).should be_nil
      rule.eat(["12"]).should be_nil
      rule.eat([nil]).should be_nil
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sexpr-1.1.0 spec/unit/matcher/sequence/test_eat.rb
sexpr-1.0.0 spec/unit/matcher/sequence/test_eat.rb
sexpr-0.6.0 spec/unit/matcher/sequence/test_eat.rb
sexpr-0.5.1 spec/matcher/sequence/test_eat.rb
sexpr-0.5.0 spec/matcher/sequence/test_eat.rb
sexpr-0.4.0 spec/matcher/sequence/test_eat.rb
sexpr-0.3.0 spec/matcher/sequence/test_eat.rb