From fa9aae7750211323c1ffc4bf1f7b43be04e86287 Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Mon, 24 Apr 2017 15:31:48 -0400 Subject: [PATCH] Use assert api instead of $ERROR --- .../RegExp-control-escape-russian-letter.js | 22 ++++-------------- .../RegExp-decimal-escape-class-range.js | 23 ++++--------------- .../RegExp-decimal-escape-not-capturing.js | 7 ++---- .../built-ins/escape/B.2.1.propertyCheck.js | 11 --------- .../escape/{B.2.1.js => prop-desc.js} | 11 +++++---- .../built-ins/unescape/B.2.2.propertyCheck.js | 11 --------- .../unescape/{B.2.2.js => prop-desc.js} | 11 ++++++--- 7 files changed, 26 insertions(+), 70 deletions(-) delete mode 100644 test/annexB/built-ins/escape/B.2.1.propertyCheck.js rename test/annexB/built-ins/escape/{B.2.1.js => prop-desc.js} (60%) delete mode 100644 test/annexB/built-ins/unescape/B.2.2.propertyCheck.js rename test/annexB/built-ins/unescape/{B.2.2.js => prop-desc.js} (59%) diff --git a/test/annexB/built-ins/RegExp/RegExp-control-escape-russian-letter.js b/test/annexB/built-ins/RegExp/RegExp-control-escape-russian-letter.js index 33dd5fb05e..851b881433 100644 --- a/test/annexB/built-ins/RegExp/RegExp-control-escape-russian-letter.js +++ b/test/annexB/built-ins/RegExp/RegExp-control-escape-russian-letter.js @@ -9,29 +9,15 @@ description: "ControlLetter :: RUSSIAN ALPHABET is incorrect" ---*/ //CHECK#0410-042F -var result = true; for (var alpha = 0x0410; alpha <= 0x042F; alpha++) { var str = String.fromCharCode(alpha % 32); - var arr = (new RegExp("\\c" + String.fromCharCode(alpha))).exec(str); - if (arr !== null) { - result = false; - } -} - -if (result !== true) { - $ERROR('#1: RUSSIAN CAPITAL ALPHABET is incorrect'); + var arr = (new RegExp("\\c" + String.fromCharCode(alpha))).exec(str); + assert.sameValue(arr, null, 'RUSSIAN CAPITAL ALPHABET: ' + alpha); } //CHECK#0430-044F -var result = true; for (alpha = 0x0430; alpha <= 0x044F; alpha++) { str = String.fromCharCode(alpha % 32); - arr = (new RegExp("\\c" + String.fromCharCode(alpha))).exec(str); - if (arr !== null) { - result = false; - } -} - -if (result !== true) { - $ERROR('#2: russian small alphabet is incorrect'); + arr = (new RegExp("\\c" + String.fromCharCode(alpha))).exec(str); + assert.sameValue(arr, null, 'russian small alphabet: ' + alpha); } diff --git a/test/annexB/built-ins/RegExp/RegExp-decimal-escape-class-range.js b/test/annexB/built-ins/RegExp/RegExp-decimal-escape-class-range.js index a6646230f3..a5bd7ea83a 100644 --- a/test/annexB/built-ins/RegExp/RegExp-decimal-escape-class-range.js +++ b/test/annexB/built-ins/RegExp/RegExp-decimal-escape-class-range.js @@ -19,24 +19,11 @@ var __expected = ["1\n\n\n\n\nl"]; __expected.index = 4; __expected.input = "line1\n\n\n\n\nline2"; -//CHECK#1 -if (__executed.length !== __expected.length) { - $ERROR('#1: __executed = /[\\d][\\12-\\14]{1,}[^\\d]/.exec("line1\\n\\n\\n\\n\\nline2"); __executed.length === ' + __expected.length + '. Actual: ' + __executed.length); -} - -//CHECK#2 -if (__executed.index !== __expected.index) { - $ERROR('#2: __executed = /[\\d][\\12-\\14]{1,}[^\\d]/.exec("line1\\n\\n\\n\\n\\nline2"); __executed.index === ' + __expected.index + '. Actual: ' + __executed.index); -} - -//CHECK#3 -if (__executed.input !== __expected.input) { - $ERROR('#3: __executed = /[\\d][\\12-\\14]{1,}[^\\d]/.exec("line1\\n\\n\\n\\n\\nline2"); __executed.input === ' + __expected.input + '. Actual: ' + __executed.input); -} +assert.sameValue(__executed.length, __expected.length, '.length'); +assert.sameValue(__executed.index, __expected.index, '.index'); +assert.sameValue(__executed.input, __expected.input, '.input'); //CHECK#4 -for(var index=0; index<__expected.length; index++) { - if (__executed[index] !== __expected[index]) { - $ERROR('#4: __executed = /[\\d][\\12-\\14]{1,}[^\\d]/.exec("line1\\n\\n\\n\\n\\nline2"); __executed[' + index + '] === ' + __expected[index] + '. Actual: ' + __executed[index]); - } +for(var index=0; index < __expected.length; index++) { + assert.sameValue(__executed[index], __expected[index], 'index: ' + index); } diff --git a/test/annexB/built-ins/RegExp/RegExp-decimal-escape-not-capturing.js b/test/annexB/built-ins/RegExp/RegExp-decimal-escape-not-capturing.js index 219cf0b77d..a677b6e454 100644 --- a/test/annexB/built-ins/RegExp/RegExp-decimal-escape-not-capturing.js +++ b/test/annexB/built-ins/RegExp/RegExp-decimal-escape-not-capturing.js @@ -13,9 +13,6 @@ description: > check results ---*/ -var __executed = /\b(\w+) \2\b/.test("do you listen the the band"); +var executed = /\b(\w+) \2\b/.test("do you listen the the band"); -//CHECK#1 -if (__executed) { - $ERROR('#1: /\\b(\\w+) \\2\\b/.test("do you listen the the band") === false'); -} +assert.sameValue(executed, false); diff --git a/test/annexB/built-ins/escape/B.2.1.propertyCheck.js b/test/annexB/built-ins/escape/B.2.1.propertyCheck.js deleted file mode 100644 index 9d1179c4e0..0000000000 --- a/test/annexB/built-ins/escape/B.2.1.propertyCheck.js +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: Check type of various properties -es5id: B.2.1 -description: Checking properties of this object (escape) ----*/ - -if (typeof this.escape === "undefined") $ERROR('#1: typeof this.escape !== "undefined"'); -if (typeof this['escape'] === "undefined") $ERROR('#2: typeof this["escape"] !== "undefined"'); diff --git a/test/annexB/built-ins/escape/B.2.1.js b/test/annexB/built-ins/escape/prop-desc.js similarity index 60% rename from test/annexB/built-ins/escape/B.2.1.js rename to test/annexB/built-ins/escape/prop-desc.js index 6c23ce7600..7867e0afa8 100644 --- a/test/annexB/built-ins/escape/B.2.1.js +++ b/test/annexB/built-ins/escape/prop-desc.js @@ -9,8 +9,11 @@ description: > includes: [propertyHelper.js] ---*/ -var global = this; +assert.sameValue(typeof this.escape, "function"); +assert.sameValue(typeof this["escape"], "function"); -verifyWritable(global, "escape"); -verifyNotEnumerable(global, "escape"); -verifyConfigurable(global, "escape"); +verifyProperty(this, "escape", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/annexB/built-ins/unescape/B.2.2.propertyCheck.js b/test/annexB/built-ins/unescape/B.2.2.propertyCheck.js deleted file mode 100644 index bd3f6e56e9..0000000000 --- a/test/annexB/built-ins/unescape/B.2.2.propertyCheck.js +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: Check type of various properties -es5id: B.2.2 -description: Checking properties of this object (unescape) ----*/ - -if (typeof this.unescape === "undefined") $ERROR('#1: typeof this.unescape !== "undefined"'); -if (typeof this['unescape'] === "undefined") $ERROR('#2: typeof this["unescape"] !== "undefined"'); diff --git a/test/annexB/built-ins/unescape/B.2.2.js b/test/annexB/built-ins/unescape/prop-desc.js similarity index 59% rename from test/annexB/built-ins/unescape/B.2.2.js rename to test/annexB/built-ins/unescape/prop-desc.js index 04e65cf55e..65b9292db9 100644 --- a/test/annexB/built-ins/unescape/B.2.2.js +++ b/test/annexB/built-ins/unescape/prop-desc.js @@ -9,6 +9,11 @@ description: > includes: [propertyHelper.js] ---*/ -verifyWritable(this, "unescape"); -verifyNotEnumerable(this, "unescape"); -verifyConfigurable(this, "unescape"); +assert.sameValue(typeof this.unescape, "function"); +assert.sameValue(typeof this["unescape"], "function"); + +verifyProperty(this, "unescape", { + writable: true, + enumerable: false, + configurable: true +});