<commit_before>require File.join(File.dirname(__FILE__), '..', 'test_helper')

class ZeroOrMoreOfATerminalWithNodeClassDeclarationTest < CompilerTestCase
  
  class Foo < Treetop2::Parser::SyntaxNode
  end

  testing_expression '"foo"* <Foo>'
  
  it "successfully parses epsilon, returning an instance declared node class with a nested failure" do
    parse('') do |result|
      result.should be_success
      result.should be_an_instance_of(Foo)
      result.nested_failures.size.should == 1
      nested_failure = result.nested_failures.first
      nested_failure.index.should == 0
      nested_failure.expected_string.should == 'foo'
    end
  end
  
  it "successfully parses two of that terminal in a row, returning an instance of the declared node class with a nested failure representing the third attempt " do
    parse("foofoo") do |result|
      result.should be_success
      result.should be_an_instance_of(Foo)
      result.nested_failures.size.should == 1
      nested_failure = result.nested_failures.first
      nested_failure.index.should == 6
      nested_failure.expected_string.should == 'foo'
    end
  end
end<commit_msg>ns - Zero or more of a terminal tested with inline module<commit_after>require File.join(File.dirname(__FILE__), '..', 'test_helper')

class ZeroOrMoreOfATerminalWithNodeClassDeclarationTest < CompilerTestCase
  
  class Foo < Treetop2::Parser::SyntaxNode
  end

  testing_expression '"foo"* <Foo> { def a_method; end }'
  
  it "successfully parses epsilon, returning an instance declared node class with a nested failure" do
    parse('') do |result|
      result.should be_success
      result.should be_an_instance_of(Foo)
      result.should respond_to(:a_method)
      result.nested_failures.size.should == 1
      nested_failure = result.nested_failures.first
      nested_failure.index.should == 0
      nested_failure.expected_string.should == 'foo'
    end
  end
  
  it "successfully parses two of that terminal in a row, returning an instance of the declared node class with a nested failure representing the third attempt " do
    parse("foofoo") do |result|
      result.should be_success
      result.should be_an_instance_of(Foo)
      result.nested_failures.size.should == 1
      nested_failure = result.nested_failures.first
      nested_failure.index.should == 6
      nested_failure.expected_string.should == 'foo'
    end
  end
end
{'fraction_non_alphanumeric': 0.08006672226855713, 'fraction_numerical': 0.004170141784820684, 'mean_word_length': 3.7317554240631163, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '2268226', 'n_tokens_mistral': 706, 'n_tokens_neox': 689, 'n_words': 194}