Sha256: 07efd49391f02b04773158ad5b3f37e704687d4fd780c7c13f5f35120b4bcd53

Contents?: true

Size: 1.14 KB

Versions: 8

Compression:

Stored size: 1.14 KB

Contents

#
# specifying raabro
#
# Mon Sep 21 05:56:18 JST 2015
#

require 'spec_helper'


describe Raabro do

  describe '.all' do

    it 'fails when not all the input is consumed' do

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

      t = Raabro.all(nil, i, :to_plus)

      expect(t.to_a(:leaves => true)).to eq(
        [ nil, 0, 0, 0, nil, :all, [
          [ :tos, 1, 0, 6, nil, :rep, [
            [ nil, 1, 0, 2, nil, :str, 'to' ],
            [ nil, 1, 2, 2, nil, :str, 'to' ],
            [ nil, 1, 4, 2, nil, :str, 'to' ],
            [ nil, 0, 6, 0, nil, :str, [] ]
          ] ]
        ] ]
      )
      expect(i.offset).to eq(0)
    end

    it 'succeeds when all the input is consumed' do

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

      t = Raabro.all(nil, i, :to_plus)

      expect(t.to_a(:leaves => true)).to eq(
        [ nil, 1, 0, 6, nil, :all, [
          [ :tos, 1, 0, 6, nil, :rep, [
            [ nil, 1, 0, 2, nil, :str, 'to' ],
            [ nil, 1, 2, 2, nil, :str, 'to' ],
            [ nil, 1, 4, 2, nil, :str, 'to' ],
            [ nil, 0, 6, 0, nil, :str, [] ]
          ] ]
        ] ]
      )
      expect(i.offset).to eq(6)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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