<commit_before>defmodule Elixre.TesterTest do
  use ExUnit.Case, async: true

  @subject Elixre.Tester

  test ".test with invalid regex" do
    result   = @subject.test("?", "foo")
    expected = %{ error: ["nothing to repeat", 0] }

    assert expected == result
  end


  test ".text with valid regex and one subject" do
    result   = @subject.test("o+(.)?", "foobar")
    expected = %{
      regex: "~r/o+(.)?/",
      results: [
        %{subject: "foobar", result: ["oob", "b"]}
      ]
    }

    assert expected == result
  end

  test ".text with valid regex and multiple subjects" do
    result   = @subject.test("(?:f|b)(.+)", ["foo", "bar", "baz"])
    expected = %{
      regex: "~r/(?:f|b)(.+)/",
      results: [
        %{result: ["foo", "oo"], subject: "foo"},
        %{result: ["bar", "ar"], subject: "bar"},
        %{result: ["baz", "az"], subject: "baz"}
      ]
    }

  assert expected == result
  end
end

defmodule Elixre.TesterTestWithShould do
  use ExUnit.Case, async: true
  use ShouldI

  @subject Elixre.Tester

  with "an invalid regex" do
    should "return error key with explanatory val" do
      result   = @subject.test("?", "foo")
      expected = %{ error: ["nothing to repeat", 0] }
      assert expected == result
    end
  end


  with "a valid regex" do
    should "return correct results for 1 subject" do
      result   = @subject.test("o+(.)?", "foobar")
      expected = %{
        regex: "~r/o+(.)?/",
        results: [
          %{subject: "foobar", result: ["oob", "b"]}
        ]
      }
      assert expected == result
    end

    should "return correct results for several subjects" do
      result   = @subject.test("(?:f|b)(.+)", ["foo", "bar", "baz"])
      expected = %{
        regex: "~r/(?:f|b)(.+)/",
        results: [
          %{result: ["foo", "oo"], subject: "foo"},
          %{result: ["bar", "ar"], subject: "bar"},
          %{result: ["baz", "az"], subject: "baz"}
        ]
      }

      assert expected == result
    end
  end
end<commit_msg>Continue ShouldIfication<commit_after>defmodule Elixre.TesterTest do
  use ExUnit.Case, async: true
  use ShouldI
  import ShouldI.Matchers.Context

  @subject Elixre.Tester

  with "an invalid regex" do
    setup context do
      @subject.test("?", "foo")
    end

    should_not_have_key :results
    should_not_have_key :regex
    should_assign_key error: ["nothing to repeat", 0]
  end


  with "a valid regex" do
    with "one subject" do
      setup context do
        @subject.test("o+(.)?", "foobar")
      end

      should_not_have_key :error
      should_assign_key regex: "~r/o+(.)?/"
      should_assign_key results: [%{subject: "foobar", result: ["oob", "b"]}]
    end

    with "multiple subjects" do
      setup context do
        @subject.test("(?:f|b)(.+)", ["foo", "bar", "baz"])
      end

      should_not_have_key :error
      should_assign_key regex: "~r/(?:f|b)(.+)/"
      should_assign_key results: [
        %{result: ["foo", "oo"], subject: "foo"},
        %{result: ["bar", "ar"], subject: "bar"},
        %{result: ["baz", "az"], subject: "baz"}
      ]
    end
  end
end
{'fraction_non_alphanumeric': 0.17718679910285165, 'fraction_numerical': 0.001281640499839795, 'mean_word_length': 2.468888888888889, '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': '3367935', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1011, 'n_words': 296}