[Pkg-javascript-commits] [node-acorn-jsx] 415/484: Add regex comparison to test driver.
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:21:04 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-acorn-jsx.
commit cb94a0851c5574d9f5380e805cca698c0b0bec83
Author: Ingvar Stepanyan <me at rreverser.com>
Date: Fri Jan 23 13:50:01 2015 +0200
Add regex comparison to test driver.
---
test/driver.js | 5 ++++-
test/tests-harmony.js | 38 +++++++++++++++++++-------------------
test/tests.js | 18 +++++++++---------
3 files changed, 32 insertions(+), 29 deletions(-)
diff --git a/test/driver.js b/test/driver.js
index c76b8f9..7b7dee8 100644
--- a/test/driver.js
+++ b/test/driver.js
@@ -66,7 +66,7 @@
}
};
- function ppJSON(v) { return JSON.stringify(v, null, 2); }
+ function ppJSON(v) { return v instanceof RegExp ? v.toString() : JSON.stringify(v, null, 2); }
function addPath(str, pt) {
if (str.charAt(str.length-1) == ")")
return str.slice(0, str.length-1) + "/" + pt + ")";
@@ -76,6 +76,9 @@
var misMatch = exports.misMatch = function(exp, act) {
if (!exp || !act || (typeof exp != "object") || (typeof act != "object")) {
if (exp !== act) return ppJSON(exp) + " !== " + ppJSON(act);
+ } else if (exp instanceof RegExp || act instanceof RegExp) {
+ var left = ppJSON(exp), right = ppJSON(act);
+ if (left !== right) return left + " !== " + right;
} else if (exp.splice) {
if (!act.slice) return ppJSON(exp) + " != " + ppJSON(act);
if (act.length != exp.length) return "array length mismatch " + exp.length + " != " + act.length;
diff --git a/test/tests-harmony.js b/test/tests-harmony.js
index 07bf912..c0c74b8 100644
--- a/test/tests-harmony.js
+++ b/test/tests-harmony.js
@@ -14783,47 +14783,47 @@ test("class A { *static() {} }", {
locations: true
});
-test("`${/\d/.exec('1')[0]}`", {
+test("`${/\\d/.exec('1')[0]}`", {
"type": "Program",
"start": 0,
- "end": 21,
+ "end": 22,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
- "end": 21,
+ "end": 22,
"expression": {
"type": "TemplateLiteral",
"start": 0,
- "end": 21,
+ "end": 22,
"expressions": [
{
"type": "MemberExpression",
"start": 3,
- "end": 19,
+ "end": 20,
"object": {
"type": "CallExpression",
"start": 3,
- "end": 16,
+ "end": 17,
"callee": {
"type": "MemberExpression",
"start": 3,
- "end": 11,
+ "end": 12,
"object": {
"type": "Literal",
"start": 3,
- "end": 6,
+ "end": 7,
"regex": {
- "pattern": "d",
+ "pattern": "\\d",
"flags": ""
},
- "value": {},
- "raw": "/d/"
+ "value": /\d/,
+ "raw": "/\\d/"
},
"property": {
"type": "Identifier",
- "start": 7,
- "end": 11,
+ "start": 8,
+ "end": 12,
"name": "exec"
},
"computed": false
@@ -14831,8 +14831,8 @@ test("`${/\d/.exec('1')[0]}`", {
"arguments": [
{
"type": "Literal",
- "start": 12,
- "end": 15,
+ "start": 13,
+ "end": 16,
"value": "1",
"raw": "'1'"
}
@@ -14840,8 +14840,8 @@ test("`${/\d/.exec('1')[0]}`", {
},
"property": {
"type": "Literal",
- "start": 17,
- "end": 18,
+ "start": 18,
+ "end": 19,
"value": 0,
"raw": "0"
},
@@ -14861,8 +14861,8 @@ test("`${/\d/.exec('1')[0]}`", {
},
{
"type": "TemplateElement",
- "start": 20,
- "end": 20,
+ "start": 21,
+ "end": 21,
"value": {
"raw": "",
"cooked": ""
diff --git a/test/tests.js b/test/tests.js
index dee69bb..d3beafc 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -169,7 +169,7 @@ test("/[a-z]/g", {
type: "ExpressionStatement",
expression: {
type: "Literal",
- value: /[a-z]/,
+ value: /[a-z]/g,
regex: {
pattern: "[a-z]",
flags: "g"
@@ -7331,7 +7331,7 @@ test("var x = /[a-z]/i", {
},
init: {
type: "Literal",
- value: {},
+ value: /[a-z]/i,
loc: {
start: {
line: 1,
@@ -7404,7 +7404,7 @@ test("var x = /[x-z]/i", {
},
init: {
type: "Literal",
- value: {},
+ value: /[x-z]/i,
loc: {
start: {
line: 1,
@@ -7477,7 +7477,7 @@ test("var x = /[a-c]/i", {
},
init: {
type: "Literal",
- value: {},
+ value: /[a-c]/i,
loc: {
start: {
line: 1,
@@ -7550,7 +7550,7 @@ test("var x = /[P QR]/i", {
},
init: {
type: "Literal",
- value: {},
+ value: /[P QR]/i,
loc: {
start: {
line: 1,
@@ -7623,7 +7623,7 @@ test("var x = /foo\\/bar/", {
},
init: {
type: "Literal",
- value: {},
+ value: /foo\/bar/,
loc: {
start: {
line: 1,
@@ -7696,7 +7696,7 @@ test("var x = /=([^=\\s])+/g", {
},
init: {
type: "Literal",
- value: {},
+ value: /=([^=\s])+/g,
loc: {
start: {
line: 1,
@@ -7769,7 +7769,7 @@ test("var x = /[P QR]/\\u0067", {
},
init: {
type: "Literal",
- value: {},
+ value: /[P QR]/g,
loc: {
start: {
line: 1,
@@ -28902,7 +28902,7 @@ test("function f() {} / 1 /", {
expression: {
type: "Literal",
regex: {pattern: " 1 ", flags: ""},
- value: {}
+ value: / 1 /
}
}
]
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git
More information about the Pkg-javascript-commits
mailing list