mirror of https://github.com/tc39/test262.git
Use assert-lib: intl402/String
This commit is contained in:
parent
8bed4d442d
commit
3841b0a09e
|
@ -12,15 +12,7 @@ author: Norbert Lindenberg
|
|||
var invalidValues = [undefined, null];
|
||||
|
||||
invalidValues.forEach(function (value) {
|
||||
var error;
|
||||
try {
|
||||
assert.throws(TypeError, function() {
|
||||
var result = String.prototype.localeCompare.call(value, "");
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
if (error === undefined) {
|
||||
$ERROR("String.prototype.localeCompare did not reject this = " + value + ".");
|
||||
} else if (error.name !== "TypeError") {
|
||||
$ERROR("String.prototype.localeCompare rejected this = " + value + " with wrong error " + error.name + ".");
|
||||
}
|
||||
}, "String.prototype.localeCompare did not reject this = " + value + ".");
|
||||
});
|
||||
|
|
|
@ -15,12 +15,6 @@ for (i = 0; i < thisValues.length; i++) {
|
|||
var j;
|
||||
for (j = 0; j < thatValues.length; j++) {
|
||||
var result = String.prototype.localeCompare.call(thisValues[i], thatValues[j]);
|
||||
if ((result === 0) !== (i === j)) {
|
||||
if (result === 0) {
|
||||
$ERROR("localeCompare treats " + thisValues[i] + " and " + thatValues[j] + " as equal.");
|
||||
} else {
|
||||
$ERROR("localeCompare treats " + thisValues[i] + " and " + thatValues[j] + " as different.");
|
||||
}
|
||||
}
|
||||
assert.sameValue((result === 0), (i === j), "localeCompare treats " + thisValues[i] + " and " + thatValues[j] + " as " + (result === 0 ? "equal" : "different") + ".");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,12 +15,6 @@ for (i = 0; i < thisValues.length; i++) {
|
|||
var j;
|
||||
for (j = 0; j < thatValues.length; j++) {
|
||||
var result = String.prototype.localeCompare.call(thisValues[i], thatValues[j]);
|
||||
if ((result === 0) !== (i === j)) {
|
||||
if (result === 0) {
|
||||
$ERROR("localeCompare treats " + thisValues[i] + " and " + thatValues[j] + " as equal.");
|
||||
} else {
|
||||
$ERROR("localeCompare treats " + thisValues[i] + " and " + thatValues[j] + " as different.");
|
||||
}
|
||||
}
|
||||
assert.sameValue((result === 0), (i === j), "localeCompare treats " + thisValues[i] + " and " + thatValues[j] + " as " + (result === 0 ? "equal" : "different") + ".");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,10 +14,6 @@ var thisValues = ["a", "t", "u", "undefined", "UNDEFINED", "nicht definiert", "x
|
|||
var i;
|
||||
for (i = 0; i < thisValues.length; i++) {
|
||||
var thisValue = thisValues[i];
|
||||
if (thisValue.localeCompare() !== thisValue.localeCompare(undefined)) {
|
||||
$ERROR("String.prototype.localeCompare does not treat missing 'that' argument as undefined.");
|
||||
}
|
||||
if (thisValue.localeCompare(undefined) !== thisValue.localeCompare("undefined")) {
|
||||
$ERROR("String.prototype.localeCompare does not treat undefined 'that' argument as \"undefined\".");
|
||||
}
|
||||
assert.sameValue(thisValue.localeCompare(), thisValue.localeCompare(undefined), "String.prototype.localeCompare does not treat missing 'that' argument as undefined.");
|
||||
assert.sameValue(thisValue.localeCompare(undefined), thisValue.localeCompare("undefined"), "String.prototype.localeCompare does not treat undefined 'that' argument as \"undefined\".");
|
||||
}
|
||||
|
|
|
@ -23,21 +23,11 @@ locales.forEach(function (locales) {
|
|||
} catch (e) {
|
||||
referenceError = e;
|
||||
}
|
||||
if (referenceError === undefined) {
|
||||
$ERROR("Internal error: Expected exception was not thrown by Intl.Collator for locales " + locales + ".");
|
||||
}
|
||||
assert.notSameValue(referenceError, undefined, "Internal error: Expected exception was not thrown by Intl.Collator for locales " + locales + ".");
|
||||
|
||||
try {
|
||||
assert.throws(referenceError.constructor, function() {
|
||||
var result = "".localeCompare("", locales);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
if (error === undefined) {
|
||||
$ERROR("String.prototype.localeCompare didn't throw exception for locales " + locales + ".");
|
||||
} else if (error.name !== referenceError.name) {
|
||||
$ERROR("String.prototype.localeCompare threw exception " + error.name +
|
||||
" for locales " + locales + "; expected " + referenceError.name + ".");
|
||||
}
|
||||
}, "String.prototype.localeCompare didn't throw exception for locales " + locales + ".");
|
||||
});
|
||||
|
||||
options.forEach(function (options) {
|
||||
|
@ -47,21 +37,9 @@ options.forEach(function (options) {
|
|||
} catch (e) {
|
||||
referenceError = e;
|
||||
}
|
||||
if (referenceError === undefined) {
|
||||
$ERROR("Internal error: Expected exception was not thrown by Intl.Collator for options " +
|
||||
JSON.stringify(options) + ".");
|
||||
}
|
||||
assert.notSameValue(referenceError, undefined, "Internal error: Expected exception was not thrown by Intl.Collator for options " + JSON.stringify(options) + ".");
|
||||
|
||||
try {
|
||||
assert.throws(referenceError.constructor, function() {
|
||||
var result = "".localeCompare("", [], options);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
if (error === undefined) {
|
||||
$ERROR("String.prototype.localeCompare didn't throw exception for options " +
|
||||
JSON.stringify(options) + ".");
|
||||
} else if (error.name !== referenceError.name) {
|
||||
$ERROR("String.prototype.localeCompare threw exception " + error.name +
|
||||
" for options " + JSON.stringify(options) + "; expected " + referenceError.name + ".");
|
||||
}
|
||||
}, "String.prototype.localeCompare didn't throw exception for options " + JSON.stringify(options) + ".");
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue