<commit_before>var originalLookup = Ember.lookup;

var obj, moduleOpts = {
  setup: function() {
    obj = {
      foo: {
        bar: {
          baz: { biff: 'BIFF' }
        }
      }

    };

    Ember.lookup = {
      Foo: {
        bar: {
          baz: { biff: 'FooBiff' }
        }
      },

      $foo: {
        bar: {
          baz: { biff: '$FOOBIFF' }
        }
      }
    };
  },

  teardown: function() {
    obj = null;
    Ember.lookup = originalLookup;
  }
};

module('Ember.set with path', moduleOpts);

test('[Foo, bar] -> Foo.bar', function() {
  Ember.lookup.Foo = {toString: function() { return 'Foo'; }}; // Behave like an Ember.Namespace

  Ember.set(Ember.lookup.Foo, 'bar', 'baz');
  equal(Ember.get(Ember.lookup.Foo, 'bar'), 'baz');
});

// ..........................................................
// LOCAL PATHS
//

test('[obj, foo] -> obj.foo', function() {
  Ember.set(obj, 'foo', "BAM");
  equal(Ember.get(obj, 'foo'), "BAM");
});

test('[obj, foo.bar] -> obj.foo.bar', function() {
  Ember.set(obj, 'foo.bar', "BAM");
  equal(Ember.get(obj, 'foo.bar'), "BAM");
});

test('[obj, this.foo] -> obj.foo', function() {
  Ember.set(obj, 'this.foo', "BAM");
  equal(Ember.get(obj, 'foo'), "BAM");
});

test('[obj, this.foo.bar] -> obj.foo.bar', function() {
  Ember.set(obj, 'this.foo.bar', "BAM");
  equal(Ember.get(obj, 'foo.bar'), "BAM");
});

// ..........................................................
// NO TARGET
//

test('[null, Foo.bar] -> Foo.bar', function() {
  Ember.set(null, 'Foo.bar', "BAM");
  equal(Ember.get(Ember.lookup.Foo, 'bar'), "BAM");
});

// ..........................................................
// DEPRECATED
//

module("Ember.set with path - deprecated", {
  setup: function() {
    Ember.TESTING_DEPRECATION = true;
    moduleOpts.setup();
  },
  teardown: function() {
    Ember.TESTING_DEPRECATION = false;
    moduleOpts.teardown();
  }
});

test('[obj, foo.baz.bat] -> EXCEPTION', function() {
  raises(function() {
    Ember.set(obj, 'foo.baz.bat', "BAM");
  }, Error);
});

test('[obj, foo.baz.bat] -> EXCEPTION', function() {
  Ember.trySet(obj, 'foo.baz.bat', "BAM");
  ok(true, "does not raise");
});<commit_msg>Adds truncation tests<commit_after>var originalLookup = Ember.lookup;

var obj, moduleOpts = {
  setup: function() {
    obj = {
      foo: {
        bar: {
          baz: { biff: 'BIFF' }
        }
      }
    };

    Ember.lookup = {
      Foo: {
        bar: {
          baz: { biff: 'FooBiff' }
        }
      },

      $foo: {
        bar: {
          baz: { biff: '$FOOBIFF' }
        }
      }
    };
  },

  teardown: function() {
    obj = null;
    Ember.lookup = originalLookup;
  }
};

module('Ember.set with path', moduleOpts);

test('[Foo, bar] -> Foo.bar', function() {
  Ember.lookup.Foo = {toString: function() { return 'Foo'; }}; // Behave like an Ember.Namespace

  Ember.set(Ember.lookup.Foo, 'bar', 'baz');
  equal(Ember.get(Ember.lookup.Foo, 'bar'), 'baz');
});

// ..........................................................
//
// LOCAL PATHS

test('[obj, foo] -> obj.foo', function() {
  Ember.set(obj, 'foo', "BAM");
  equal(Ember.get(obj, 'foo'), "BAM");
});

test('[obj, foo.bar] -> obj.foo.bar', function() {
  Ember.set(obj, 'foo.bar', "BAM");
  equal(Ember.get(obj, 'foo.bar'), "BAM");
});

test('[obj, this.foo] -> obj.foo', function() {
  Ember.set(obj, 'this.foo', "BAM");
  equal(Ember.get(obj, 'foo'), "BAM");
});

test('[obj, this.foo.bar] -> obj.foo.bar', function() {
  Ember.set(obj, 'this.foo.bar', "BAM");
  equal(Ember.get(obj, 'foo.bar'), "BAM");
});

// ..........................................................
// NO TARGET
//

test('[null, Foo.bar] -> Foo.bar', function() {
  Ember.set(null, 'Foo.bar', "BAM");
  equal(Ember.get(Ember.lookup.Foo, 'bar'), "BAM");
});

// ..........................................................
// DEPRECATED
//

module("Ember.set with path - deprecated", {
  setup: function() {
    Ember.TESTING_DEPRECATION = true;
    moduleOpts.setup();
  },
  teardown: function() {
    Ember.TESTING_DEPRECATION = false;
    moduleOpts.teardown();
  }
});

test('[null, bla] gives a proper exception message', function() {
  var exceptionMessage = 'Object in path bla could not be found or was destroyed.';
  try {
    Ember.set(null, 'bla', "BAM");
  } catch(ex) {
    equal(ex.message, exceptionMessage);
  }
});

test('[obj, bla.bla] gives a proper exception message', function() {
  var exceptionMessage = 'Object in path bla could not be found or was destroyed.';
  try {
    Ember.set(obj, 'bla.bla', "BAM");
  } catch(ex) {
    equal(ex.message, exceptionMessage);
  }
});

test('[obj, foo.baz.bat] -> EXCEPTION', function() {
  raises(function() {
    Ember.set(obj, 'foo.baz.bat', "BAM");
  }, Error);
});

test('[obj, foo.baz.bat] -> EXCEPTION', function() {
  Ember.trySet(obj, 'foo.baz.bat', "BAM");
  ok(true, "does not raise");
});
{'fraction_non_alphanumeric': 0.27971457696228336, 'fraction_numerical': 0.0, 'mean_word_length': 2.169250645994832, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '4148412', 'n_tokens_mistral': 1852, 'n_tokens_neox': 1801, 'n_words': 344}