Ensure _.set passes strict mode tests.

This commit is contained in:
jdalton
2015-04-06 09:36:56 -05:00
parent 633f37bfb6
commit c876004fb2
2 changed files with 26 additions and 10 deletions

View File

@@ -13261,7 +13261,7 @@
test('should follow `path` over non-plain objects', 2, function() {
_.set(0, 'constructor.prototype.a', 'ok');
strictEqual(1..a, 'ok');
strictEqual(0..a, 'ok');
delete numberProto.a;
var object = { 'a': '' };
@@ -13269,6 +13269,21 @@
strictEqual(stringProto.replace.b, 1);
delete stringProto.replace.b;
});
test('should not error on paths over primitive values in strict mode', 2, function() {
numberProto.a = 0;
_.each(['a', 'a.a.a'], function(path) {
try {
_.set(0, path, 1);
strictEqual(0..a, 0);
} catch(e) {
ok(false, e.message);
}
});
delete numberProto.a;
});
}());
/*--------------------------------------------------------------------------*/