Fix "prototype" iteration bug with _.keys.

Former-commit-id: 1e072b2639e21a5c0a920db0ac27693ade34b009
This commit is contained in:
John-David Dalton
2012-05-31 10:29:33 -05:00
parent b432721fe5
commit 861eea5148
3 changed files with 43 additions and 19 deletions

View File

@@ -306,6 +306,20 @@
deepEqual(_.keys(shadowed).sort(),
'constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf'.split(' '));
});
test('skips the prototype property of functions (test in Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1)', function() {
function Foo() {}
Foo.prototype.c = 3;
Foo.a = 1;
Foo.b = 2;
var expected = ['a', 'b'];
deepEqual(_.keys(Foo), expected);
Foo.prototype = { 'c': 3 };
deepEqual(_.keys(Foo), expected);
});
}());
/*--------------------------------------------------------------------------*/