Sha256: 36102541fc3bd81a8e49364d85a54db289e6e6898b02bd9a174d5c6e1775f138

Contents?: true

Size: 609 Bytes

Versions: 1

Compression:

Stored size: 609 Bytes

Contents

require 'spec_helper'
module Sexpr
  describe Sequence, 'match?' do

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

    it 'returns true on match' do
      rule.should be_match([nil, "hello"])
    end

    it 'returns false on partial match' do
      rule.should_not be_match([nil, "hello", "world"])
    end

    it 'returns false on no match' do
      rule.should_not be_match([:hello, 12])
      rule.should_not be_match([])
      rule.should_not be_match(nil)
      rule.should_not be_match([nil])
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sexpr-0.2.0 spec/sequence/test_match_q.rb