mirror of https://github.com/tc39/test262.git
Use assert-lib: intl402/Date
This commit is contained in:
parent
3aa427257b
commit
94e9ad831e
|
@ -19,16 +19,8 @@ var invalidValues = [undefined, null, 5, "5", false, {valueOf: function () { ret
|
||||||
Object.getOwnPropertyNames(functions).forEach(function (p) {
|
Object.getOwnPropertyNames(functions).forEach(function (p) {
|
||||||
var f = functions[p];
|
var f = functions[p];
|
||||||
invalidValues.forEach(function (value) {
|
invalidValues.forEach(function (value) {
|
||||||
var error;
|
assert.throws(TypeError, function() {
|
||||||
try {
|
|
||||||
var result = f.call(value);
|
var result = f.call(value);
|
||||||
} catch (e) {
|
}, "Date.prototype." + p + " did not reject this = " + value + ".");
|
||||||
error = e;
|
|
||||||
}
|
|
||||||
if (error === undefined) {
|
|
||||||
$ERROR("Date.prototype." + p + " did not reject this = " + value + ".");
|
|
||||||
} else if (error.name !== "TypeError") {
|
|
||||||
$ERROR("Date.prototype." + p + " rejected this = " + value + " with wrong error " + error.name + ".");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,9 +20,6 @@ Object.getOwnPropertyNames(functions).forEach(function (p) {
|
||||||
var f = functions[p];
|
var f = functions[p];
|
||||||
invalidValues.forEach(function (value) {
|
invalidValues.forEach(function (value) {
|
||||||
var result = f.call(new Date(value));
|
var result = f.call(new Date(value));
|
||||||
if (result !== "Invalid Date") {
|
assert.sameValue(result, "Invalid Date", "Date.prototype." + p + " did not return \"Invalid Date\" for " + value);
|
||||||
$ERROR("Date.prototype." + p + " did not return \"Invalid Date\" for " +
|
|
||||||
value + " – got " + result + " instead.");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -31,21 +31,11 @@ Object.getOwnPropertyNames(functions).forEach(function (p) {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
referenceError = e;
|
referenceError = e;
|
||||||
}
|
}
|
||||||
if (referenceError === undefined) {
|
assert.notSameValue(referenceError, undefined, "Internal error: Expected exception was not thrown by Intl.DateTimeFormat for locales " + locales + ".");
|
||||||
$ERROR("Internal error: Expected exception was not thrown by Intl.DateTimeFormat for locales " + locales + ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
assert.throws(referenceError.constructor, function() {
|
||||||
var result = f.call(new Date(), locales);
|
var result = f.call(new Date(), locales);
|
||||||
} catch (e) {
|
}, "Date.prototype." + p + " didn't throw exception for locales " + locales + ".");
|
||||||
error = e;
|
|
||||||
}
|
|
||||||
if (error === undefined) {
|
|
||||||
$ERROR("Date.prototype." + p + " didn't throw exception for locales " + locales + ".");
|
|
||||||
} else if (error.name !== referenceError.name) {
|
|
||||||
$ERROR("Date.prototype." + p + " threw exception " + error.name +
|
|
||||||
" for locales " + locales + "; expected " + referenceError.name + ".");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
options.forEach(function (options) {
|
options.forEach(function (options) {
|
||||||
|
@ -55,22 +45,10 @@ Object.getOwnPropertyNames(functions).forEach(function (p) {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
referenceError = e;
|
referenceError = e;
|
||||||
}
|
}
|
||||||
if (referenceError === undefined) {
|
assert.notSameValue(referenceError, undefined, "Internal error: Expected exception was not thrown by Intl.DateTimeFormat for options " + JSON.stringify(options) + ".");
|
||||||
$ERROR("Internal error: Expected exception was not thrown by Intl.DateTimeFormat for options " +
|
|
||||||
JSON.stringify(options) + ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
assert.throws(referenceError.constructor, function() {
|
||||||
var result = f.call(new Date(), [], options);
|
var result = f.call(new Date(), [], options);
|
||||||
} catch (e) {
|
}, "Date.prototype." + p + " didn't throw exception for options " + JSON.stringify(options) + ".");
|
||||||
error = e;
|
|
||||||
}
|
|
||||||
if (error === undefined) {
|
|
||||||
$ERROR("Date.prototype." + p + " didn't throw exception for options " +
|
|
||||||
JSON.stringify(options) + ".");
|
|
||||||
} else if (error.name !== referenceError.name) {
|
|
||||||
$ERROR("Date.prototype." + p + " threw exception " + error.name +
|
|
||||||
" for options " + JSON.stringify(options) + "; expected " + referenceError.name + ".");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue