Skip to content

Commit

Permalink
Make feature tests more obvious and store test values in variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanforbes committed Jan 30, 2012
1 parent 7eebefa commit d0b79ba
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions es5-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,9 @@ if (!Object.keys) {
// string format defined in 15.9.1.15. All fields are present in the String.
// The time zone is always UTC, denoted by the suffix Z. If the time value of
// this object is not a finite Number a RangeError exception is thrown.
if (!Date.prototype.toISOString || !~(new Date(-62198755200000).toISOString().indexOf('-000001'))) {
var negDate = -62198755200000,
yearStr = '-000001';
if (!Date.prototype.toISOString || (new Date(negDate).toISOString().indexOf(yearStr) === -1)) {
Date.prototype.toISOString = function toISOString() {
var result, length, value, year;
if (!isFinite(this)) {
Expand Down Expand Up @@ -888,11 +890,11 @@ if (!Date.prototype.toISOString || !~(new Date(-62198755200000).toISOString().in
// http://es5.github.com/#x15.9.5.44
// This function provides a String representation of a Date object for use by
// JSON.stringify (15.12.3).
if (!Date.prototype.toJSON || !~((new Date(-62198755200000)).toJSON().indexOf('-000001')) ||
~(function() {
if (!Date.prototype.toJSON || ((new Date(negDate)).toJSON().indexOf(yearStr) === -1) ||
!(function() {
// is Date.prototype.toJSON non-generic?
try {
return Date.prototype.toJSON.call({toISOString:function(){return -1;}});
return Date.prototype.toJSON.call({toISOString:function(){return 1;}});
} catch (err) {}
}())) {
Date.prototype.toJSON = function toJSON(key) {
Expand Down

0 comments on commit d0b79ba

Please sign in to comment.