summaryrefslogtreecommitdiff
path: root/harness
diff options
context:
space:
mode:
authorAndré Bargull <andre.bargull@gmail.com>2017-04-18 22:31:31 +0200
committerLeo Balter <leonardo.balter@gmail.com>2017-04-18 16:31:31 -0400
commit94f6003d112f4b4c844f90f2e4f05bd3e1e3e740 (patch)
tree87ffd734f89b4991302849b1cd110efac5087013 /harness
parentd354788f6f610b1a07b58d60c66b27d5ce0a9cb6 (diff)
downloadqtdeclarative-testsuites-94f6003d112f4b4c844f90f2e4f05bd3e1e3e740.tar.gz
Optimize decodeURI/encodeURI tests (#987)
* Move decimalToHexString into harness instead of duplicating it in multiple files * Optimize decimalToHexString and support numbers greater than 65535 * Replace alternative decimalToHexString function with include for decimalToHexString.js * Add decimalToHex2String to return the string representation of a two-digit hex-number * Replace decimalToHex2String with decimalToPercentHexString to return the percent hex-encoded string of a two-digit hex-number * Replace two String.fromCharCode calls with a single call * Further reduce string concatentations in decodeURI[Component] tests * Remove unnecessary Test262Error error handling in catch-clauses * Remove try/catch wrappings in decodeURI/encodeURI tests
Diffstat (limited to 'harness')
-rw-r--r--harness/decimalToHexString.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/harness/decimalToHexString.js b/harness/decimalToHexString.js
new file mode 100644
index 000000000..36a2bb5b4
--- /dev/null
+++ b/harness/decimalToHexString.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+function decimalToHexString(n) {
+ var hex = "0123456789ABCDEF";
+ n >>>= 0;
+ var s = "";
+ while (n) {
+ s = hex[n & 0xf] + s;
+ n >>>= 4;
+ }
+ while (s.length < 4) {
+ s = "0" + s;
+ }
+ return s;
+}
+
+function decimalToPercentHexString(n) {
+ var hex = "0123456789ABCDEF";
+ return "%" + hex[(n >> 4) & 0xf] + hex[n & 0xf];
+}