<commit_before>require 'generator/exercise_case'

class RunLengthEncodingCase < Generator::ExerciseCase

  def name
    super.sub('test_',"test_#{property}_")
  end

  def workload
    indent_lines([
      "input = '#{input}'",
      "output = '#{expected}'",
      assertion
    ], 4)
  end

  private

  def assertion
    if property == 'consistency'
      'assert_equal output,
                 RunLengthEncoding.decode(RunLengthEncoding.encode(input))'
    else
      "assert_equal output, RunLengthEncoding.#{property}(input)"
    end
  end

end<commit_msg>run-length-encoding: Update generator<commit_after>require 'generator/exercise_case'

class RunLengthEncodingCase < Generator::ExerciseCase
  def workload
    send("#{property}_assertion")
  end

  def test_name
    super.sub('test_',"test_#{property}_")
  end

  private

  def standard_assertion
    [
      "input = '#{string}'",
      "output = '#{expected}'",
      "assert_equal output, RunLengthEncoding.#{property}(input)"
    ]
  end

  alias_method :encode_assertion, :standard_assertion
  alias_method :decode_assertion, :standard_assertion

  def consistency_assertion
    [
      "input = '#{string}'",
      "encoded = RunLengthEncoding.encode(input)",
      "assert_equal input, RunLengthEncoding.decode(encoded)"
    ]
  end
end
{'fraction_non_alphanumeric': 0.11791730474732007, 'fraction_numerical': 0.0007656967840735069, 'mean_word_length': 3.6347517730496453, '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': '5565205', 'n_tokens_mistral': 406, 'n_tokens_neox': 393, 'n_words': 77}