<commit_before>describe "shpec"
  describe "basic operations"
    it "asserts equality"
      assert equal "foo" "foo"
    end

    it "asserts inequality"
      assert unequal "foo" "bar"
    end

    it "asserts less than"
      assert lt 5 7
    end

    it "asserts greater than"
      assert gt 7 5
    end

    it "asserts presence"
      assert present "something"
    end

    it "asserts blankness"
      assert blank ""
    end
  end

  describe "equality matcher"
    it "handles newlines properly"
      string_with_newline_char="new\nline"
      multiline_string='new
line'
      assert equal "$multiline_string" "$string_with_newline_char"
    end

    it "compares strings containing single quotes"
      assert equal "a' b" "a' b"
    end

    it "compares strings containing double quotes"
      assert equal 'a" b' 'a" b'
    end
  end

  describe "lt matcher"
    it "handles numbers of different length properly"
      assert lt 5 17
    end
  end

  describe "gt matcher"
    it "handles numbers of different length properly"
      assert gt 17 5
    end
  end

  describe "glob matcher"
    it "is essentially 'assert equal' if no special characters are used"
      assert glob "word" "word"
    end

    it "supports multi-character wildcards"
      assert glob "impartially" "*partial*"
    end

    it "supports single-character wildcards"
      assert glob "word" "wo?d"
      assert no_glob "world" "wo?d"
    end

    it "supports character lists"
      assert glob "foo" "[a-f]oo"
      assert no_glob "foo" "[g-z]oo"
      assert glob "boo" "[a-z]oo"
      assert glob "bar" "[a-z]*"
    end

    it "asserts globs which are not compatible with grep"
      assert glob "loooooooooooooooooong" "l*ng"
    end

    it "asserts lack of globs"
      assert no_glob "zebra" "giraffe"
    end
  end

  describe "grep matcher"
    it "handles regex properly"
        assert grep "hello" "^[a-z]*$"
    end
  end

  describe "no_grep matcher"
    it "handles regex properly"
        assert no_grep "hello1" "^[a-z]*$"
    end
  end

  describe "egrep matcher"
    it "handles regex extended properly"
        assert egrep "hello" "^[a-z]+$"
    end
  end

  describe "no_egrep matcher"
    it "handles regex extended properly"
        assert no_egrep "hello1" "^[a-z]+$"
    end
  end

  describe "passing through to the test builtin"
    it "asserts an arbitrary algebraic test"
      assert test "[ 5 -lt 10 ]"
    end
  end

  describe "stubbing commands"
    it "stubs to the null command by default"
      stub_command "false"
      false # doesn't do anything
      assert equal "$?" 0
      unstub_command "false"
    end
    it "preserves the original working of the stub"
      false
      assert equal "$?" 1
    end

    it "accepts an optional function body"
      stub_command "curl" "echo 'stubbed body'"<commit_msg>Adds some more coverage around the grep matchers<commit_after>describe "shpec"
  describe "basic operations"
    it "asserts equality"
      assert equal "foo" "foo"
    end

    it "asserts inequality"
      assert unequal "foo" "bar"
    end

    it "asserts less than"
      assert lt 5 7
    end

    it "asserts greater than"
      assert gt 7 5
    end

    it "asserts presence"
      assert present "something"
    end

    it "asserts blankness"
      assert blank ""
    end
  end

  describe "equality matcher"
    it "handles newlines properly"
      string_with_newline_char="new\nline"
      multiline_string='new
line'
      assert equal "$multiline_string" "$string_with_newline_char"
    end

    it "compares strings containing single quotes"
      assert equal "a' b" "a' b"
    end

    it "compares strings containing double quotes"
      assert equal 'a" b' 'a" b'
    end
  end

  describe "lt matcher"
    it "handles numbers of different length properly"
      assert lt 5 17
    end
  end

  describe "gt matcher"
    it "handles numbers of different length properly"
      assert gt 17 5
    end
  end

  describe "glob matcher"
    it "is essentially 'assert equal' if no special characters are used"
      assert glob "word" "word"
    end

    it "supports multi-character wildcards"
      assert glob "impartially" "*partial*"
    end

    it "supports single-character wildcards"
      assert glob "word" "wo?d"
      assert no_glob "world" "wo?d"
    end

    it "supports character lists"
      assert glob "foo" "[a-f]oo"
      assert no_glob "foo" "[g-z]oo"
      assert glob "boo" "[a-z]oo"
      assert glob "bar" "[a-z]*"
    end

    it "asserts globs which are not compatible with grep"
      assert glob "loooooooooooooooooong" "l*ng"
    end

    it "asserts lack of globs"
      assert no_glob "zebra" "giraffe"
    end
  end

  describe "grep matcher"
    it "supports matching regular expressions"
      assert grep "hello" "^[a-z]*$"
    end

    it "supports lack of matching regular expressions"
      assert no_grep "hello1" "^[a-z]*$"
    end

    it "does not match multiple lines in a single expression"
      output="$(. $SHPEC_ROOT/etc/multi_assert_example)"

      assert grep "$output" "a assert"
      assert grep "$output" "multi assert"
      assert no_grep "$output" "a assert.*multi assert"
    end
  end

  describe "egrep matcher"
    it "supports matching extended regular expressions"
      assert egrep "hello" "^[a-z]+$"
    end

    it "supports lack of matching extended regular expressions"
      assert no_egrep "hello1" "^[a-z]+$"
    end
  end

  describe "passing through to the test builtin"
    it "asserts an arbitrary algebraic test"
      assert test "[ 5 -lt 10 ]"
    end
  end

  describe "stubbing commands"
    it "stubs to the null command by default"
      stub_command "false"
      false # doesn't do anything
      assert equal "$?" 0
      unstub_command "false"
    end
    it "preserves the original working of the stub"
      false
      assert equal "$?" 1
    end

    it "accepts an optional function body"
      stub_command "curl" "echo 'stubbed body'"
{'fraction_non_alphanumeric': 0.08445777111444278, 'fraction_numerical': 0.00566383474929202, 'mean_word_length': 2.4886693782684484, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '312473', 'n_tokens_mistral': 1966, 'n_tokens_neox': 1860, 'n_words': 705}