<commit_before>require 'spec_helper'

require 'timeout'
require 'parslet'

describe Parslet do
  def not_parse
    raise_error(Parslet::ParseFailed)
  end
  
  include Parslet
  extend Parslet

  def src(str)
    Source.new str
  end
  
  describe "match('[abc]')" do
    attr_reader :parslet
    before(:each) do
      @parslet = match('[abc]')
    end
    
    it "should parse {a,b,c}" do
      parslet.parse('a')
      parslet.parse('b')
      parslet.parse('c')
    end 
    it "should not parse d" do
      lambda {
        parslet.parse('d')
      }.should not_parse
      parslet.cause.should == "Failed to match [abc] at line 1 char 1."
    end 
    it "should print as [abc]" do
      parslet.inspect.should == "[abc]"
    end 
  end
  describe "match(['[a]').repeat(3)" do
    attr_reader :parslet
    before(:each) do
      @parslet = match('[a]').repeat(3)
    end
    
    context "when failing on input 'aa'" do
      before(:each) do<commit_msg>! fixes Source constant finding troubles<commit_after>require 'spec_helper'

require 'timeout'
require 'parslet'

describe Parslet do
  def not_parse
    raise_error(Parslet::ParseFailed)
  end
  
  include Parslet
  extend Parslet

  def src(str)
    Parslet::Source.new str
  end
  
  describe "match('[abc]')" do
    attr_reader :parslet
    before(:each) do
      @parslet = match('[abc]')
    end
    
    it "should parse {a,b,c}" do
      parslet.parse('a')
      parslet.parse('b')
      parslet.parse('c')
    end 
    it "should not parse d" do
      lambda {
        parslet.parse('d')
      }.should not_parse
      parslet.cause.should == "Failed to match [abc] at line 1 char 1."
    end 
    it "should print as [abc]" do
      parslet.inspect.should == "[abc]"
    end 
  end
  describe "match(['[a]').repeat(3)" do
    attr_reader :parslet
    before(:each) do
      @parslet = match('[a]').repeat(3)
    end
    
    context "when failing on input 'aa'" do
      before(:each) do
{'fraction_non_alphanumeric': 0.1261491317671093, 'fraction_numerical': 0.0040858018386108275, 'mean_word_length': 2.510752688172043, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5294329', 'n_tokens_mistral': 696, 'n_tokens_neox': 660, 'n_words': 186}