@@ -12853,6 +12853,150 @@ describe("Grammar Tests", function() {
1285312853 expect(tokens[3][13].scopes).toEqual(["source.python","comment.line.number-sign.python"]);
1285412854 });
1285512855
12856+ it("test/strings/bug1.py",
12857+ function() {
12858+ tokens = grammar.tokenizeLines("# issue 150\nrecord = {\n \"a\": {k: str(v) for k, v in foo if \"\"}\n}")
12859+ expect(tokens[0][0].value).toBe("#");
12860+ expect(tokens[0][0].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]);
12861+ expect(tokens[0][1].value).toBe(" issue 150");
12862+ expect(tokens[0][1].scopes).toEqual(["source.python","comment.line.number-sign.python"]);
12863+ expect(tokens[1][0].value).toBe("record");
12864+ expect(tokens[1][0].scopes).toEqual(["source.python"]);
12865+ expect(tokens[1][1].value).toBe(" ");
12866+ expect(tokens[1][1].scopes).toEqual(["source.python"]);
12867+ expect(tokens[1][2].value).toBe("=");
12868+ expect(tokens[1][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]);
12869+ expect(tokens[1][3].value).toBe(" ");
12870+ expect(tokens[1][3].scopes).toEqual(["source.python"]);
12871+ expect(tokens[1][4].value).toBe("{");
12872+ expect(tokens[1][4].scopes).toEqual(["source.python","punctuation.definition.dict.begin.python"]);
12873+ expect(tokens[2][0].value).toBe(" ");
12874+ expect(tokens[2][0].scopes).toEqual(["source.python"]);
12875+ expect(tokens[2][1].value).toBe("\"");
12876+ expect(tokens[2][1].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]);
12877+ expect(tokens[2][2].value).toBe("a");
12878+ expect(tokens[2][2].scopes).toEqual(["source.python","string.quoted.single.python"]);
12879+ expect(tokens[2][3].value).toBe("\"");
12880+ expect(tokens[2][3].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]);
12881+ expect(tokens[2][4].value).toBe(":");
12882+ expect(tokens[2][4].scopes).toEqual(["source.python","punctuation.separator.dict.python"]);
12883+ expect(tokens[2][5].value).toBe(" ");
12884+ expect(tokens[2][5].scopes).toEqual(["source.python"]);
12885+ expect(tokens[2][6].value).toBe("{");
12886+ expect(tokens[2][6].scopes).toEqual(["source.python","punctuation.definition.dict.begin.python"]);
12887+ expect(tokens[2][7].value).toBe("k");
12888+ expect(tokens[2][7].scopes).toEqual(["source.python"]);
12889+ expect(tokens[2][8].value).toBe(":");
12890+ expect(tokens[2][8].scopes).toEqual(["source.python","punctuation.separator.dict.python"]);
12891+ expect(tokens[2][9].value).toBe(" ");
12892+ expect(tokens[2][9].scopes).toEqual(["source.python"]);
12893+ expect(tokens[2][10].value).toBe("str");
12894+ expect(tokens[2][10].scopes).toEqual(["source.python","meta.function-call.python","support.type.python"]);
12895+ expect(tokens[2][11].value).toBe("(");
12896+ expect(tokens[2][11].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]);
12897+ expect(tokens[2][12].value).toBe("v");
12898+ expect(tokens[2][12].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.arguments.python"]);
12899+ expect(tokens[2][13].value).toBe(")");
12900+ expect(tokens[2][13].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.end.python"]);
12901+ expect(tokens[2][14].value).toBe(" ");
12902+ expect(tokens[2][14].scopes).toEqual(["source.python"]);
12903+ expect(tokens[2][15].value).toBe("for");
12904+ expect(tokens[2][15].scopes).toEqual(["source.python","keyword.control.flow.python"]);
12905+ expect(tokens[2][16].value).toBe(" ");
12906+ expect(tokens[2][16].scopes).toEqual(["source.python"]);
12907+ expect(tokens[2][17].value).toBe("k");
12908+ expect(tokens[2][17].scopes).toEqual(["source.python"]);
12909+ expect(tokens[2][18].value).toBe(",");
12910+ expect(tokens[2][18].scopes).toEqual(["source.python","punctuation.separator.element.python"]);
12911+ expect(tokens[2][19].value).toBe(" ");
12912+ expect(tokens[2][19].scopes).toEqual(["source.python"]);
12913+ expect(tokens[2][20].value).toBe("v");
12914+ expect(tokens[2][20].scopes).toEqual(["source.python"]);
12915+ expect(tokens[2][21].value).toBe(" ");
12916+ expect(tokens[2][21].scopes).toEqual(["source.python"]);
12917+ expect(tokens[2][22].value).toBe("in");
12918+ expect(tokens[2][22].scopes).toEqual(["source.python","keyword.operator.logical.python"]);
12919+ expect(tokens[2][23].value).toBe(" ");
12920+ expect(tokens[2][23].scopes).toEqual(["source.python"]);
12921+ expect(tokens[2][24].value).toBe("foo");
12922+ expect(tokens[2][24].scopes).toEqual(["source.python"]);
12923+ expect(tokens[2][25].value).toBe(" ");
12924+ expect(tokens[2][25].scopes).toEqual(["source.python"]);
12925+ expect(tokens[2][26].value).toBe("if");
12926+ expect(tokens[2][26].scopes).toEqual(["source.python","keyword.control.flow.python"]);
12927+ expect(tokens[2][27].value).toBe(" ");
12928+ expect(tokens[2][27].scopes).toEqual(["source.python"]);
12929+ expect(tokens[2][28].value).toBe("\"");
12930+ expect(tokens[2][28].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]);
12931+ expect(tokens[2][29].value).toBe("\"");
12932+ expect(tokens[2][29].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]);
12933+ expect(tokens[2][30].value).toBe("}");
12934+ expect(tokens[2][30].scopes).toEqual(["source.python","punctuation.definition.dict.end.python"]);
12935+ expect(tokens[3][0].value).toBe("}");
12936+ expect(tokens[3][0].scopes).toEqual(["source.python","punctuation.definition.dict.end.python"]);
12937+ });
12938+
12939+ it("test/strings/bug2.py",
12940+ function() {
12941+ tokens = grammar.tokenizeLines("# issue 150\ncmd = \"git-clang-format --style=\\\"{{BasedOnStyle: Google, ColumnLimit: 100, IndentWidth: 2, \" \\\n \"AlignConsecutiveAssignments: true}}\\\" {COMMIT_SHA} -- ./**/*.proto > {OUTPUT}\".format(")
12942+ expect(tokens[0][0].value).toBe("#");
12943+ expect(tokens[0][0].scopes).toEqual(["source.python","comment.line.number-sign.python","punctuation.definition.comment.python"]);
12944+ expect(tokens[0][1].value).toBe(" issue 150");
12945+ expect(tokens[0][1].scopes).toEqual(["source.python","comment.line.number-sign.python"]);
12946+ expect(tokens[1][0].value).toBe("cmd");
12947+ expect(tokens[1][0].scopes).toEqual(["source.python"]);
12948+ expect(tokens[1][1].value).toBe(" ");
12949+ expect(tokens[1][1].scopes).toEqual(["source.python"]);
12950+ expect(tokens[1][2].value).toBe("=");
12951+ expect(tokens[1][2].scopes).toEqual(["source.python","keyword.operator.assignment.python"]);
12952+ expect(tokens[1][3].value).toBe(" ");
12953+ expect(tokens[1][3].scopes).toEqual(["source.python"]);
12954+ expect(tokens[1][4].value).toBe("\"");
12955+ expect(tokens[1][4].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]);
12956+ expect(tokens[1][5].value).toBe("git-clang-format --style=");
12957+ expect(tokens[1][5].scopes).toEqual(["source.python","string.quoted.single.python"]);
12958+ expect(tokens[1][6].value).toBe("\\\"");
12959+ expect(tokens[1][6].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.escape.python"]);
12960+ expect(tokens[1][7].value).toBe("{{");
12961+ expect(tokens[1][7].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]);
12962+ expect(tokens[1][8].value).toBe("BasedOnStyle: Google, ColumnLimit: 100, IndentWidth: 2, ");
12963+ expect(tokens[1][8].scopes).toEqual(["source.python","string.quoted.single.python"]);
12964+ expect(tokens[1][9].value).toBe("\"");
12965+ expect(tokens[1][9].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]);
12966+ expect(tokens[1][10].value).toBe(" ");
12967+ expect(tokens[1][10].scopes).toEqual(["source.python"]);
12968+ expect(tokens[1][11].value).toBe("\\");
12969+ expect(tokens[1][11].scopes).toEqual(["source.python","punctuation.separator.continuation.line.python"]);
12970+ expect(tokens[1][12].value).toBe("");
12971+ expect(tokens[1][12].scopes).toEqual(["source.python"]);
12972+ expect(tokens[2][0].value).toBe(" ");
12973+ expect(tokens[2][0].scopes).toEqual(["source.python"]);
12974+ expect(tokens[2][1].value).toBe("\"");
12975+ expect(tokens[2][1].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.begin.python"]);
12976+ expect(tokens[2][2].value).toBe("AlignConsecutiveAssignments: true");
12977+ expect(tokens[2][2].scopes).toEqual(["source.python","string.quoted.single.python"]);
12978+ expect(tokens[2][3].value).toBe("}}");
12979+ expect(tokens[2][3].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]);
12980+ expect(tokens[2][4].value).toBe("\\\"");
12981+ expect(tokens[2][4].scopes).toEqual(["source.python","string.quoted.single.python","constant.character.escape.python"]);
12982+ expect(tokens[2][5].value).toBe(" ");
12983+ expect(tokens[2][5].scopes).toEqual(["source.python","string.quoted.single.python"]);
12984+ expect(tokens[2][6].value).toBe("{COMMIT_SHA}");
12985+ expect(tokens[2][6].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]);
12986+ expect(tokens[2][7].value).toBe(" -- ./**/*.proto > ");
12987+ expect(tokens[2][7].scopes).toEqual(["source.python","string.quoted.single.python"]);
12988+ expect(tokens[2][8].value).toBe("{OUTPUT}");
12989+ expect(tokens[2][8].scopes).toEqual(["source.python","string.quoted.single.python","meta.format.brace.python","constant.character.format.placeholder.other.python"]);
12990+ expect(tokens[2][9].value).toBe("\"");
12991+ expect(tokens[2][9].scopes).toEqual(["source.python","string.quoted.single.python","punctuation.definition.string.end.python"]);
12992+ expect(tokens[2][10].value).toBe(".");
12993+ expect(tokens[2][10].scopes).toEqual(["source.python","punctuation.separator.period.python"]);
12994+ expect(tokens[2][11].value).toBe("format");
12995+ expect(tokens[2][11].scopes).toEqual(["source.python","meta.function-call.python","meta.function-call.generic.python"]);
12996+ expect(tokens[2][12].value).toBe("(");
12997+ expect(tokens[2][12].scopes).toEqual(["source.python","meta.function-call.python","punctuation.definition.arguments.begin.python"]);
12998+ });
12999+
1285613000 it("test/strings/bytes1.py",
1285713001 function() {
1285813002 tokens = grammar.tokenizeLines("a = b\"\"\"\nmultiline \"binary\" string \\\n\n \\xf1 \\u1234aaaa \\U1234aaaa\n\n \\N{BLACK SPADE SUIT}\n\"\"\"")
0 commit comments