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) {
|
||||
var f = functions[p];
|
||||
invalidValues.forEach(function (value) {
|
||||
var error;
|
||||
try {
|
||||
assert.throws(TypeError, function() {
|
||||
var result = f.call(value);
|
||||
} catch (e) {
|
||||
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 + ".");
|
||||
}
|
||||
}, "Date.prototype." + p + " did not reject this = " + value + ".");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,9 +20,6 @@ Object.getOwnPropertyNames(functions).forEach(function (p) {
|
|||
var f = functions[p];
|
||||
invalidValues.forEach(function (value) {
|
||||
var result = f.call(new Date(value));
|
||||
if (result !== "Invalid Date") {
|
||||
$ERROR("Date.prototype." + p + " did not return \"Invalid Date\" for " +
|
||||
value + " – got " + result + " instead.");
|
||||
}
|
||||
assert.sameValue(result, "Invalid Date", "Date.prototype." + p + " did not return \"Invalid Date\" for " + value);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -31,21 +31,11 @@ Object.getOwnPropertyNames(functions).forEach(function (p) {
|
|||
} catch (e) {
|
||||
referenceError = e;
|
||||
}
|
||||
if (referenceError === undefined) {
|
||||
$ERROR("Internal error: Expected exception was not thrown by Intl.DateTimeFormat for locales " + locales + ".");
|
||||
}
|
||||
|
||||
try {
|
||||
assert.notSameValue(referenceError, undefined, "Internal error: Expected exception was not thrown by Intl.DateTimeFormat for locales " + locales + ".");
|
||||
|
||||
assert.throws(referenceError.constructor, function() {
|
||||
var result = f.call(new Date(), locales);
|
||||
} catch (e) {
|
||||
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 + ".");
|
||||
}
|
||||
}, "Date.prototype." + p + " didn't throw exception for locales " + locales + ".");
|
||||
});
|
||||
|
||||
options.forEach(function (options) {
|
||||
|
@ -55,22 +45,10 @@ Object.getOwnPropertyNames(functions).forEach(function (p) {
|
|||
} catch (e) {
|
||||
referenceError = e;
|
||||
}
|
||||
if (referenceError === undefined) {
|
||||
$ERROR("Internal error: Expected exception was not thrown by Intl.DateTimeFormat for options " +
|
||||
JSON.stringify(options) + ".");
|
||||
}
|
||||
|
||||
try {
|
||||
assert.notSameValue(referenceError, undefined, "Internal error: Expected exception was not thrown by Intl.DateTimeFormat for options " + JSON.stringify(options) + ".");
|
||||
|
||||
assert.throws(referenceError.constructor, function() {
|
||||
var result = f.call(new Date(), [], options);
|
||||
} catch (e) {
|
||||
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 + ".");
|
||||
}
|
||||
}, "Date.prototype." + p + " didn't throw exception for options " + JSON.stringify(options) + ".");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue