<commit_before>
require 'spec_helper'


describe 'memo feature' do

  class MemoParser < Neg::Parser

    exp == num + `+` + num | num + `-` + num
    num == _('0-9') * 1
  end

  def parse(s, opts={})

    MemoParser.parse(s, opts)
  end

  it 'parses additions' do

    parse('12+34')[2].should == true
  end

  it 'parses substractions' do

    parse('12-34')[2].should == true
  end
end
<commit_msg>make the memo spec a real spec<commit_after>
require 'spec_helper'


describe 'memo feature' do

  class MemoParser < Neg::Parser

    exp == num + `+` + num | num + `-` + num
    num == _('0-9') * 1
  end

  def parse(s, opts={})

    i = Neg::Input(s)

    r = MemoParser.parse(i, opts)

    [ i, r ]
  end

  it 'parses additions' do

    i, r = parse('12+34')

    r[2].should ==
      true
    i.instance_variable_get(:@memos).keys.sort.should ==
      %w[ exp--0 num--0 num--3 ]
  end

  it 'parses substractions' do

    i, r = parse('12-34')

    r[2].should ==
      true
    i.instance_variable_get(:@memos).keys.sort.should ==
      %w[ exp--0 num--0 num--3 ]
  end
end

{'fraction_non_alphanumeric': 0.1669741697416974, 'fraction_numerical': 0.02952029520295203, 'mean_word_length': 2.390625, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4521580', 'n_tokens_mistral': 450, 'n_tokens_neox': 413, 'n_words': 107}