<commit_before>
use("ispec")

describe(Hook,
  it("should have the correct kind",
    Hook should have kind("Hook")
  )

  describe("connectedObjects",
    it("should return the connected objects for that hook",
      x = Origin mimic
      y = Origin mimic
      z = Origin mimic

      Hook into(x) connectedObjects[0] should be(x)
      Hook into(x, y) connectedObjects[0] should be(x)
      Hook into(x, y) connectedObjects[1] should be(y)
      Hook into(x, y, z) connectedObjects[0] should be(x)
      Hook into(x, y, z) connectedObjects[1] should be(y)
      Hook into(x, y, z) connectedObjects[2] should be(z)

      Hook into(x, y, z) connectedObjects length should == 3
    )
  )

  describe("into",
    it("should return a new hook object",
      xx = Origin mimic
      yy = Hook into(xx)
      yy should mimic(Hook)
      yy should not be(Hook)
    )

    it("should take one or more arguments",
      Hook into(Origin mimic)
      Hook into(Origin mimic, Origin mimic)
      Hook into(Origin mimic, Origin mimic, Origin mimic)
      Hook into(Origin mimic, Origin mimic, Origin mimic, Origin mimic)
      Hook into(Origin mimic, Origin mimic, Origin mimic, Origin mimic, Origin mimic)

      fn(Hook into()) should signal(Condition Error Invocation TooFewArguments)
    )
  )

  describe("into!",
    it("should add itself to the mimic chain of the first argument and bind it to the second object")
  )

  describe("hook!",
    it("should add a new observed object to the receiver")
  )

  describe("cellAdded",
    it("should be called on the hook when a cell is added on the observed object",
      xx = Origin mimic
      yy = Hook into(xx)
      yy invoked = 0
      yy cellAdded = method(obj, _,  @invoked++)
      xx bar = "hello"
      yy invoked should == 1
      xx flux = method(nil)
      yy invoked should == 2
    )

    it("should be called after the cell has been added",
      xx = Origin mimic
      yy = Hook into(xx)
      yy cellAdded = fnx(obj, _,
        xx fox should == "blarg"
      )
      xx fox = "blarg"
    )

    it("should give the object that has been updated",
      xx = Origin mimic
      yy = Hook into(xx)
      yy cellAdded = fnx(obj, _,
        obj should be(xx)
      )
      xx fox = "blarg"
    )

    it("should give the name of the added cell to the hook as an argument",
      xx = Origin mimic
      yy = Hook into(xx)
      yy cellAdded = fnx(obj, sym,
        sym should == :fox
      )
      xx fox = "blarg"
    )

    it("should fire on more than one hook if available",
      xx = Origin mimic
      yy = Origin mimic
      zz = Hook into(xx, yy)
      zz invoked = 0
      zz cellAdded = method(_, _,
        @invoked++
      )
      xx blah = "arg"
      yy foo = "ax"
      yy muuh = "wow"
      zz invoked should == 3
    )

    it("should not fire when a cell is updated")
  )

  describe("cellRemoved",
    it("should have tests")
  )

  describe("cellChanged",
    it("should be called on the hook when a cell is added on the observed object",
      xx = Origin mimic
      yy = Hook into(xx)
      yy invoked = 0
      yy cellChanged = method(@invoked++)
      xx bar = "hello"
      yy invoked should == 1<commit_msg>A test to make sure cellAdded doesn't fire for updates<commit_after>
use("ispec")

describe(Hook,
  it("should have the correct kind",
    Hook should have kind("Hook")
  )

  describe("connectedObjects",
    it("should return the connected objects for that hook",
      x = Origin mimic
      y = Origin mimic
      z = Origin mimic

      Hook into(x) connectedObjects[0] should be(x)
      Hook into(x, y) connectedObjects[0] should be(x)
      Hook into(x, y) connectedObjects[1] should be(y)
      Hook into(x, y, z) connectedObjects[0] should be(x)
      Hook into(x, y, z) connectedObjects[1] should be(y)
      Hook into(x, y, z) connectedObjects[2] should be(z)

      Hook into(x, y, z) connectedObjects length should == 3
    )
  )

  describe("into",
    it("should return a new hook object",
      xx = Origin mimic
      yy = Hook into(xx)
      yy should mimic(Hook)
      yy should not be(Hook)
    )

    it("should take one or more arguments",
      Hook into(Origin mimic)
      Hook into(Origin mimic, Origin mimic)
      Hook into(Origin mimic, Origin mimic, Origin mimic)
      Hook into(Origin mimic, Origin mimic, Origin mimic, Origin mimic)
      Hook into(Origin mimic, Origin mimic, Origin mimic, Origin mimic, Origin mimic)

      fn(Hook into()) should signal(Condition Error Invocation TooFewArguments)
    )
  )

  describe("into!",
    it("should add itself to the mimic chain of the first argument and bind it to the second object")
  )

  describe("hook!",
    it("should add a new observed object to the receiver")
  )

  describe("cellAdded",
    it("should be called on the hook when a cell is added on the observed object",
      xx = Origin mimic
      yy = Hook into(xx)
      yy invoked = 0
      yy cellAdded = method(obj, _,  @invoked++)
      xx bar = "hello"
      yy invoked should == 1
      xx flux = method(nil)
      yy invoked should == 2
    )

    it("should be called after the cell has been added",
      xx = Origin mimic
      yy = Hook into(xx)
      yy cellAdded = fnx(obj, _,
        xx fox should == "blarg"
      )
      xx fox = "blarg"
    )

    it("should give the object that has been updated",
      xx = Origin mimic
      yy = Hook into(xx)
      yy cellAdded = fnx(obj, _,
        obj should be(xx)
      )
      xx fox = "blarg"
    )

    it("should give the name of the added cell to the hook as an argument",
      xx = Origin mimic
      yy = Hook into(xx)
      yy cellAdded = fnx(obj, sym,
        sym should == :fox
      )
      xx fox = "blarg"
    )

    it("should fire on more than one hook if available",
      xx = Origin mimic
      yy = Origin mimic
      zz = Hook into(xx, yy)
      zz invoked = 0
      zz cellAdded = method(_, _,
        @invoked++
      )
      xx blah = "arg"
      yy foo = "ax"
      yy muuh = "wow"
      zz invoked should == 3
    )

    it("should not fire when a cell is updated",
      xx = Origin mimic
      yy = Hook into(xx)
      xx blarg = "hello"
      yy invoked = 0
      yy cellAdded = method(obj, _,  @invoked++)
      xx blarg = "goodbye"
      yy invoked should == 0
    )
  )

  describe("cellRemoved",
    it("should have tests")
  )

  describe("cellChanged",
    it("should be called on the hook when a cell is added on the observed object",
      xx = Origin mimic
      yy = Hook into(xx)
      yy invoked = 0
      yy cellChanged = method(@invoked++)
      xx bar = "hello"
      yy invoked should == 1
{'fraction_non_alphanumeric': 0.09724106739032112, 'fraction_numerical': 0.004522840343735866, 'mean_word_length': 2.27928818586258, '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': '304237', 'n_tokens_mistral': 2117, 'n_tokens_neox': 1955, 'n_words': 791}