<commit_before>require 'spec_helper'

describe Fid, "#diff" do
  it 'returns {} for two empty objects' do
    Fid.diff({}, {}).should == {}
  end

  it 'returns "<" for item not in 2nd object' do
    Fid.diff({'apples' => 1}, {}).should == {'apples' => {'<' => 1}}
  end

  it 'returns ">" for item not in 1st object' do
    Fid.diff({}, {'bananas' => 3}).should == {'bananas' => {'>' => 3}}
  end

  it 'returns "<" and "> for changed item' do
    Fid.diff({'bananas' => 5}, {'bananas' => 3})
       .should == {'bananas' => {'<' => 5, '>' => 3}}
  end

  it 'omits unchanged item' do
    Fid.diff({'bananas' => 5}, {'bananas' => 5}).should == {}
  end

  it 'correctly returns diff from README' do
    Fid.diff({
               "pears"   => 1,
               "apples"  => {"red" => 2, "green" => 1},
               "bananas" => 5,
               "mangos"  => 2
             },
             {
               "apples"  => {"golden" => 1},
               "bananas" => 3,
               "oranges" => 6,
               "mangos"  => 2
             })
       .should == {
                    "apples"  => {
                                   ">" => {"golden" => 1},
                                   "<" => {"red" => 2, "green" => 1}
                                 },
                    "bananas" => {">" => 3, "<" => 5},
                    "oranges" => {">" => 6},
                    "pears"   => {"<" => 1}
                  }
  end
end

describe Fid, "#patch" do
  it 'returns {} for two empty objects' do
    Fid.patch({}, {}).should == {}
  end

  it 'removes "<" item in patch' do
    Fid.patch({'apples' => 1}, {'apples' => {'<' => 1}}).should == {}
  end

  #it 'returns ">" for item not in 1st object' do
  #  Fid.diff({}, {'bananas' => 3}).should == {'bananas' => {'>' => 3}}
  #end

  #it 'returns "<" and "> for changed item' do
  #  Fid.diff({'bananas' => 5}, {'bananas' => 3})
  #     .should == {'bananas' => {'<' => 5, '>' => 3}}
  #end

  #it 'omits unchanged item' do
  #  Fid.diff({'bananas' => 5}, {'bananas' => 5}).should == {}
  #end

  #it 'correctly returns diff from README' do
  #  Fid.diff({
  #             "pears"   => 1,
  #             "apples"  => {"red" => 2, "green" => 1},
  #             "bananas" => 5,
  #             "mangos"  => 2
  #           },
  #           {
  #             "apples"  => {"golden" => 1},
  #             "bananas" => 3,
  #             "oranges" => 6,
  #             "mangos"  => 2
  #           })
  #     .should == {
  #                  "apples"  => {
  #                                 ">" => {"golden" => 1},
  #                                 "<" => {"red" => 2, "green" => 1}
  #                               },
  #                  "bananas" => {">" => 3, "<" => 5},
  #                  "oranges" => {">" => 6},
  #                  "pears"   => {"<" => 1}
  #                }
  #end
end
<commit_msg>add remaining examples<commit_after>require 'spec_helper'

describe Fid, "#diff" do
  it 'returns {} for two empty objects' do
    Fid.diff({}, {}).should == {}
  end

  it 'returns "<" for item not in 2nd object' do
    Fid.diff({'apples' => 1}, {}).should == {'apples' => {'<' => 1}}
  end

  it 'returns ">" for item not in 1st object' do
    Fid.diff({}, {'bananas' => 3}).should == {'bananas' => {'>' => 3}}
  end

  it 'returns "<" and "> for changed item' do
    Fid.diff({'bananas' => 5}, {'bananas' => 3})
       .should == {'bananas' => {'<' => 5, '>' => 3}}
  end

  it 'omits unchanged item' do
    Fid.diff({'bananas' => 5}, {'bananas' => 5}).should == {}
  end

  it 'correctly returns diff from README' do
    Fid.diff({
               "pears"   => 1,
               "apples"  => {"red" => 2, "green" => 1},
               "bananas" => 5,
               "mangos"  => 2
             },
             {
               "apples"  => {"golden" => 1},
               "bananas" => 3,
               "oranges" => 6,
               "mangos"  => 2
             })
       .should == {
                    "apples"  => {
                                   ">" => {"golden" => 1},
                                   "<" => {"red" => 2, "green" => 1}
                                 },
                    "bananas" => {">" => 3, "<" => 5},
                    "oranges" => {">" => 6},
                    "pears"   => {"<" => 1}
                  }
  end
end

describe Fid, "#patch" do
  it 'returns {} for two empty objects' do
    Fid.patch({}, {}).should == {}
  end

  it 'removes "<" item in patch' do
    Fid.patch({'apples' => 1}, {'apples' => {'<' => 1}}).should == {}
  end

  it 'adds ">" item in patch' do
    Fid.patch({}, {'bananas' => {'>' => 3}}).should == {'bananas' => 3}
  end

  it 'replaces "<" and ">" item in patch' do
    Fid.patch({'bananas' => 5}, {'bananas' => {'<' => 5, '>' => 3}})
       .should == {'bananas' => 3}
  end

  it 'leaves unchanged with empty patch' do
    Fid.patch({'bananas' => 5}, {}).should == {'bananas' => 5}
  end

  it 'correctly patches with diff from README' do
    Fid.patch({
                "pears"   => 1,
                "apples"  => {"red" => 2, "green" => 1},
                "bananas" => 5,
                "mangos"  => 2
              },
              {
                "apples"  => {
                               ">" => {"golden" => 1},
                               "<" => {"red" => 2, "green" => 1}
                             },
                "bananas" => {">" => 3, "<" => 5},
                "oranges" => {">" => 6},
                "pears"   => {"<" => 1}
              })
       .should == {
                    "apples"  => {"golden" => 1},
                    "bananas" => 3,
                    "oranges" => 6,
                    "mangos"  => 2
                  }
  end
end

{'fraction_non_alphanumeric': 0.2175732217573222, 'fraction_numerical': 0.01900278940027894, 'mean_word_length': 1.2729793977812995, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 179, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6767156', 'n_tokens_mistral': 2062, 'n_tokens_neox': 1892, 'n_words': 459}