From 95bb619096be474dca33203d3805545e1274d652 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Thu, 4 Apr 2019 17:00:17 +0200 Subject: [PATCH] Add test for #22, remove old broken test --- src/rule.ts | 26 +- src/tests/themes.test.ts | 2 +- test-cases/suite1/fixtures/Jade22.json | 964 ++ test-cases/suite1/tests.json | 66 + test-cases/themes/tests/test.jade | 27 - test-cases/themes/tests/test.jade.result | 13722 ---------------- .../themes/tests/test.jade.result.patch | 1844 --- 7 files changed, 1044 insertions(+), 15607 deletions(-) create mode 100644 test-cases/suite1/fixtures/Jade22.json delete mode 100644 test-cases/themes/tests/test.jade delete mode 100644 test-cases/themes/tests/test.jade.result delete mode 100644 test-cases/themes/tests/test.jade.result.patch diff --git a/src/rule.ts b/src/rule.ts index d9f4f19..4f34d0d 100644 --- a/src/rule.ts +++ b/src/rule.ts @@ -601,19 +601,7 @@ export class RuleFactory { ); } - if (desc.while) { - return new BeginWhileRule( - desc.$vscodeTextmateLocation, - desc.id, - desc.name, - desc.contentName, - desc.begin, RuleFactory._compileCaptures(desc.beginCaptures || desc.captures, helper, repository), - desc.while, RuleFactory._compileCaptures(desc.whileCaptures || desc.captures, helper, repository), - RuleFactory._compilePatterns(desc.patterns, helper, repository) - ); - } - - if (!desc.begin && !desc.end) { + if (typeof desc.begin === 'undefined') { if (desc.repository) { repository = mergeObjects({}, repository, desc.repository); } @@ -626,6 +614,18 @@ export class RuleFactory { ); } + if (desc.while) { + return new BeginWhileRule( + desc.$vscodeTextmateLocation, + desc.id, + desc.name, + desc.contentName, + desc.begin, RuleFactory._compileCaptures(desc.beginCaptures || desc.captures, helper, repository), + desc.while, RuleFactory._compileCaptures(desc.whileCaptures || desc.captures, helper, repository), + RuleFactory._compilePatterns(desc.patterns, helper, repository) + ); + } + return new BeginEndRule( desc.$vscodeTextmateLocation, desc.id, diff --git a/src/tests/themes.test.ts b/src/tests/themes.test.ts index d5ab31c..26a846e 100644 --- a/src/tests/themes.test.ts +++ b/src/tests/themes.test.ts @@ -113,7 +113,7 @@ class ThemeInfo { let test = new ThemeTest(THEMES_TEST_PATH, testFile, _resolvers[i]); (it(test.testName, () => { return test.evaluate(_themeDatas[i]).then(_ => { - //test.writeDiffPage(); + // test.writeDiffPage(); assert.ok(!test.hasDiff(), 'no more unpatched differences'); }); })).timeout(20000); diff --git a/test-cases/suite1/fixtures/Jade22.json b/test-cases/suite1/fixtures/Jade22.json new file mode 100644 index 0000000..0bb3f88 --- /dev/null +++ b/test-cases/suite1/fixtures/Jade22.json @@ -0,0 +1,964 @@ +{ + "fileTypes": [ + "jade" + ], + "name": "Jade", + "patterns": [ + { + "comment": "Doctype declaration.", + "match": "^(!!!|doctype)(\\s*[a-zA-Z0-9-_]+)?", + "name": "meta.tag.sgml.doctype.html" + }, + { + "begin": "^(\\s*)//-", + "comment": "Unbuffered (jade-only) comments.", + "end": "^(?!(\\1\\s)|\\s*$)", + "name": "comment.unbuffered.block.jade" + }, + { + "begin": "^(\\s*)//", + "comment": "Buffered (html) comments.", + "end": "^(?!(\\1\\s)|\\s*$)", + "name": "string.comment.buffered.block.jade", + "patterns": [ + { + "captures": { + "1": { + "name": "invalid.illegal.comment.comment.block.jade" + } + }, + "comment": "Buffered comments inside buffered comments will generate invalid html.", + "match": "^\\s*(//)(?!-)", + "name": "string.comment.buffered.block.jade" + } + ] + }, + { + "begin": "^(\\s*)-$", + "comment": "Unbuffered code block.", + "end": "^(?!(\\1\\s)|\\s*$)", + "name": "source.js", + "patterns": [ + { + "include": "source.js" + } + ] + }, + { + "begin": "^(\\s*)(script)(?=[.#(\\s])((?![^\\n]*type=)|(?=[^\\n]*(text|application)/javascript))", + "beginCaptures": { + "2": { + "name": "entity.name.tag.script.jade" + } + }, + "comment": "Script tag with JavaScript code.", + "end": "^(?!(\\1\\s)|\\s*$)", + "name": "meta.tag.other", + "patterns": [ + { + "begin": "\\G(?=\\()", + "end": "$", + "name": "stuff.tag.script.jade", + "patterns": [ + { + "include": "#tag_attributes" + } + ] + }, + { + "begin": "\\G(?=[.#])", + "end": "$", + "name": "stuff.tag.script.jade", + "patterns": [ + { + "include": "#complete_tag" + } + ] + }, + { + "include": "source.js" + } + ] + }, + { + "begin": "^(\\s*)(style)((\\.$)|(?=[.#(].*\\.$))", + "beginCaptures": { + "2": { + "name": "entity.name.tag.script.jade" + } + }, + "comment": "Style tag with CSS code.", + "end": "^(?!(\\1\\s)|\\s*$)", + "name": "meta.tag.other", + "patterns": [ + { + "begin": "\\G(?=\\()", + "end": "$", + "name": "stuff.tag.style.jade", + "patterns": [ + { + "include": "#tag_attributes" + } + ] + }, + { + "begin": "\\G(?=[.#])", + "end": "$", + "name": "stuff.tag.style.jade", + "patterns": [ + { + "include": "#complete_tag" + } + ] + }, + { + "include": "source.css" + } + ] + }, + { + "begin": "^(\\s*):(sass)(?=\\(|$)", + "beginCaptures": { + "2": { + "name": "constant.language.name.sass.filter.jade" + } + }, + "end": "^(?!(\\1\\s)|\\s*$)", + "name": "source.sass.filter.jade", + "patterns": [ + { + "include": "#tag_attributes" + }, + { + "include": "source.sass" + } + ] + }, + { + "begin": "^(\\s*):(less)(?=\\(|$)", + "beginCaptures": { + "2": { + "name": "constant.language.name.less.filter.jade" + } + }, + "end": "^(?!(\\1\\s)|\\s*$)", + "name": "source.less.filter.jade", + "patterns": [ + { + "include": "#tag_attributes" + }, + { + "include": "source.less" + } + ] + }, + { + "begin": "^(\\s*):(stylus)(?=\\(|$)", + "beginCaptures": { + "2": { + "name": "constant.language.name.stylus.filter.jade" + } + }, + "end": "^(?!(\\1\\s)|\\s*$)", + "patterns": [ + { + "include": "#tag_attributes" + }, + { + "include": "source.stylus" + } + ] + }, + { + "begin": "^(\\s*):(coffee(-?script)?)(?=\\(|$)", + "beginCaptures": { + "2": { + "name": "constant.language.name.coffeescript.filter.jade" + } + }, + "end": "^(?!(\\1\\s)|\\s*$)", + "name": "source.coffeescript.filter.jade", + "patterns": [ + { + "include": "#tag_attributes" + }, + { + "include": "source.coffee" + } + ] + }, + { + "begin": "^(\\s*)((:(?=.))|(:$))", + "beginCaptures": { + "4": { + "name": "invalid.illegal.empty.generic.filter.jade" + } + }, + "comment": "Generic Jade filter.", + "end": "^(?!(\\1\\s)|\\s*$)", + "patterns": [ + { + "begin": "\\G(?<=:)(?=.)", + "end": "$", + "name": "name.generic.filter.jade", + "patterns": [ + { + "match": "\\G\\(", + "name": "invalid.illegal.name.generic.filter.jade" + }, + { + "match": "[\\w-]", + "name": "constant.language.name.generic.filter.jade" + }, + { + "include": "#tag_attributes" + }, + { + "match": "\\W", + "name": "invalid.illegal.name.generic.filter.jade" + } + ] + } + ] + }, + { + "begin": "^(\\s*)(?=[\\w.#].*?\\.$)(?=(?:(?:(?:(?:(?:#[\\w-]+)|(?:\\.[\\w-]+))|(?:(?:[#!]\\{[^}]*\\})|(?:\\w(?:(?:[\\w:-]+[\\w-])|(?:[\\w-]*)))))(?:(?:#[\\w-]+)|(?:\\.[\\w-]+)|(?:\\((?:[^()\\'\\\"]*(?:(?:\\'(?:[^\\']|(?:(?|$", + "patterns": [ + { + "include": "#inline_jade" + }, + { + "include": "#interpolated_value" + }, + { + "include": "#interpolated_error" + } + ] + }, + { + "include": "#inline_jade" + }, + { + "include": "#embedded_html" + }, + { + "include": "#html_entity" + }, + { + "include": "#interpolated_value" + }, + { + "include": "#interpolated_error" + } + ] + }, + { + "include": "#complete_tag" + } + ] + } + ], + "repository": { + "blocks_and_includes": { + "captures": { + "1": { + "name": "storage.type.import.include.jade" + }, + "4": { + "name": "variable.control.import.include.jade" + } + }, + "comment": "Template blocks and includes.", + "match": "(extends|include|yield|append|prepend|block( (append|prepend))?)\\s+(.*)$", + "name": "meta.first-class.jade" + }, + "case_conds": { + "begin": "(default|when)((\\s+|(?=:))|$)", + "captures": { + "1": { + "name": "storage.type.function.jade" + } + }, + "comment": "Jade case conditionals.", + "end": "$", + "name": "meta.control.flow.jade", + "patterns": [ + { + "begin": "\\G(?!:)", + "end": "(?=:\\s+)|$", + "name": "js.embedded.control.flow.jade", + "patterns": [ + { + "include": "#case_when_paren" + }, + { + "include": "source.js" + } + ] + }, + { + "begin": ":\\s+", + "end": "$", + "name": "tag.case.control.flow.jade", + "patterns": [ + { + "include": "#complete_tag" + } + ] + } + ] + }, + "case_when_paren": { + "begin": "\\(", + "end": "\\)", + "name": "js.when.control.flow.jade", + "patterns": [ + { + "include": "#case_when_paren" + }, + { + "match": ":", + "name": "invalid.illegal.name.tag.jade" + }, + { + "include": "source.js" + } + ] + }, + "complete_tag": { + "begin": "(?=[\\w.#])|(:\\s*)", + "end": "(\\.?$)|(?=:.)", + "patterns": [ + { + "include": "#blocks_and_includes" + }, + { + "include": "#unbuffered_code" + }, + { + "include": "#mixin_call" + }, + { + "include": "#flow_control" + }, + { + "match": "(?<=:)\\w.*$", + "name": "invalid.illegal.name.tag.jade" + }, + { + "include": "#tag_name" + }, + { + "include": "#tag_id" + }, + { + "include": "#tag_classes" + }, + { + "include": "#tag_attributes" + }, + { + "include": "#tag_mixin_attributes" + }, + { + "captures": { + "2": { + "name": "invalid.illegal.end.tag.jade" + }, + "4": { + "name": "invalid.illegal.end.tag.jade" + } + }, + "match": "((\\.)\\s+$)|((:)\\s*$)" + }, + { + "include": "#printed_expression" + }, + { + "include": "#tag_text" + } + ] + }, + "embedded_html": { + "begin": "(?=<[^>]*>)", + "end": "$|(?=>)", + "name": "html", + "patterns": [ + { + "include": "text.html.basic" + }, + { + "include": "#interpolated_value" + }, + { + "include": "#interpolated_error" + } + ] + }, + "flow_control": { + "begin": "(for|if|else if|else|each|until|while|unless|case)(\\s+|$)", + "captures": { + "1": { + "name": "storage.type.function.jade" + } + }, + "comment": "Jade control flow.", + "end": "$", + "name": "meta.control.flow.jade", + "patterns": [ + { + "begin": "", + "end": "$", + "name": "js.embedded.control.flow.jade", + "patterns": [ + { + "include": "source.js" + } + ] + } + ] + }, + "html_entity": { + "patterns": [ + { + "match": "(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)", + "name": "constant.character.entity.html.text.jade" + }, + { + "match": "[<>&]", + "name": "invalid.illegal.html_entity.text.jade" + } + ] + }, + "inline_jade": { + "begin": "(?:?/])|\\))", + "name": "attribute_value", + "patterns": [ + { + "include": "#string" + }, + { + "include": "#js_parens" + }, + { + "include": "#js_brackets" + }, + { + "include": "#js_braces" + }, + { + "include": "source.js" + } + ] + }, + { + "begin": "(?<=[%&*-+~|<>:?/])\\s+", + "end": "$|(?=,|(?:\\s+[^!%&*-+~|<>:?/])|\\))", + "name": "attribute_value2", + "patterns": [ + { + "include": "#string" + }, + { + "include": "#js_parens" + }, + { + "include": "#js_brackets" + }, + { + "include": "#js_braces" + }, + { + "include": "source.js" + } + ] + } + ] + }, + "tag_classes": { + "captures": { + "1": { + "name": "invalid.illegal.tag.jade" + } + }, + "match": "\\.([^\\w-])?[\\w-]*", + "name": "constant.language.js" + }, + "tag_id": { + "match": "#[\\w-]+", + "name": "constant.id.tag.jade" + }, + "tag_mixin_attributes": { + "begin": "(&attributes\\()", + "captures": { + "1": { + "name": "entity.name.function.jade" + } + }, + "end": "(\\))", + "name": "meta.tag.other", + "patterns": [ + { + "match": "attributes(?=\\))", + "name": "storage.type.keyword.jade" + }, + { + "include": "source.js" + } + ] + }, + "tag_name": { + "begin": "([#!]\\{(?=.*?\\}))|(\\w(([\\w:-]+[\\w-])|([\\w-]*)))", + "end": "(\\G(?