<commit_before>require 'spec_helper'

describe Autofold::Commander::Scaffold do
  let(:api) { Autofold::Commander::Scaffold }
  let(:action) { lambda { |input, expected| api.send(@action, input).should eq expected } }
  describe "#parse_to_simple_array" do
    before(:each) { @action = "parse_to_simple_array" }
    it "should take a fairly complicated input argument and smear it out to its parts" do
      input = "dog:cat:(bat+nig)+hay:(jew:mew+rat):(gay+man)"
      ex = []
      ex.push "dog:cat:bat"
      ex.push "dog:cat:nig"
      ex.push "hay:jew:mew:gay"
      ex.push "hay:jew:mew:man"
      ex.push "hay:rat:gay"
      ex.push "hay:rat:man"
      expected = ex.map { |e| e.split(":") }
      action.call input, expected 
    end
    it "should take a given input and produce out an array of arrays that are all simplified" do
      input = "dog:(bat:cat+snail):racoon"
      expected = ["dog:bat:cat:racoon".split(":"), "dog:snail:racoon".split(":")]
      action.call input, expected
    end
  end
  describe "#_break_to_chunks" do
    before :each do
      @action = "_break_to_chunks"
    end
    it "should trivially equal to just breaking on colons" do
      input = "dog:bat:cat:snail:racoon"
      expected = ["dog:bat:cat:snail:racoon".split(":")]
      action.call input, expected
    end
    it "should trivially equal to just breaking on colons" do
      input = "dog:(bat:cat+snail):racoon"
      expected = [["dog", "(bat:cat+snail)", "racoon"]]
      action.call input, expected
    end
  end
  describe "#_simplify_split" do
    before :each do
      @action = "_simplify_split"
    end
    it "should nominally just return a null double array" do
      input = []
      expected = [input]
      action.call input, expected
    end
    it "should take a slightly complexed row and split it to two" do
      input = ["cat+bat"]
      expected = [["cat"],["bat"]]
      action.call input, expected
    end
    it "should leave alone rows that are already simple" do
      input = ["dog", "cat+snail", "bat"]
      expected = ["dog:cat:bat".split(":"), "dog:snail:bat".split(":")]
      action.call input, expected
    end
    it "should be able to handle arbitrarily complicated expressions" do
      input = ["dog", "(bat:cat+snail)", "racoon"]
      expected = ["dog:bat:cat:racoon".split(":"), "dog:snail:racoon".split(":")]
      action.call input, expected
    end
  end
  describe "#_break_on_colon" do
    before :each do
      @action = "_break_on_colon"
    end
    it "should correctly split up the input string" do
      input = "dog:(bat:cat+snail):racoon"
      expected = ["dog","(bat:cat+snail)","racoon"]
      action.call input, expected
    end
    it "should properly handle the simple case" do
      input = "dog"
      expected = ["dog"]
      action.call input, expected
    end
    it "should a complex beginning case" do
      input = "(dog+cat:bat:hat):racoon:(snail+slug)"
      expected = ["(dog+cat:bat:hat)", "racoon", "(snail+slug)"]
      action.call input, expected
    end
  end
  describe "#_break_on_plus" do
    before :each do
      @action = "_break_on_plus"
    end
    it "should correctly split up the input string" do
      input = "dog:(bat:cat+snail):racoon"
      expected = ["dog:(bat:cat+snail):racoon"]
      action.call input, expected
    end
    it "should properly handle the simple case" do
      input = "dog"
      expected = ["dog"]
      action.call input, expected
    end
    it "should properly handle the simple case" do
      input = "dog:cat:snail"
      expected = ["dog:cat:snail"]
      action.call input, expected
    end
    it "should a complex beginning case" do
      input = "dog+cat:bat:hat:racoon:(snail+slug)"
      expected = ["dog","cat:bat:hat:racoon:(snail+slug)"]
      action.call input, expected
    end
  end
  describe "#_malformed_input" do
  end
end<commit_msg>put in a pending test for malformed<commit_after>require 'spec_helper'

