<commit_before>require_relative '../lib/constraints'

describe Constraints::Eq do
  describe "#matches" do
    context "when matching an identical string" do
      let(:matches) { Constraints::Eq.new("hello").matches("hello") }

      it "has a single match" do; expect(matches.length).to eq 1; end
      it "matches every character" do; expect(matches.first.length).to eq 5; end
    end

    context "when matching a substring" do
      let(:matches) { Constraints::Eq.new("ll").matches("hello") }

      it "has one match" do; expect(matches.length).to eq 1; end
    end

    context "when matching a similar string" do
      let(:matches) { Constraints::Eq.new("hello").matches("hellp") }

      it "has no matches" do; expect(matches).to be_empty; end
    end

    context "when matching a completely different string" do
      let(:matches) { Constraints::Eq.new("hello").matches("fdas") }

      it "has no matches" do; expect(matches).to be_empty; end
    end
  end
end
#
# describe Constraints::And do
#   describe "#matches" do
#     context "when matching a single equal constraint" do
#       let(:constraints) {
#         Constraints::And.new([Constraints::Eq.new("hello")])
#       }
#
#       context "when matching with an identical string" do
#         let(:matches) { constraints.matches("hello") }
#
#         it "has a single match" do; expect(matches.length).to eq 1; end
#       end
#
#       context "when matching with an incorrect string" do
#         let(:matches) { constraints.matches("he") }
#
#         it "has no matches" do; expect(matches).to be_empty; end
#       end
#     end
#
#     context "when matching with two equal constraints" do
#       let(:constraints) {
#         Constraints::And.new([
#           Constraints::Eq.new("hello"),
#           Constraints::Eq.new("world"),
#         ])
#       }
#
#       context "when matching with a single correct string" do
#         let(:matches) { constraints.matches("world") }
#
#         it "has no matches" do; expect(matches).to be_empty; end
#       end
#
#       context "when matching with both strings correct" do
#         let(:matches) { constraints.matches("hello world") }
#
#         it "has two matches" do; expect(matches.length).to eq 2; end
#       end
#     end
#   end
# end

describe Constraints::Or do
  describe "#matches" do
    context "when matching a single equal constraint" do
      let(:constraints) {
        Constraints::Or.new([Constraints::Eq.new("hello")])
      }

      context "when the tokens are identical" do
        it "has a single match" do
          expect(constraints.matches("hello").length).to eq 1
        end<commit_msg>Fixed the 'Or' constraint tests<commit_after>require_relative '../lib/constraints'

describe Constraints::Eq do
  describe "#matches" do
    context "when matching an identical string" do
      let(:matches) { Constraints::Eq.new("hello").matches("hello") }

      it "has a single match" do; expect(matches.length).to eq 1; end
      it "matches every character" do; expect(matches.first.length).to eq 5; end
    end

    context "when matching a substring" do
      let(:matches) { Constraints::Eq.new("ll").matches("hello") }

      it "has one match" do; expect(matches.length).to eq 1; end
    end

    context "when matching a similar string" do
      let(:matches) { Constraints::Eq.new("hello").matches("hellp") }

      it "has no matches" do; expect(matches).to be_empty; end
    end

    context "when matching a completely different string" do
      let(:matches) { Constraints::Eq.new("hello").matches("fdas") }

      it "has no matches" do; expect(matches).to be_empty; end
    end
  end
end

describe Constraints::And do
  describe "#matches" do
    context "when matching a single equal constraint" do
      let(:constraints) {
        Constraints::And.new([Constraints::Eq.new("hello")])
      }

      context "when matching with an identical string" do
        let(:matches) { constraints.matches("hello") }

        it "has a single match" do; expect(matches.length).to eq 1; end
      end

      context "when matching with an incorrect string" do
        let(:matches) { constraints.matches("he") }

        it "has no matches" do; expect(matches).to be_empty; end
      end
    end

    context "when matching with two equal constraints" do
      let(:constraints) {
        Constraints::And.new([
          Constraints::Eq.new("hello"),
          Constraints::Eq.new("world"),
        ])
      }

      context "when matching with no strings correct" do
        let(:matches) { constraints.matches("abcdef") }

        it "has no matches" do; expect(matches).to be_empty; end
      end

      context "when matching with a single correct string" do
        let(:matches) { constraints.matches("world") }

        it "has no matches" do; expect(matches).to be_empty; end
      end

      context "when matching with both strings correct" do
        let(:matches) { constraints.matches("hello world") }

        it "has two matches" do; expect(matches.length).to eq 2; end
      end
    end
  end
end

describe Constraints::Or do
  describe "#matches" do
    context "when matching a single equal constraint" do
      let(:constraints) {
        Constraints::Or.new([Constraints::Eq.new("hello")])
      }

      context "when the tokens are identical" do
        it "has a single match" do
          expect(constraints.matches("hello").length).to eq 1
        end
{'fraction_non_alphanumeric': 0.12274898934215361, 'fraction_numerical': 0.002205071664829107, 'mean_word_length': 2.798325191905094, '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': '205843', 'n_tokens_mistral': 1567, 'n_tokens_neox': 1512, 'n_words': 502}