File: alternative_spec.rb

package info (click to toggle)
ruby-parslet 1.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 908 kB
  • ctags: 473
  • sloc: ruby: 5,220; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 640 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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