-
Notifications
You must be signed in to change notification settings - Fork 464
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
Test that Date.prototype.toString throws for non-Date receiver #924
Conversation
Pending discussion of tc39/ecma262#849 Test passes in V8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests are fine, I just found some nitpicks.
One thing I'm missing from Date#toString
is a test that confirms the type of the returned value after a successful call. This can be done in a follow up PR, anyway.
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: #sec-date.prototype.tostring |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to remove the #
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -0,0 +1,12 @@ | |||
// Copyright (C) 2017 V8 project authors. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick for consistency: the V8 project authors
- // Copyright (C) 2017 V8 project authors. All rights reserved.
+ // Copyright (C) 2017 the V8 project authors. All rights reserved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
/*--- | ||
esid: #sec-date.prototype.tostring | ||
description: Date.prototype.toString throws a TypeError on non-Date receivers | ||
---*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The info tag is being valuable for reviews (even after the PR phase). If you don't mind, I would like to add the following:
+info: |
+ Date.prototype.toString ( )
+
+ 1. Let tv be ? thisTimeValue(this value).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
description: Date.prototype.toString throws a TypeError on non-Date receivers | ||
---*/ | ||
|
||
assert.throws(TypeError, () => Date.prototype.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch! I hope we never give Date.prototype a [[DateValue]] internal slot anymore, even worse with a NaN value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly, this is the only case that ChakraCore fails.
assert.throws(TypeError, () => Date.prototype.toString()); | ||
assert.throws(TypeError, () => Date.prototype.toString.call(undefined)); | ||
assert.throws(TypeError, () => Date.prototype.toString.call(0)); | ||
assert.throws(TypeError, () => Date.prototype.toString.call({})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to suggest 2 special cases we can add in here:
Date.prototype.toString.call("Tue Mar 21 2017 12:16:43 GMT-0400 (EDT)")
Date.prototype.toString.call(1490113011493)
It seems silly but they're still parseable values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Pending discussion of tc39/ecma262#849. Not ready to merge yet!
Test passes in V8.