describe Autofold::Commander::Scaffold do
  let(:api) { Autofold::Commander::Scaffold }
  let(:action) { lambda { |input, expected| api.send(@action, input).should eq expected } }
  describe "#parse_to_simple_array" do
    before(:each) { @action = "parse_to_simple_array" }
    it "should take a fairly complicated input argument and smear it out to its parts" do
      input = "dog:cat:(bat+nig)+hay:(jew:mew+rat):(gay+man)"
      ex = []
      ex.push "dog:cat:bat"
      ex.push "dog:cat:nig"
      ex.push "hay:jew:mew:gay"
      ex.push "hay:jew:mew:man"
      ex.push "hay:rat:gay"
      ex.push "hay:rat:man"
      expected = ex.map { |e| e.split(":") }
      action.call input, expected 
    end
    it "should take a given input and produce out an array of arrays that are all simplified" do
      input = "dog:(bat:cat+snail):racoon"
      expected = ["dog:bat:cat:racoon".split(":"), "dog:snail:racoon".split(":")]
      action.call input, expected
    end
  end
  describe "#_break_to_chunks" do
    before :each do
      @action = "_break_to_chunks"
    end
    it "should trivially equal to just breaking on colons" do
      input = "dog:bat:cat:snail:racoon"
      expected = ["dog:bat:cat:snail:racoon".split(":")]
      action.call input, expected
    end
    it "should trivially equal to just breaking on colons" do
      input = "dog:(bat:cat+snail):racoon"
      expected = [["dog", "(bat:cat+snail)", "racoon"]]
      action.call input, expected
    end
  end
  describe "#_simplify_split" do
    before :each do
      @action = "_simplify_split"
    end
    it "should nominally just return a null double array" do
      input = []
      expected = [input]
      action.call input, expected
    end
    it "should take a slightly complexed row and split it to two" do
      input = ["cat+bat"]
      expected = [["cat"],["bat"]]
      action.call input, expected
    end
    it "should leave alone rows that are already simple" do
      input = ["dog", "cat+snail", "bat"]
      expected = ["dog:cat:bat".split(":"), "dog:snail:bat".split(":")]
      action.call input, expected
    end
    it "should be able to handle arbitrarily complicated expressions" do
      input = ["dog", "(bat:cat+snail)", "racoon"]
      expected = ["dog:bat:cat:racoon".split(":"), "dog:snail:racoon".split(":")]
      action.call input, expected
    end
  end
  describe "#_break_on_colon" do
    before :each do
      @action = "_break_on_colon"
    end
    it "should correctly split up the input string" do
      input = "dog:(bat:cat+snail):racoon"
      expected = ["dog","(bat:cat+snail)","racoon"]
      action.call input, expected
    end
    it "should properly handle the simple case" do
      input = "dog"
      expected = ["dog"]
      action.call input, expected
    end
    it "should a complex beginning case" do
      input = "(dog+cat:bat:hat):racoon:(snail+slug)"
      expected = ["(dog+cat:bat:hat)", "racoon", "(snail+slug)"]
      action.call input, expected
    end
  end
  describe "#_break_on_plus" do
    before :each do
      @action = "_break_on_plus"
    end
    it "should correctly split up the input string" do
      input = "dog:(bat:cat+snail):racoon"
      expected = ["dog:(bat:cat+snail):racoon"]
      action.call input, expected
    end
    it "should properly handle the simple case" do
      input = "dog"
      expected = ["dog"]
      action.call input, expected
    end
    it "should properly handle the simple case" do
      input = "dog:cat:snail"
      expected = ["dog:cat:snail"]
      action.call input, expected
    end
    it "should a complex beginning case" do
      input = "dog+cat:bat:hat:racoon:(snail+slug)"
      expected = ["dog","cat:bat:hat:racoon:(snail+slug)"]
      action.call input, expected
    end
  end
  describe "#_malformed_input" do
    it "should have tests!"
  end
end
{'fraction_non_alphanumeric': 0.1332392921261862, 'fraction_numerical': 0.0, 'mean_word_length': 3.005649717514124, 'pattern_counts': {'":': 16, '<': 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': '4926111', 'n_tokens_mistral': 2564, 'n_tokens_neox': 2517, 'n_words': 739}