From 5e785c10f4a285c3e16a871705234be1631fdef3 Mon Sep 17 00:00:00 2001 From: Shawn Silverman Date: Thu, 13 Aug 2020 20:35:33 -0700 Subject: [PATCH] Fix ECMA 262 \Z and \z tests The old test was incorrect because "\Z" is actually valid. It matches a literal Z in ECMA 262. --- .../optional/ecmascript-regex.json | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/tests/draft2019-09/optional/ecmascript-regex.json b/tests/draft2019-09/optional/ecmascript-regex.json index b9412e02..fe36d5dd 100644 --- a/tests/draft2019-09/optional/ecmascript-regex.json +++ b/tests/draft2019-09/optional/ecmascript-regex.json @@ -4,8 +4,46 @@ "schema": { "format": "regex" }, "tests": [ { - "description": "ECMA 262 has no support for \\Z anchor from .NET", + "description": "ECMA 262 has no support for \\Z anchor, but it's still a valid regex", "data": "^\\S(|(.|\\n)*\\S)\\Z", + "valid": true + } + ] + }, + { + "description": "ECMA 262 regex non-compliance", + "schema": { + "type": "string", + "pattern": "^x\\Z" + }, + "tests": [ + { + "description": "\\Z should match literal Z", + "data": "xZ", + "valid": true + }, + { + "description": "\\Z should not match end", + "data": "x", + "valid": false + } + ] + }, + { + "description": "ECMA 262 regex non-compliance", + "schema": { + "type": "string", + "pattern": "^x\\z" + }, + "tests": [ + { + "description": "\\z should match literal z", + "data": "xz", + "valid": true + }, + { + "description": "\\z should not match end", + "data": "x", "valid": false } ]