diff options
author | André Bargull <andre.bargull@gmail.com> | 2017-05-04 21:15:31 +0200 |
---|---|---|
committer | André Bargull <andre.bargull@gmail.com> | 2017-05-04 21:15:31 +0200 |
commit | 3841b0a09ef96a99e94f6c94c2ef1c63a7bcc1f6 (patch) | |
tree | a01b1b37ed83760e86c24904ef63ffd665f3f8d8 /test/intl402 | |
parent | 8bed4d442de2b151e295027146774cd6078b81d9 (diff) | |
download | qtdeclarative-testsuites-3841b0a09ef96a99e94f6c94c2ef1c63a7bcc1f6.tar.gz |
Use assert-lib: intl402/String
Diffstat (limited to 'test/intl402')
5 files changed, 14 insertions, 60 deletions
diff --git a/test/intl402/String/prototype/localeCompare/13.1.1_1.js b/test/intl402/String/prototype/localeCompare/13.1.1_1.js index d0564c5d1..86466eff5 100644 --- a/test/intl402/String/prototype/localeCompare/13.1.1_1.js +++ b/test/intl402/String/prototype/localeCompare/13.1.1_1.js @@ -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 + "."); }); diff --git a/test/intl402/String/prototype/localeCompare/13.1.1_2.js b/test/intl402/String/prototype/localeCompare/13.1.1_2.js index fcbd96b32..8caf9854e 100644 --- a/test/intl402/String/prototype/localeCompare/13.1.1_2.js +++ b/test/intl402/String/prototype/localeCompare/13.1.1_2.js @@ -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") + "."); } } diff --git a/test/intl402/String/prototype/localeCompare/13.1.1_3_1.js b/test/intl402/String/prototype/localeCompare/13.1.1_3_1.js index 4b7f944fc..ee16eba18 100644 --- a/test/intl402/String/prototype/localeCompare/13.1.1_3_1.js +++ b/test/intl402/String/prototype/localeCompare/13.1.1_3_1.js @@ -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") + "."); } } diff --git a/test/intl402/String/prototype/localeCompare/13.1.1_3_2.js b/test/intl402/String/prototype/localeCompare/13.1.1_3_2.js index 5d9605b0d..9d580424d 100644 --- a/test/intl402/String/prototype/localeCompare/13.1.1_3_2.js +++ b/test/intl402/String/prototype/localeCompare/13.1.1_3_2.js @@ -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\"."); } diff --git a/test/intl402/String/prototype/localeCompare/13.1.1_6_1.js b/test/intl402/String/prototype/localeCompare/13.1.1_6_1.js index 9215b1afb..db587de86 100644 --- a/test/intl402/String/prototype/localeCompare/13.1.1_6_1.js +++ b/test/intl402/String/prototype/localeCompare/13.1.1_6_1.js @@ -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 + "."); - } - - try { + assert.notSameValue(referenceError, undefined, "Internal error: Expected exception was not thrown by Intl.Collator for locales " + locales + "."); + + 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) + "."); - } - - try { + assert.notSameValue(referenceError, undefined, "Internal error: Expected exception was not thrown by Intl.Collator for options " + JSON.stringify(options) + "."); + + 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) + "."); }); |