mirror of https://github.com/tc39/test262.git
Use assert-lib: intl402/Number
This commit is contained in:
parent
c63cb39cbb
commit
315031c07d
|
@ -11,17 +11,9 @@ var invalidValues = [undefined, null, "5", false, {valueOf: function () { return
|
|||
var validValues = [5, NaN, -1234567.89, -Infinity];
|
||||
|
||||
invalidValues.forEach(function (value) {
|
||||
var error;
|
||||
try {
|
||||
assert.throws(TypeError, function() {
|
||||
var result = Number.prototype.toLocaleString.call(value);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
if (error === undefined) {
|
||||
$ERROR("Number.prototype.toLocaleString did not reject this = " + value + ".");
|
||||
} else if (error.name !== "TypeError") {
|
||||
$ERROR("Number.prototype.toLocaleString rejected this = " + value + " with wrong error " + error.name + ".");
|
||||
}
|
||||
}, "Number.prototype.toLocaleString did not reject this = " + value + ".");
|
||||
});
|
||||
|
||||
// for valid values, just check that a Number value and the corresponding
|
||||
|
@ -30,8 +22,5 @@ validValues.forEach(function (value) {
|
|||
var Constructor = Number; // to keep jshint happy
|
||||
var valueResult = Number.prototype.toLocaleString.call(value);
|
||||
var objectResult = Number.prototype.toLocaleString.call(new Constructor(value));
|
||||
if (valueResult !== objectResult) {
|
||||
$ERROR("Number.prototype.toLocaleString produces different results for Number value " +
|
||||
value + " and corresponding Number object: " + valueResult + " vs. " + objectResult + ".");
|
||||
}
|
||||
assert.sameValue(valueResult, objectResult, "Number.prototype.toLocaleString produces different results for Number value " + value + " and corresponding Number object.");
|
||||
});
|
||||
|
|
|
@ -25,21 +25,11 @@ locales.forEach(function (locales) {
|
|||
} catch (e) {
|
||||
referenceError = e;
|
||||
}
|
||||
if (referenceError === undefined) {
|
||||
$ERROR("Internal error: Expected exception was not thrown by Intl.NumberFormat for locales " + locales + ".");
|
||||
}
|
||||
assert.notSameValue(referenceError, undefined, "Internal error: Expected exception was not thrown by Intl.NumberFormat for locales " + locales + ".");
|
||||
|
||||
try {
|
||||
assert.throws(referenceError.constructor, function() {
|
||||
var result = (0).toLocaleString(locales);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
if (error === undefined) {
|
||||
$ERROR("Number.prototype.toLocaleString didn't throw exception for locales " + locales + ".");
|
||||
} else if (error.name !== referenceError.name) {
|
||||
$ERROR("Number.prototype.toLocaleString threw exception " + error.name +
|
||||
" for locales " + locales + "; expected " + referenceError.name + ".");
|
||||
}
|
||||
}, "Number.prototype.toLocaleString didn't throw exception for locales " + locales + ".");
|
||||
});
|
||||
|
||||
options.forEach(function (options) {
|
||||
|
@ -49,21 +39,9 @@ options.forEach(function (options) {
|
|||
} catch (e) {
|
||||
referenceError = e;
|
||||
}
|
||||
if (referenceError === undefined) {
|
||||
$ERROR("Internal error: Expected exception was not thrown by Intl.NumberFormat for options " +
|
||||
JSON.stringify(options) + ".");
|
||||
}
|
||||
assert.notSameValue(referenceError, undefined, "Internal error: Expected exception was not thrown by Intl.NumberFormat for options " + JSON.stringify(options) + ".");
|
||||
|
||||
try {
|
||||
assert.throws(referenceError.constructor, function() {
|
||||
var result = (0).toLocaleString([], options);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
if (error === undefined) {
|
||||
$ERROR("Number.prototype.toLocaleString didn't throw exception for options " +
|
||||
JSON.stringify(options) + ".");
|
||||
} else if (error.name !== referenceError.name) {
|
||||
$ERROR("Number.prototype.toLocaleString threw exception " + error.name +
|
||||
" for options " + JSON.stringify(options) + "; expected " + referenceError.name + ".");
|
||||
}
|
||||
}, "Number.prototype.toLocaleString didn't throw exception for options " + JSON.stringify(options) + ".");
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue