From 6b83678f5400fbfb52ac74bc96c0bc11257b5fec Mon Sep 17 00:00:00 2001 From: thom Date: Fri, 10 Nov 2017 10:44:16 -0500 Subject: [PATCH 1/4] Added regexp tests. --- JavaScript/syntax_test_js_regexp.js | 163 ++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 JavaScript/syntax_test_js_regexp.js diff --git a/JavaScript/syntax_test_js_regexp.js b/JavaScript/syntax_test_js_regexp.js new file mode 100644 index 0000000000..df47fefc59 --- /dev/null +++ b/JavaScript/syntax_test_js_regexp.js @@ -0,0 +1,163 @@ +// SYNTAX TEST "Packages/JavaScript/JavaScript.sublime-syntax" + + // +// ^^ comment - string.regexp + + /abc/; +// ^^^^^ string.regexp +// ^ punctuation.definition.string.begin +// ^ punctuation.definition.string.end + + /ab\/c/; +// ^^^^^^^ string.regexp +// ^^ constant.character.escape.backslash + + /ab\//; +// ^^^^^^ string.regexp - comment +// ^^ constant.character.escape.backslash + + /ab\/*/; +// ^^^^^^^ string.regexp - comment +// ^^ constant.character.escape.backslash +// ^ keyword.operator.quantifier + + /abc/gimuy; +// ^^^^^^^^^^ string.regexp +// ^^^^^ keyword.other.js + + /abc//i; +// ^^^^^ string.regexp +// ^^ - string.regexp +// ^ keyword.operator.arithmetic +// ^ variable.other.readwrite + + /abc/*i; +// ^^^^^ string.regexp +// ^^ - string.regexp +// ^ keyword.operator.arithmetic - string.regexp +// ^ variable.other.readwrite + + + /a|b/; +// ^ keyword.operator.or + +// ESCAPES + + /a.c/; +// ^ constant.other.character-class.escape + + /\d\D\w\W\s\S/; +// ^^^^^^^^^^^^ constant.other.character-class.escape.backslash + + /\t\r\n\v\f\0/; +// ^^^^^^^^^^^^ constant.character.escape.backslash + + /\cAB/; +// ^^^ constant.character.escape.backslash +// ^ - constant.character.escape + + /\x0ff/; +// ^^^^ constant.character.escape.backslash +// ^ - constant.character.escape + + /\x0/; +// ^^ constant.character.escape.backslash +// ^ - constant.character.escape + + /\u12abc/; +// ^^^^^^ constant.character.escape.backslash +// ^ - constant.character.escape + + /\u12a/; +// ^^ constant.character.escape.backslash +// ^^^ - constant.character.escape + + /\b\B^$/; +// ^^^^^^ keyword.control.anchor + +// QUANTIFIERS + + /a*b+c?/; +// ^ keyword.operator.quantifier.regexp +// ^ keyword.operator.quantifier.regexp +// ^ keyword.operator.quantifier.regexp + + /a*?b+?c??/; +// ^^ keyword.operator.quantifier.regexp +// ^^ keyword.operator.quantifier.regexp +// ^^ keyword.operator.quantifier.regexp + + /a{10}b{1,2}c{1,}/; +// ^^^^ keyword.operator.quantifier +// ^^^^^ keyword.operator.quantifier +// ^^^^ keyword.operator.quantifier + + + /a{10}?b{1,2}?c{1,}?/; +// ^^^^^ keyword.operator.quantifier +// ^^^^^^ keyword.operator.quantifier +// ^^^^^ keyword.operator.quantifier + + /a{b{}c{,1}d{1, 2}/; +// ^^^^^^^^^^^^^^^^^ - keyword.operator.quantifier' + +// GROUPING + + /a(bc)d/; +// ^^^^ meta.group +// ^ punctuation.definition.group +// ^ punctuation.definition.group + + /a(?:bc)d/; +// ^^^^^^ meta.group +// ^^^ punctuation.definition.group +// ^^ punctuation.definition.group.no-capture +// ^ punctuation.definition.group + + /a(b(c)d)e/; +// ^^^^^^^ meta.group +// ^^^ meta.group meta.group +// ^ punctuation.definition.group +// ^ punctuation.definition.group +// ^ punctuation.definition.group +// ^ punctuation.definition.group + + /a(b)c\1/; +// ^^ keyword.other.back-reference + +// ASSERTIONS + + /(?=foo)/; +// ^^^^^^^ meta.group.assertion +// ^ punctuation.definition.group +// ^^ punctuation.definition.group.assertion meta.assertion.look-ahead +// ^ punctuation.definition.group + + /(?!foo)/; +// ^^^^^^^ meta.group.assertion +// ^ punctuation.definition.group +// ^^ punctuation.definition.group.assertion meta.assertion.negative-look-ahead +// ^ punctuation.definition.group + +// CHARACTER CLASSES + + /[abc]/; +// ^^^^^ constant.other.character-class.set +// ^ punctuation.definition.character-class +// ^ punctuation.definition.character-class + + /[^abc]/; +// ^^^^^^ constant.other.character-class.set +// ^ punctuation.definition.character-class +// ^ keyword.operator.negation +// ^ punctuation.definition.character-class + + /[\b]/; +// ^^ constant.character.escape.backslash - keyword.control.anchor + + /][[]]/; +// ^ - punctuation +// ^^^ constant.other.character-class.set.regexp +// ^ punctuation.definition.character-class +// ^ punctuation.definition.character-class +// ^ - punctuation From 270249f6ff4915642fbe45b732c23166f3410915 Mon Sep 17 00:00:00 2001 From: thom Date: Fri, 10 Nov 2017 10:47:57 -0500 Subject: [PATCH 2/4] Moved tests to own directory. --- JavaScript/{ => tests}/syntax_test_js.js | 0 JavaScript/{ => tests}/syntax_test_js_regexp.js | 0 JavaScript/{ => tests}/syntax_test_json.json | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename JavaScript/{ => tests}/syntax_test_js.js (100%) rename JavaScript/{ => tests}/syntax_test_js_regexp.js (100%) rename JavaScript/{ => tests}/syntax_test_json.json (100%) diff --git a/JavaScript/syntax_test_js.js b/JavaScript/tests/syntax_test_js.js similarity index 100% rename from JavaScript/syntax_test_js.js rename to JavaScript/tests/syntax_test_js.js diff --git a/JavaScript/syntax_test_js_regexp.js b/JavaScript/tests/syntax_test_js_regexp.js similarity index 100% rename from JavaScript/syntax_test_js_regexp.js rename to JavaScript/tests/syntax_test_js_regexp.js diff --git a/JavaScript/syntax_test_json.json b/JavaScript/tests/syntax_test_json.json similarity index 100% rename from JavaScript/syntax_test_json.json rename to JavaScript/tests/syntax_test_json.json From 0c05a80422cdfe75b2683bdfe598792d07930e4f Mon Sep 17 00:00:00 2001 From: thom Date: Tue, 14 Nov 2017 10:10:22 -0500 Subject: [PATCH 3/4] Moved/expanded some tests. --- JavaScript/tests/syntax_test_js.js | 14 -------------- JavaScript/tests/syntax_test_js_regexp.js | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/JavaScript/tests/syntax_test_js.js b/JavaScript/tests/syntax_test_js.js index 670f0c6bc1..2a1fa85a1d 100644 --- a/JavaScript/tests/syntax_test_js.js +++ b/JavaScript/tests/syntax_test_js.js @@ -854,20 +854,6 @@ var reg = /a+/gimy.exec('aabb') // <- string.regexp // ^^ punctuation.definition.group.no-capture.regexp -/test// 1; -// <- string.regexp.js -// ^ keyword.operator.arithmetic.js - -/test/* 1; -// <- string.regexp.js -// ^ keyword.operator.arithmetic.js -// */ - -/test/** 1; -// <- string.regexp.js -// ^^ keyword.operator.arithmetic.js -// */ - 'str'.match(/[" ]+/g); // ^^^^^^^^ string.regexp.js diff --git a/JavaScript/tests/syntax_test_js_regexp.js b/JavaScript/tests/syntax_test_js_regexp.js index df47fefc59..6d8b96c30b 100644 --- a/JavaScript/tests/syntax_test_js_regexp.js +++ b/JavaScript/tests/syntax_test_js_regexp.js @@ -25,6 +25,14 @@ // ^^^^^^^^^^ string.regexp // ^^^^^ keyword.other.js + /abc/ + gimuy; +// ^^^^^ variable.other.readwrite - string.regexp; + + /abc//* + */gimuy; +// ^^^^^ variable.other.readwrite - string.regexp; + /abc//i; // ^^^^^ string.regexp // ^^ - string.regexp @@ -37,6 +45,12 @@ // ^ keyword.operator.arithmetic - string.regexp // ^ variable.other.readwrite + /abc/**i; +// ^^^^^ string.regexp +// ^^^ - string.regexp +// ^^ keyword.operator.arithmetic - string.regexp +// ^ variable.other.readwrite + /a|b/; // ^ keyword.operator.or @@ -155,6 +169,10 @@ /[\b]/; // ^^ constant.character.escape.backslash - keyword.control.anchor + /[/]/; +// ^^^^^ string.regexp +// ^^^ constant.other.character-class.set + /][[]]/; // ^ - punctuation // ^^^ constant.other.character-class.set.regexp From 237100dd746a7a06e6db0c26c172b2f44d1e9110 Mon Sep 17 00:00:00 2001 From: thom Date: Fri, 9 Feb 2018 16:36:18 -0500 Subject: [PATCH 4/4] Improved legibility. --- JavaScript/tests/syntax_test_js_regexp.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/JavaScript/tests/syntax_test_js_regexp.js b/JavaScript/tests/syntax_test_js_regexp.js index 6d8b96c30b..e0e7732e7f 100644 --- a/JavaScript/tests/syntax_test_js_regexp.js +++ b/JavaScript/tests/syntax_test_js_regexp.js @@ -1,5 +1,7 @@ // SYNTAX TEST "Packages/JavaScript/JavaScript.sublime-syntax" +/* LITERAL */ + // // ^^ comment - string.regexp @@ -55,7 +57,7 @@ /a|b/; // ^ keyword.operator.or -// ESCAPES +/* ESCAPES */ /a.c/; // ^ constant.other.character-class.escape @@ -89,7 +91,7 @@ /\b\B^$/; // ^^^^^^ keyword.control.anchor -// QUANTIFIERS +/* QUANTIFIERS */ /a*b+c?/; // ^ keyword.operator.quantifier.regexp @@ -115,7 +117,7 @@ /a{b{}c{,1}d{1, 2}/; // ^^^^^^^^^^^^^^^^^ - keyword.operator.quantifier' -// GROUPING +/* GROUPING */ /a(bc)d/; // ^^^^ meta.group @@ -139,7 +141,7 @@ /a(b)c\1/; // ^^ keyword.other.back-reference -// ASSERTIONS +/* ASSERTIONS */ /(?=foo)/; // ^^^^^^^ meta.group.assertion @@ -153,7 +155,7 @@ // ^^ punctuation.definition.group.assertion meta.assertion.negative-look-ahead // ^ punctuation.definition.group -// CHARACTER CLASSES +/* CHARACTER CLASSES */ /[abc]/; // ^^^^^ constant.other.character-class.set