Sha256: e4256506967f5e8d1f6faf0d1246385a8c40a2b0f4ce16628d6100af6347f9a0

Contents?: true

Size: 862 Bytes

Versions: 8

Compression:

Stored size: 862 Bytes

Contents

#
# specifying raabro
#
# Sun Sep 20 07:12:35 JST 2015
#

require 'spec_helper'


describe Raabro do

  describe '.rex' do

    it 'hits' do

      i = Raabro::Input.new('toto')

      t = Raabro.rex(nil, i, /t[ua]/)

      expect(t.to_a).to eq(
        [ nil, 0, 0, 0, nil, :rex, [] ]
      )
      expect(i.offset).to eq(0)
    end

    it 'misses' do

      i = Raabro::Input.new('toto')

      t = Raabro.rex(nil, i, /(to)+/)

      expect(t.to_a(:leaves => true)).to eq(
        [ nil, 1, 0, 4, nil, :rex, 'toto' ]
      )
      expect(i.offset).to eq(4)
    end

    it 'misses if the match is not at the current input offset' do

      i = Raabro::Input.new('tato')

      t = Raabro.rex(:biga, i, /(to)+/)

      expect(t.to_a(:leaves => true)).to eq(
        [ :biga, 0, 0, 0, nil, :rex, [] ]
      )
      expect(i.offset).to eq(0)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
raabro-1.1.1 spec/rex_spec.rb
raabro-1.1.0 spec/rex_spec.rb
raabro-1.0.5 spec/rex_spec.rb
raabro-1.0.4 spec/rex_spec.rb
raabro-1.0.3 spec/rex_spec.rb
raabro-1.0.2 spec/rex_spec.rb
raabro-1.0.1 spec/rex_spec.rb
raabro-1.0.0 spec/rex_spec.rb