<commit_before>require 'wordlist/mutator'

require 'spec_helper'

describe Mutator do
  it "should replace matched text with a byte" do
    mutator = Mutator.new('o',0x41)
    mutator.replace('o').should == 'A'
  end

  it "should replace matched text with a String" do
    mutator = Mutator.new('o','0')
    mutator.replace('o').should == '0'
  end

  it "should replace matched text using a proc" do
    mutator = Mutator.new('o',proc { |match| match * 2 })
    mutator.replace('o').should == 'oo'
  end

  it "should iterate over every possible substitution" do
    remaining_mutations = ['lolol', 'l0lo', 'lol0l', 'l0l0l']

    mutator = Mutator.new(/o/,'0')
    mutator.each('lolol') do |word|
      puts word
      remaining_mutations.delete(word)
    end

    remaining_mutations.should == []
  end

  it "should iterate over the original word, if no matches were found" do
    mutator = Mutator.new('x','0')

    mutator.each('hello') do |word|
      word.should == 'hello'
    end
  end<commit_msg>Fixed a spec.<commit_after>require 'wordlist/mutator'

require 'spec_helper'

describe Mutator do
  it "should replace matched text with a byte" do
    mutator = Mutator.new('o',0x41)
    mutator.replace('o').should == 'A'
  end

  it "should replace matched text with a String" do
    mutator = Mutator.new('o','0')
    mutator.replace('o').should == '0'
  end

  it "should replace matched text using a proc" do
    mutator = Mutator.new('o',proc { |match| match * 2 })
    mutator.replace('o').should == 'oo'
  end

  it "should iterate over every possible substitution" do
    remaining = ['lolol', 'l0lol', 'lol0l', 'l0l0l']

    mutator = Mutator.new(/o/,'0')
    mutator.each('lolol') do |mutation|
      remaining.delete(mutation)
    end

    remaining.should == []
  end

  it "should iterate over the original word, if no matches were found" do
    mutator = Mutator.new('x','0')

    mutator.each('hello') do |word|
      word.should == 'hello'
    end
  end
{'fraction_non_alphanumeric': 0.13808801213960548, 'fraction_numerical': 0.012139605462822459, 'mean_word_length': 3.2629310344827585, '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': '1316518', 'n_tokens_mistral': 687, 'n_tokens_neox': 667, 'n_words': 195}