summaryrefslogtreecommitdiff
path: root/test/intl402
diff options
context:
space:
mode:
authorAndré Bargull <andre.bargull@gmail.com>2017-05-04 21:10:58 +0200
committerAndré Bargull <andre.bargull@gmail.com>2017-05-04 21:10:58 +0200
commit3aa427257bf18c8f942f16272f8f4aa1ccdeb3e1 (patch)
tree06dcdb1cb4c426724dddae696c14b5ed50ed73f1 /test/intl402
parent19eb1d2e02c31ba813fe0ff5d10ea2c09a911fb5 (diff)
downloadqtdeclarative-testsuites-3aa427257bf18c8f942f16272f8f4aa1ccdeb3e1.tar.gz
Use assert-lib: intl402/Collator
Diffstat (limited to 'test/intl402')
-rw-r--r--test/intl402/Collator/10.1.1_1.js8
-rw-r--r--test/intl402/Collator/10.1.1_10.js4
-rw-r--r--test/intl402/Collator/10.1.1_19_b.js10
-rw-r--r--test/intl402/Collator/10.1.1_19_c.js10
-rw-r--r--test/intl402/Collator/10.1.3.js8
-rw-r--r--test/intl402/Collator/10.2.3_b.js10
-rw-r--r--test/intl402/Collator/10.4_a.js4
-rw-r--r--test/intl402/Collator/9.2.5_11_g_ii_2.js8
-rw-r--r--test/intl402/Collator/prototype/10.2.1.js16
-rw-r--r--test/intl402/Collator/prototype/10.3_a.js5
-rw-r--r--test/intl402/Collator/prototype/10.3_b.js12
-rw-r--r--test/intl402/Collator/prototype/compare/10.3.2_CS_a.js5
-rw-r--r--test/intl402/Collator/prototype/constructor/10.3.1.js5
-rw-r--r--test/intl402/Collator/prototype/resolvedOptions/10.3.3.js4
-rw-r--r--test/intl402/Collator/supportedLocalesOf/10.2.2_a.js12
15 files changed, 27 insertions, 94 deletions
diff --git a/test/intl402/Collator/10.1.1_1.js b/test/intl402/Collator/10.1.1_1.js
index 42f4fe67b..faab9acee 100644
--- a/test/intl402/Collator/10.1.1_1.js
+++ b/test/intl402/Collator/10.1.1_1.js
@@ -14,16 +14,12 @@ testWithIntlConstructors(function (Constructor) {
// variant 1: use constructor in a "new" expression
obj = new Constructor();
newObj = Intl.Collator.call(obj);
- if (obj === newObj) {
- $ERROR("Collator object created with \"new\" was not ignored as this-value.");
- }
+ assert.notSameValue(obj, newObj, "Collator object created with \"new\" was not ignored as this-value.");
// variant 2: use constructor as a function
obj = Constructor();
newObj = Intl.Collator.call(obj);
- if (obj === newObj) {
- $ERROR("Collator object created with constructor as function was not ignored as this-value.");
- }
+ assert.notSameValue(obj, newObj, "Collator object created with constructor as function was not ignored as this-value.");
return true;
});
diff --git a/test/intl402/Collator/10.1.1_10.js b/test/intl402/Collator/10.1.1_10.js
index b5e0d6d19..526552a76 100644
--- a/test/intl402/Collator/10.1.1_10.js
+++ b/test/intl402/Collator/10.1.1_10.js
@@ -13,6 +13,4 @@ includes: [testIntl.js]
taintProperties(["localeMatcher", "kn", "kf"]);
var locale = new Intl.Collator(undefined, {localeMatcher: "lookup"}).resolvedOptions().locale;
-if (!isCanonicalizedStructurallyValidLanguageTag(locale)) {
- $ERROR("Collator returns invalid locale " + locale + ".");
-}
+assert(isCanonicalizedStructurallyValidLanguageTag(locale), "Collator returns invalid locale " + locale + ".");
diff --git a/test/intl402/Collator/10.1.1_19_b.js b/test/intl402/Collator/10.1.1_19_b.js
index 47642dc1f..8a6eaeb35 100644
--- a/test/intl402/Collator/10.1.1_19_b.js
+++ b/test/intl402/Collator/10.1.1_19_b.js
@@ -13,16 +13,10 @@ function checkCollation(extensionCoValue, usageValue, expectedCollations, expect
var collator = new Intl.Collator([requestLocale], options);
var collation = collator.resolvedOptions().collation;
- if (expectedCollations.indexOf(collation) === -1) {
- $ERROR((extensionCoValue === undefined ? "Default collation" : "Collation for \"" + extensionCoValue) +
- "\" should be " + expectedCollations.join(" or ") + ", but is " + collation + ".");
- }
+ assert.notSameValue(expectedCollations.indexOf(collation), -1, (extensionCoValue === undefined ? "Default collation" : "Collation for \"" + extensionCoValue) + "\" should be " + expectedCollations.join(" or ") + ", but is " + collation + ".");
var usage = collator.resolvedOptions().usage;
- if (expectedUsage !== usage) {
- $ERROR((usageValue === undefined ? "Default usage" : "Usage") +
- " should be " + expectedUsage + ", but is " + usage + ".");
- }
+ assert.sameValue(usage, expectedUsage, (usageValue === undefined ? "Default usage" : "Usage") + " mismatch.");
}
checkCollation(undefined, undefined, ["default"], "sort");
diff --git a/test/intl402/Collator/10.1.1_19_c.js b/test/intl402/Collator/10.1.1_19_c.js
index 7a4239e01..ae4f099fb 100644
--- a/test/intl402/Collator/10.1.1_19_c.js
+++ b/test/intl402/Collator/10.1.1_19_c.js
@@ -35,10 +35,7 @@ options.forEach(function (option) {
supportedValues.forEach(function (value) {
collator = new Intl.Collator([defaultLocale + "-u-" + option.key + "-" + value]);
result = collator.resolvedOptions()[option.property];
- if (result !== value) {
- $ERROR("Property " + option.property + " couldn't be set through locale extension key " +
- option.key + "; requested value: " + value + "; actual value: " + result + ".");
- }
+ assert.sameValue(result, value, "Property " + option.property + " couldn't be set through locale extension key " + option.key + ".");
});
// verify that the options setting overrides the locale setting
@@ -54,10 +51,7 @@ options.forEach(function (option) {
opt[option.property] = value;
collator = new Intl.Collator([defaultLocale + "-u-" + option.key + "-" + otherValue], opt);
result = collator.resolvedOptions()[option.property];
- if (result !== value) {
- $ERROR("Options value for property " + option.property + " doesn't override locale extension key " +
- option.key + "; requested value: " + value + "; actual value: " + result + ".");
- }
+ assert.sameValue(result, value, "Options value for property " + option.property + " doesn't override locale extension key " + option.key + ".");
}
});
});
diff --git a/test/intl402/Collator/10.1.3.js b/test/intl402/Collator/10.1.3.js
index 942fdf3ec..47263a1b6 100644
--- a/test/intl402/Collator/10.1.3.js
+++ b/test/intl402/Collator/10.1.3.js
@@ -12,10 +12,6 @@ author: Norbert Lindenberg
var obj = new Intl.Collator();
var actualPrototype = Object.getPrototypeOf(obj);
-if (actualPrototype !== Intl.Collator.prototype) {
- $ERROR("Prototype of object constructed by Intl.Collator isn't Intl.Collator.prototype; got " + actualPrototype);
-}
+assert.sameValue(actualPrototype, Intl.Collator.prototype, "Prototype of object constructed by Intl.Collator isn't Intl.Collator.prototype.");
-if (!Object.isExtensible(obj)) {
- $ERROR("Object constructed by Intl.Collator must be extensible.");
-}
+assert(Object.isExtensible(obj), "Object constructed by Intl.Collator must be extensible.");
diff --git a/test/intl402/Collator/10.2.3_b.js b/test/intl402/Collator/10.2.3_b.js
index c7ae39850..7add01d5b 100644
--- a/test/intl402/Collator/10.2.3_b.js
+++ b/test/intl402/Collator/10.2.3_b.js
@@ -39,14 +39,8 @@ Object.getOwnPropertyNames(keyValues).forEach(function (key) {
keyValues[key].forEach(function (value) {
var collator = new Intl.Collator([defaultLocale + "-u-" + key + "-" + value]);
var options = collator.resolvedOptions();
- if (options.locale !== defaultLocale) {
- $ERROR("Locale " + options.locale + " is affected by key " +
- key + "; value " + value + ".");
- }
- if (JSON.stringify(options) !== defaultOptionsJSON) {
- $ERROR("Resolved options " + JSON.stringify(options) + " are affected by key " +
- key + "; value " + value + ".");
- }
+ assert.sameValue(options.locale, defaultLocale, "Locale " + options.locale + " is affected by key " + key + "; value " + value + ".");
+ assert.sameValue(JSON.stringify(options), defaultOptionsJSON, "Resolved options " + JSON.stringify(options) + " are affected by key " + key + "; value " + value + ".");
testArraysAreSame(defaultSortedArray, testArray.sort(collator.compare));
});
});
diff --git a/test/intl402/Collator/10.4_a.js b/test/intl402/Collator/10.4_a.js
index 3b250759a..37b975130 100644
--- a/test/intl402/Collator/10.4_a.js
+++ b/test/intl402/Collator/10.4_a.js
@@ -10,6 +10,4 @@ author: Norbert Lindenberg
var obj = new Intl.Collator();
var toStringValue = Object.prototype.toString.call(obj);
-if (toStringValue !== "[object Object]") {
- $ERROR("Intl.Collator instance produces wrong [[Class]] - toString returns " + toStringValue + ".");
-}
+assert.sameValue(toStringValue, "[object Object]", "Intl.Collator instance produces wrong [[Class]] - toString returns " + toStringValue + ".");
diff --git a/test/intl402/Collator/9.2.5_11_g_ii_2.js b/test/intl402/Collator/9.2.5_11_g_ii_2.js
index f7af9512c..44642492b 100644
--- a/test/intl402/Collator/9.2.5_11_g_ii_2.js
+++ b/test/intl402/Collator/9.2.5_11_g_ii_2.js
@@ -17,11 +17,7 @@ extensions.forEach(function (extension) {
var locale = collator.resolvedOptions().locale;
var numeric = collator.resolvedOptions().numeric;
if (numeric !== undefined) {
- if (numeric !== true) {
- $ERROR("Default value for \"kn\" should be true, but is " + numeric + ".");
- }
- if (locale.indexOf("-kn") !== -1) {
- $ERROR("\"kn\" is returned in locale, but shouldn't be.");
- }
+ assert.sameValue(numeric, true, "Default value for \"kn\" should be true, but is " + numeric + ".");
+ assert.sameValue(locale.indexOf("-kn"), -1, "\"kn\" is returned in locale, but shouldn't be.");
}
});
diff --git a/test/intl402/Collator/prototype/10.2.1.js b/test/intl402/Collator/prototype/10.2.1.js
index c47db09db..879362e44 100644
--- a/test/intl402/Collator/prototype/10.2.1.js
+++ b/test/intl402/Collator/prototype/10.2.1.js
@@ -8,15 +8,7 @@ author: Norbert Lindenberg
---*/
var desc = Object.getOwnPropertyDescriptor(Intl.Collator, "prototype");
-if (desc === undefined) {
- $ERROR("Intl.Collator.prototype is not defined.");
-}
-if (desc.writable) {
- $ERROR("Intl.Collator.prototype must not be writable.");
-}
-if (desc.enumerable) {
- $ERROR("Intl.Collator.prototype must not be enumerable.");
-}
-if (desc.configurable) {
- $ERROR("Intl.Collator.prototype must not be configurable.");
-}
+assert.notSameValue(desc, undefined, "Intl.Collator.prototype is not defined.");
+assert.sameValue(desc.writable, false, "Intl.Collator.prototype must not be writable.");
+assert.sameValue(desc.enumerable, false, "Intl.Collator.prototype must not be enumerable.");
+assert.sameValue(desc.configurable, false, "Intl.Collator.prototype must not be configurable.");
diff --git a/test/intl402/Collator/prototype/10.3_a.js b/test/intl402/Collator/prototype/10.3_a.js
index a155b8c94..9fb489ab4 100644
--- a/test/intl402/Collator/prototype/10.3_a.js
+++ b/test/intl402/Collator/prototype/10.3_a.js
@@ -10,7 +10,4 @@ description: >
// test by calling a function that would fail if "this" were not an object
// initialized as an Intl.Collator
-if (Intl.Collator.prototype.compare("aаあ아", "aаあ아") !== 0) {
- $ERROR("Intl.Collator.prototype is not an object that has been " +
- "initialized as an Intl.Collator.");
-}
+assert.sameValue(Intl.Collator.prototype.compare("aаあ아", "aаあ아"), 0, "Intl.Collator.prototype is not an object that has been initialized as an Intl.Collator.");
diff --git a/test/intl402/Collator/prototype/10.3_b.js b/test/intl402/Collator/prototype/10.3_b.js
index 312cd3fcd..ea3f62c31 100644
--- a/test/intl402/Collator/prototype/10.3_b.js
+++ b/test/intl402/Collator/prototype/10.3_b.js
@@ -19,16 +19,8 @@ var invalidTargets = [undefined, null, true, 0, "Collator", [], {}];
Object.getOwnPropertyNames(functions).forEach(function (functionName) {
var f = functions[functionName];
invalidTargets.forEach(function (target) {
- var error;
- try {
+ assert.throws(TypeError, function() {
f.call(target);
- } catch (e) {
- error = e;
- }
- if (error === undefined) {
- $ERROR("Calling " + functionName + " on " + target + " was not rejected.");
- } else if (error.name !== "TypeError") {
- $ERROR("Calling " + functionName + " on " + target + " was rejected with wrong error " + error.name + ".");
- }
+ }, "Calling " + functionName + " on " + target + " was not rejected.");
});
});
diff --git a/test/intl402/Collator/prototype/compare/10.3.2_CS_a.js b/test/intl402/Collator/prototype/compare/10.3.2_CS_a.js
index 630c3e48c..164b6aff5 100644
--- a/test/intl402/Collator/prototype/compare/10.3.2_CS_a.js
+++ b/test/intl402/Collator/prototype/compare/10.3.2_CS_a.js
@@ -52,10 +52,7 @@ var pairs = [
var i;
for (i = 0; i < pairs.length; i++) {
var pair = pairs[i];
- if (collator.compare(pair[0], pair[1]) !== 0) {
- $ERROR("Collator.compare considers " + pair[0] + " (" + toU(pair[0]) +
- ") ≠ " + pair[1] + " (" + toU(pair[1]) + ").");
- }
+ assert.sameValue(collator.compare(pair[0], pair[1]), 0, "Collator.compare considers " + pair[0] + " (" + toU(pair[0]) + ") ≠ " + pair[1] + " (" + toU(pair[1]) + ").");
}
function toU(s) {
diff --git a/test/intl402/Collator/prototype/constructor/10.3.1.js b/test/intl402/Collator/prototype/constructor/10.3.1.js
index 6a582b362..b700edba0 100644
--- a/test/intl402/Collator/prototype/constructor/10.3.1.js
+++ b/test/intl402/Collator/prototype/constructor/10.3.1.js
@@ -8,7 +8,4 @@ description: >
Intl.Collator.
---*/
-if (Intl.Collator.prototype.constructor !== Intl.Collator) {
- $ERROR("Intl.Collator.prototype.constructor is not the same as " +
- "Intl.Collator");
-}
+assert.sameValue(Intl.Collator.prototype.constructor, Intl.Collator, "Intl.Collator.prototype.constructor is not the same as Intl.Collator");
diff --git a/test/intl402/Collator/prototype/resolvedOptions/10.3.3.js b/test/intl402/Collator/prototype/resolvedOptions/10.3.3.js
index c50817283..07a975d1c 100644
--- a/test/intl402/Collator/prototype/resolvedOptions/10.3.3.js
+++ b/test/intl402/Collator/prototype/resolvedOptions/10.3.3.js
@@ -13,9 +13,7 @@ includes: [testIntl.js]
var actual = new Intl.Collator().resolvedOptions();
var actual2 = new Intl.Collator().resolvedOptions();
-if (actual2 === actual) {
- $ERROR("resolvedOptions returned the same object twice.");
-}
+assert.notSameValue(actual2, actual, "resolvedOptions returned the same object twice.");
// source: CLDR file common/bcp47/collation.xml; version CLDR 21.
var collations = [
diff --git a/test/intl402/Collator/supportedLocalesOf/10.2.2_a.js b/test/intl402/Collator/supportedLocalesOf/10.2.2_a.js
index dcd56dc50..b7dc8219f 100644
--- a/test/intl402/Collator/supportedLocalesOf/10.2.2_a.js
+++ b/test/intl402/Collator/supportedLocalesOf/10.2.2_a.js
@@ -14,15 +14,9 @@ var requestedLocales = [defaultLocale, notSupported];
var supportedLocales;
-if (!Intl.Collator.hasOwnProperty('supportedLocalesOf')) {
- $ERROR("Intl.Collator doesn't have a supportedLocalesOf property.");
-}
+assert(Intl.Collator.hasOwnProperty('supportedLocalesOf'), "Intl.Collator doesn't have a supportedLocalesOf property.");
supportedLocales = Intl.Collator.supportedLocalesOf(requestedLocales);
-if (supportedLocales.length !== 1) {
- $ERROR('The length of supported locales list is not 1.');
-}
+assert.sameValue(supportedLocales.length, 1, 'The length of supported locales list is not 1.');
-if (supportedLocales[0] !== defaultLocale) {
- $ERROR('The default locale is not returned in the supported list.');
-}
+assert.sameValue(supportedLocales[0], defaultLocale, 'The default locale is not returned in the supported list.');