<commit_before>require "spec_helper"
require "hamster/set"

describe Hamster::Set do
  describe "#inspect" do
    [
      [[], "Hamster::Set[]"],
      [["A"], 'Hamster::Set["A"]'],
    ].each do |values, expected|

      describe "on #{values.inspect}" do
        before do
          @original = Hamster.set(*values)
          @result   = @original.inspect
        end

        it "returns #{expected.inspect}" do
          @result.should == expected
        end

        it "returns a string which can be eval'd to get an equivalent set" do
          eval(@result).should eql(@original)
        end
      end
    end

    describe 'on ["A", "B", "C"]' do
      before do
        @original = Hamster.set("A", "B", "C")
        @result   = @original.inspect
      end

      it "returns a programmer-readable representation of the set contents" do
        @result.should match(/^Hamster::Set\["[A-C]", "[A-C]", "[A-C]"\]$/)
      end

      it "returns a string which can be eval'd to get an equivalent set" do
        eval(@result).should eql(@original)
      end
    end

    context "from a subclass" do
      before do
        MySet     = Class.new(Hamster::Set)
        @original = MySet[1, 2]
        @result   = @original.inspect
      end

      it "returns a programmer-readable representation of the set contents" do
        @result.should match(/^MySet\[[1-2], [1-2]\]$/)
      end

      it "returns a string which can be eval'd to get an equivalent set" do
        eval(@result).should eql(@original)
      end<commit_msg>Updated style of Set#inspect spec<commit_after>require "spec_helper"
require "hamster/set"

describe Hamster::Set do
  describe "#inspect" do
    [
      [[], "Hamster::Set[]"],
      [["A"], 'Hamster::Set["A"]'],
    ].each do |values, expected|
      describe "on #{values.inspect}" do
        let(:set) { Hamster.set(*values) }

        it "returns #{expected.inspect}" do
          set.inspect.should == expected
        end

        it "returns a string which can be eval'd to get an equivalent set" do
          eval(set.inspect).should eql(set)
        end
      end
    end

    describe 'on ["A", "B", "C"]' do
      let(:set) { Hamster.set("A", "B", "C") }

      it "returns a programmer-readable representation of the set contents" do
        set.inspect.should match(/^Hamster::Set\["[A-C]", "[A-C]", "[A-C]"\]$/)
      end

      it "returns a string which can be eval'd to get an equivalent set" do
        eval(set.inspect).should eql(set)
      end
    end

    context "from a subclass" do
      MySet = Class.new(Hamster::Set)
      let(:set) { MySet[1, 2] }

      it "returns a programmer-readable representation of the set contents" do
        set.inspect.should match(/^MySet\[[1-2], [1-2]\]$/)
      end

      it "returns a string which can be eval'd to get an equivalent set" do
        eval(set.inspect).should eql(set)
      end
{'fraction_non_alphanumeric': 0.14008993427879626, 'fraction_numerical': 0.0041508128675198895, 'mean_word_length': 2.2567567567567566, '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': '112474', 'n_tokens_mistral': 930, 'n_tokens_neox': 882, 'n_words': 284}