Sha256: 0b782b2be99c390619045739619d10b37088af59f241a1e3ecaedb2995e534b7

Contents?: true

Size: 577 Bytes

Versions: 7

Compression:

Stored size: 577 Bytes

Contents

require 'spec_helper'

describe Parslet::Atoms::Scope do
  include Parslet
  include Parslet::Atoms::DSL
  
  
  let(:context) { Parslet::Atoms::Context.new(nil) }
  let(:captures) { context.captures }
  
  def inject string, parser
    source = Parslet::Source.new(string)
    parser.apply(source, context, true)
  end
  
  let(:aabb) { 
    scope {
      match['ab'].capture(:f) >> dynamic { |s,c| str(c.captures[:f]) }
    }
  }
  it "keeps values of captures outside" do
    captures[:f] = 'old_value'
    inject 'aa', aabb
    captures[:f].should == 'old_value'
  end 
end

Version data entries

7 entries across 7 versions & 2 rubygems

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