Sha256: b72976f3afaaff43c8cabd794ad1278984e6246eeb7dc1175342354f96b30337

Contents?: true

Size: 526 Bytes

Versions: 1

Compression:

Stored size: 526 Bytes

Contents

require 'spec_helper'
module Sexpr
  describe Rule, "eat" do

    let(:defn){ Sequence.new [Terminal.new(/^[a-z]+$/)] }
    let(:rule){ Rule.new :hello, defn }

    it 'returns the trailing array when match' do
      rule.eat([[:hello, "world"], "!"]).should eq(["!"])
    end

    it 'returns nil when not match' do
      rule.eat([:hello, "world"]).should be_nil
      rule.eat([:hello]).should be_nil
      rule.eat([]).should be_nil
      rule.eat([[]]).should be_nil
      rule.eat([nil]).should be_nil
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sexpr-0.2.0 spec/rule/test_eat.rb