-
Notifications
You must be signed in to change notification settings - Fork 684
Increase test coverage: Array.prototype.toLocaleString #2716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,3 +54,38 @@ try { | |
assert (e.message === "foo"); | ||
assert (e instanceof ReferenceError); | ||
} | ||
|
||
/* ES v5.1 15.4.4.3.1. | ||
Checking behavior when the function's this_argument is null */ | ||
try { | ||
Array.prototype.toLocaleString.call(null); | ||
assert(false); | ||
} catch (e) { | ||
assert(e instanceof TypeError); | ||
} | ||
|
||
/* ES v5.1 15.4.4.3.2. | ||
Checking behavior when length throws error */ | ||
try { | ||
var obj = {}; | ||
Object.defineProperty(obj, 'length', { 'get' : function () { throw new ReferenceError("foo"); } }); | ||
Array.prototype.toLocaleString.call(obj); | ||
assert(false); | ||
} catch (e) { | ||
assert(e instanceof ReferenceError); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please check the message as well! (And use unique messages) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The message is not checked. Why is this marked as resolved? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @akosthekiss Probably that was a miss click, I've just unresolved it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The thrown error and the one in the function are not the same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something is not right then. Q1: Why set the error message then, if it cannot be checked? Q2: Does the error object get replaced somewhere by the builtin implementation? Q3: If yes, why? Q4: If yes, is it necessary to throw a reference error within the anonymous function or any kind of error can be thrown? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something is a bit fishy there. try {
var obj = {};
Object.defineProperty(obj, 'length', { 'get' : function () { throw new ReferenceError("foo"); } });
Array.prototype.toLocaleString.call(obj);
assert(false);
} catch (e) {
assert(e instanceof ReferenceError);
assert (e.message == "foo");
} The suggested assertion for the message is correct in all engines that I've tested (V8, Spidermonkey, JSC) even in Jerry as well. Could you please give more detailed description about why this assert is failing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I made a typo, that is why it did not work. |
||
assert(e.message == "foo"); | ||
} | ||
|
||
/* ES v5.1 15.4.4.3.3. | ||
Checking behavior when length is an object, which has a valueOf method that throws an error */ | ||
var len = { }; | ||
Object.defineProperty(len, 'valueOf', { 'get' : function () { throw new ReferenceError("vOf"); } }); | ||
var obj = { toLocaleString : Array.prototype.toLocaleString, length : len }; | ||
|
||
try { | ||
obj.toLocaleString(); | ||
assert(false); | ||
} catch (e) { | ||
assert(e.message === 'vOf'); | ||
assert(e instanceof ReferenceError); | ||
} |
Uh oh!
There was an error while loading. Please reload this page.