From 5b4826fd08806eed873ff3aff6379191e3934f20 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 20 Aug 2020 23:15:38 +0200 Subject: [PATCH] extra tests for escaping --- spec/search/lexer.spec.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/spec/search/lexer.spec.js b/spec/search/lexer.spec.js index 8cce5e6c0..180e77fcd 100644 --- a/spec/search/lexer.spec.js +++ b/spec/search/lexer.spec.js @@ -22,6 +22,29 @@ describe("Lexer fulltext", () => { .toEqual(["i can use \" or ` or #~=*", "without", "problem"]); }); + it("I can use backslash to escape quotes", () => { + expect(lex("hello \\\"world\\\"").fulltextTokens.map(t => t.token)) + .toEqual(["hello", '"world"']); + + expect(lex("hello \\\'world\\\'").fulltextTokens.map(t => t.token)) + .toEqual(["hello", "'world'"]); + + expect(lex("hello \\\`world\\\`").fulltextTokens.map(t => t.token)) + .toEqual(["hello", '`world`']); + + expect(lex('"hello \\\"world\\\"').fulltextTokens.map(t => t.token)) + .toEqual(['hello "world"']); + + expect(lex("'hello \\\'world\\\''").fulltextTokens.map(t => t.token)) + .toEqual(["hello 'world'"]); + + expect(lex("`hello \\\`world\\\``").fulltextTokens.map(t => t.token)) + .toEqual(["hello `world`"]); + + expect(lex("\\#token").fulltextTokens.map(t => t.token)) + .toEqual(["#token"]); + }); + it("quote inside a word does not have a special meaning", () => { const lexResult = lex("d'Artagnan is dead #hero = d'Artagnan");