summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Bargull <andre.bargull@gmail.com>2017-12-21 12:08:10 -0800
committerRick Waldron <waldron.rick@gmail.com>2017-12-21 16:46:55 -0500
commit123259733b25badb7c19f37e35ce472eb5e20e16 (patch)
treeb14f709137931816cb00e13fb2409ce80fee55ac
parente65c65c293c2f7cf8b775704aa26579989ea1514 (diff)
downloadqtdeclarative-testsuites-123259733b25badb7c19f37e35ce472eb5e20e16.tar.gz
Replace testArraysAreSame with assert.compareArray
-rw-r--r--harness/testIntl.js20
-rw-r--r--test/intl402/Collator/10.1.2_a.js4
-rw-r--r--test/intl402/Collator/10.2.3_b.js4
-rw-r--r--test/intl402/Collator/prototype/compare/10.3.2_1_c.js12
-rw-r--r--test/intl402/Collator/prototype/compare/10.3.2_CS_b_NN.js4
-rw-r--r--test/intl402/Collator/prototype/compare/10.3.2_CS_c_NN.js4
-rw-r--r--test/intl402/Collator/prototype/compare/10.3.2_CS_d_NN.js4
-rw-r--r--test/intl402/Date/prototype/13.3.0_7.js14
-rw-r--r--test/intl402/DateTimeFormat/12.1.2.js4
-rw-r--r--test/intl402/Number/prototype/toLocaleString/13.2.1_5.js14
-rw-r--r--test/intl402/NumberFormat/11.1.2.js4
-rw-r--r--test/intl402/PluralRules/can-be-subclassed.js4
-rw-r--r--test/intl402/String/prototype/localeCompare/13.1.1_7.js12
13 files changed, 34 insertions, 70 deletions
diff --git a/harness/testIntl.js b/harness/testIntl.js
index 4fd4f4348..8b9d29688 100644
--- a/harness/testIntl.js
+++ b/harness/testIntl.js
@@ -1181,23 +1181,3 @@ function isCanonicalizedStructurallyValidTimeZoneName(timeZone) {
}
return zoneNamePattern.test(timeZone);
}
-
-
-/**
- * Verifies that the actual array matches the expected one in length, elements,
- * and element order.
- * @param {Array} expected the expected array.
- * @param {Array} actual the actual array.
- * @return {boolean} true if the test succeeds.
- * @exception if the test fails.
- */
-function testArraysAreSame(expected, actual) {
- var i;
- for (i = 0; i < Math.max(actual.length, expected.length); i++) {
- if (actual[i] !== expected[i]) {
- $ERROR("Result array element at index " + i + " should be \"" +
- expected[i] + "\" but is \"" + actual[i] + "\".");
- }
- }
- return true;
-}
diff --git a/test/intl402/Collator/10.1.2_a.js b/test/intl402/Collator/10.1.2_a.js
index 83bd66b46..e6087b8ce 100644
--- a/test/intl402/Collator/10.1.2_a.js
+++ b/test/intl402/Collator/10.1.2_a.js
@@ -6,7 +6,7 @@
es5id: 10.1.2_a
description: Tests that Intl.Collator can be subclassed.
author: Norbert Lindenberg
-includes: [testIntl.js]
+includes: [testIntl.js, compareArray.js]
---*/
// get a collator and have it sort an array for comparison with the subclass
@@ -25,4 +25,4 @@ class MyCollator extends Intl.Collator {
var collator = new MyCollator(locales);
a.sort(collator.compare);
-testArraysAreSame(referenceSorted, a);
+assert.compareArray(a, referenceSorted);
diff --git a/test/intl402/Collator/10.2.3_b.js b/test/intl402/Collator/10.2.3_b.js
index 7add01d5b..a0120cecb 100644
--- a/test/intl402/Collator/10.2.3_b.js
+++ b/test/intl402/Collator/10.2.3_b.js
@@ -7,7 +7,7 @@ description: >
Tests that Intl.Collator does not accept Unicode locale extension
keys and values that are not allowed.
author: Norbert Lindenberg
-includes: [testIntl.js]
+includes: [testIntl.js, compareArray.js]
---*/
var testArray = [
@@ -41,6 +41,6 @@ Object.getOwnPropertyNames(keyValues).forEach(function (key) {
var options = collator.resolvedOptions();
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));
+ assert.compareArray(testArray.sort(collator.compare), defaultSortedArray);
});
});
diff --git a/test/intl402/Collator/prototype/compare/10.3.2_1_c.js b/test/intl402/Collator/prototype/compare/10.3.2_1_c.js
index 7bf3b7266..5e8374cb7 100644
--- a/test/intl402/Collator/prototype/compare/10.3.2_1_c.js
+++ b/test/intl402/Collator/prototype/compare/10.3.2_1_c.js
@@ -5,7 +5,7 @@
es5id: 10.3.2_1_c
description: Tests that compare function is bound to its Intl.Collator.
author: Norbert Lindenberg
-includes: [testIntl.js]
+includes: [testIntl.js, compareArray.js]
---*/
var strings = ["d", "O", "od", "oe", "of", "ö", "o\u0308", "X", "y", "Z", "Z.", "𠮷野家", "吉野家", "!A", "A", "b", "C"];
@@ -24,12 +24,8 @@ locales.forEach(function (locales) {
referenceSorted.sort(function (a, b) { return collatorObj.compare(a, b); });
var sorted = strings;
sorted.sort(compareFunc);
- try {
- testArraysAreSame(referenceSorted, sorted);
- } catch (e) {
- e.message += " (Testing with locales " + locales + "; options " +
- (options ? JSON.stringify(options) : options) + ".)";
- throw e;
- }
+ assert.compareArray(sorted, referenceSorted,
+ "(Testing with locales " + locales + "; options " +
+ (options ? JSON.stringify(options) : options) + ".)");
});
});
diff --git a/test/intl402/Collator/prototype/compare/10.3.2_CS_b_NN.js b/test/intl402/Collator/prototype/compare/10.3.2_CS_b_NN.js
index e1d5e2941..0056f2889 100644
--- a/test/intl402/Collator/prototype/compare/10.3.2_CS_b_NN.js
+++ b/test/intl402/Collator/prototype/compare/10.3.2_CS_b_NN.js
@@ -7,7 +7,7 @@ description: >
Tests that the compare function isn't entirely unreasonable. This
test is not normative.
author: Norbert Lindenberg
-includes: [testIntl.js]
+includes: [testIntl.js, compareArray.js]
---*/
// this test should be valid at least for the following locales
@@ -18,5 +18,5 @@ locales.forEach(function (locale) {
var a = ["L", "X", "C", "k", "Z", "H", "d", "m", "w", "A", "i", "f", "y", "E", "N", "V", "g", "J", "b"];
a.sort(collator.compare);
var expected = ["A", "b", "C", "d", "E", "f", "g", "H", "i", "J", "k", "L", "m", "N", "V", "w", "X", "y", "Z"];
- testArraysAreSame(expected, a);
+ assert.compareArray(a, expected);
});
diff --git a/test/intl402/Collator/prototype/compare/10.3.2_CS_c_NN.js b/test/intl402/Collator/prototype/compare/10.3.2_CS_c_NN.js
index 62dd4da93..2b2378a13 100644
--- a/test/intl402/Collator/prototype/compare/10.3.2_CS_c_NN.js
+++ b/test/intl402/Collator/prototype/compare/10.3.2_CS_c_NN.js
@@ -8,7 +8,7 @@ description: >
Tests that the compare function supports phonebook sorting if it
says it does. This test is not normative.
author: Norbert Lindenberg
-includes: [testIntl.js]
+includes: [testIntl.js, compareArray.js]
---*/
// this test should be valid at least for the following locales
@@ -18,5 +18,5 @@ if (locales.indexOf(collator.resolvedOptions().locale) !== -1) {
var a = ["A", "b", "Af", "Ab", "od", "off", "Ä", "ö"];
a.sort(collator.compare);
var expected = ["A", "Ab", "Ä", "Af", "b", "od", "ö", "off"];
- testArraysAreSame(expected, a);
+ assert.compareArray(a, expected);
}
diff --git a/test/intl402/Collator/prototype/compare/10.3.2_CS_d_NN.js b/test/intl402/Collator/prototype/compare/10.3.2_CS_d_NN.js
index b9c56abf7..372a8e202 100644
--- a/test/intl402/Collator/prototype/compare/10.3.2_CS_d_NN.js
+++ b/test/intl402/Collator/prototype/compare/10.3.2_CS_d_NN.js
@@ -8,7 +8,7 @@ description: >
Tests that the compare function supports different sensitivity
settings. This test is not normative.
author: Norbert Lindenberg
-includes: [testIntl.js]
+includes: [testIntl.js, compareArray.js]
---*/
// this test should be valid at least for the following locales
@@ -29,6 +29,6 @@ locales.forEach(function (locale) {
var matches = input.filter(function (v) {
return collator.compare(v, target) === 0;
});
- testArraysAreSame(expected[sensitivity], matches);
+ assert.compareArray(matches, expected[sensitivity]);
});
});
diff --git a/test/intl402/Date/prototype/13.3.0_7.js b/test/intl402/Date/prototype/13.3.0_7.js
index d04a83254..39cb4b660 100644
--- a/test/intl402/Date/prototype/13.3.0_7.js
+++ b/test/intl402/Date/prototype/13.3.0_7.js
@@ -7,7 +7,7 @@ description: >
Tests that Date.prototype.toLocaleString & Co. produces the same
results as Intl.DateTimeFormat.
author: Norbert Lindenberg
-includes: [testIntl.js]
+includes: [testIntl.js, compareArray.js]
---*/
var functions = {
@@ -45,15 +45,11 @@ Object.getOwnPropertyNames(functions).forEach(function (p) {
}
var referenceDateTimeFormat = new Intl.DateTimeFormat(locales, constructorOptions);
var referenceFormatted = dates.map(referenceDateTimeFormat.format);
-
+
var formatted = dates.map(function (a) { return f.call(a, locales, options); });
- try {
- testArraysAreSame(referenceFormatted, formatted);
- } catch (e) {
- e.message += " (Testing with locales " + locales + "; options " +
- (options ? JSON.stringify(options) : options) + ".)";
- throw e;
- }
+ assert.compareArray(formatted, referenceFormatted,
+ "(Testing with locales " + locales + "; options " +
+ (options ? JSON.stringify(options) : options) + ".)");
});
});
});
diff --git a/test/intl402/DateTimeFormat/12.1.2.js b/test/intl402/DateTimeFormat/12.1.2.js
index 5265b68fd..7c8522629 100644
--- a/test/intl402/DateTimeFormat/12.1.2.js
+++ b/test/intl402/DateTimeFormat/12.1.2.js
@@ -6,7 +6,7 @@
es5id: 12.1.2
description: Tests that Intl.DateTimeFormat can be subclassed.
author: Norbert Lindenberg
-includes: [testIntl.js]
+includes: [testIntl.js, compareArray.js]
---*/
// get a date-time format and have it format an array of dates for comparison with the subclass
@@ -25,4 +25,4 @@ class MyDateTimeFormat extends Intl.DateTimeFormat {
var format = new MyDateTimeFormat(locales);
var actual = a.map(format.format);
-testArraysAreSame(referenceFormatted, actual);
+assert.compareArray(actual, referenceFormatted);
diff --git a/test/intl402/Number/prototype/toLocaleString/13.2.1_5.js b/test/intl402/Number/prototype/toLocaleString/13.2.1_5.js
index 929cb6be1..b7d36b916 100644
--- a/test/intl402/Number/prototype/toLocaleString/13.2.1_5.js
+++ b/test/intl402/Number/prototype/toLocaleString/13.2.1_5.js
@@ -7,7 +7,7 @@ description: >
Tests that Number.prototype.toLocaleString produces the same
results as Intl.NumberFormat.
author: Norbert Lindenberg
-includes: [testIntl.js]
+includes: [testIntl.js, compareArray.js]
---*/
var numbers = [0, -0, 1, -1, 5.5, 123, -123, -123.45, 123.44501, 0.001234,
@@ -29,14 +29,10 @@ locales.forEach(function (locales) {
options.forEach(function (options) {
var referenceNumberFormat = new Intl.NumberFormat(locales, options);
var referenceFormatted = numbers.map(referenceNumberFormat.format);
-
+
var formatted = numbers.map(function (a) { return a.toLocaleString(locales, options); });
- try {
- testArraysAreSame(referenceFormatted, formatted);
- } catch (e) {
- e.message += " (Testing with locales " + locales + "; options " +
- (options ? JSON.stringify(options) : options) + ".)";
- throw e;
- }
+ assert.compareArray(formatted, referenceFormatted,
+ "(Testing with locales " + locales + "; options " +
+ (options ? JSON.stringify(options) : options) + ".)");
});
});
diff --git a/test/intl402/NumberFormat/11.1.2.js b/test/intl402/NumberFormat/11.1.2.js
index 6032130c8..6335f921a 100644
--- a/test/intl402/NumberFormat/11.1.2.js
+++ b/test/intl402/NumberFormat/11.1.2.js
@@ -6,7 +6,7 @@
es5id: 11.1.2
description: Tests that Intl.NumberFormat can be subclassed.
author: Norbert Lindenberg
-includes: [testIntl.js]
+includes: [testIntl.js, compareArray.js]
---*/
// get a number format and have it format an array of numbers for comparison with the subclass
@@ -25,4 +25,4 @@ class MyNumberFormat extends Intl.NumberFormat {
var format = new MyNumberFormat(locales);
var actual = a.map(format.format);
-testArraysAreSame(referenceFormatted, actual);
+assert.compareArray(actual, referenceFormatted);
diff --git a/test/intl402/PluralRules/can-be-subclassed.js b/test/intl402/PluralRules/can-be-subclassed.js
index 57a0562f2..36ec0da27 100644
--- a/test/intl402/PluralRules/can-be-subclassed.js
+++ b/test/intl402/PluralRules/can-be-subclassed.js
@@ -5,7 +5,7 @@
esid: sec-intl-pluralrules-constructor
description: Tests that Intl.PluralRules can be subclassed.
author: Zibi Braniecki
-includes: [testIntl.js]
+includes: [testIntl.js, compareArray.js]
---*/
// get a plural-rules and have it format an array of dates for comparison with the subclass
@@ -25,4 +25,4 @@ class MyPluralRules extends Intl.PluralRules {
var pr = new MyPluralRules(locales);
var actual = a.map(pr.select.bind(pr));
-testArraysAreSame(referenceSelected, actual);
+assert.compareArray(actual, referenceSelected);
diff --git a/test/intl402/String/prototype/localeCompare/13.1.1_7.js b/test/intl402/String/prototype/localeCompare/13.1.1_7.js
index 25990ded3..171dad245 100644
--- a/test/intl402/String/prototype/localeCompare/13.1.1_7.js
+++ b/test/intl402/String/prototype/localeCompare/13.1.1_7.js
@@ -7,7 +7,7 @@ description: >
Tests that localeCompare produces the same results as
Intl.Collator.
author: Norbert Lindenberg
-includes: [testIntl.js]
+includes: [testIntl.js, compareArray.js]
---*/
var strings = ["d", "O", "od", "oe", "of", "ö", "o\u0308", "X", "y", "Z", "Z.", "𠮷野家", "吉野家", "!A", "A", "b", "C"];
@@ -22,13 +22,9 @@ locales.forEach(function (locales) {
options.forEach(function (options) {
var referenceCollator = new Intl.Collator(locales, options);
var referenceSorted = strings.slice().sort(referenceCollator.compare);
-
+
strings.sort(function (a, b) { return a.localeCompare(b, locales, options); });
- try {
- testArraysAreSame(referenceSorted, strings);
- } catch (e) {
- e.message += " (Testing with locales " + locales + "; options " + JSON.stringify(options) + ".)";
- throw e;
- }
+ assert.compareArray(strings, referenceSorted,
+ "(Testing with locales " + locales + "; options " + JSON.stringify(options) + ".)");
});
});