Sha256: 5f3c114076870a8ee7923385f8f6786ba8e4bf79390336b2e538d8961d77a145

Contents?: true

Size: 640 Bytes

Versions: 7

Compression:

Stored size: 640 Bytes

Contents

require 'spec_helper'

describe Parslet::Atoms::Alternative do
  include Parslet
  
  describe '| shortcut' do
    let(:alternative) { str('a') | str('b') }
    
    context "when chained with different atoms" do
      before(:each) { 
        # Chain something else to the alternative parslet. If it modifies the
        # parslet atom in place, we'll notice: 
        
        alternative | str('d')
      }
      let!(:chained) { alternative | str('c') }
      
      
      it "is side-effect free" do
        chained.should parse('c')
        chained.should parse('a')
        chained.should_not parse('d')
      end 
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
parslet-2.0.0 spec/parslet/atoms/alternative_spec.rb
parslet-1.8.2 spec/parslet/atoms/alternative_spec.rb
parslet-1.8.1 spec/parslet/atoms/alternative_spec.rb
parslet-1.8.0 spec/parslet/atoms/alternative_spec.rb
swift-pyrite-0.1.1 vendor/bundle/ruby/2.0.0/gems/parslet-1.7.1/spec/parslet/atoms/alternative_spec.rb
swift-pyrite-0.1.0 vendor/bundle/ruby/2.0.0/gems/parslet-1.7.1/spec/parslet/atoms/alternative_spec.rb
parslet-1.7.1 spec/parslet/atoms/alternative_spec.rb