Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: test/snippets.js

Issue 29853555: Issue 6853 - Add unit tests for quirks in snippet script parsing (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Aug. 11, 2018, 6:16 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 [["f\ud83d\ude42\ud83d\ude42", "b\ud83d\ude02r"]]); 181 [["f\ud83d\ude42\ud83d\ude42", "b\ud83d\ude02r"]]);
182 checkParsedScript("Script with no-op commands", "foo; ;;; ; ; bar 1", 182 checkParsedScript("Script with no-op commands", "foo; ;;; ; ; bar 1",
183 [["foo"], ["bar", "1"]]); 183 [["foo"], ["bar", "1"]]);
184 checkParsedScript("Script with blank argument in the middle", "foo '' Hello", 184 checkParsedScript("Script with blank argument in the middle", "foo '' Hello",
185 [["foo", "", "Hello"]]); 185 [["foo", "", "Hello"]]);
186 checkParsedScript("Script with blank argument at the end", "foo Hello ''", 186 checkParsedScript("Script with blank argument at the end", "foo Hello ''",
187 [["foo", "Hello", ""]]); 187 [["foo", "Hello", ""]]);
188 checkParsedScript("Script with consecutive blank arguments", "foo '' ''", 188 checkParsedScript("Script with consecutive blank arguments", "foo '' ''",
189 [["foo", "", ""]]); 189 [["foo", "", ""]]);
190 190
191 // Undocumented quirks (#6853).
192 checkParsedScript("Script with quotes within an argument", "foo Hello''world",
193 [["foo", "Helloworld"]]);
194 checkParsedScript("Script with quotes within an argument containing whitespace ",
195 "foo Hello' 'world",
196 [["foo", "Hello world"]]);
197 checkParsedScript("Script with quotes within an argument containing non-whites pace",
198 "foo Hello','world",
199 [["foo", "Hello,world"]]);
200 checkParsedScript("Script with quotes within an argument containing whitespace and non-whitespace",
201 "foo Hello', 'world",
202 [["foo", "Hello, world"]]);
203 checkParsedScript("Script with opening quote at the beginning of an argument",
204 "foo 'Hello, 'world",
205 [["foo", "Hello, world"]]);
206 checkParsedScript("Script with closing quote at the end of an argument",
207 "foo Hello,' world'",
208 [["foo", "Hello, world"]]);
209
210 checkParsedScript("Script with closing quote missing", "foo 'Hello, world",
211 []);
212 checkParsedScript("Script with closing quote missing in last command",
213 "foo Hello; bar 'How are you?",
214 [["foo", "Hello"]]);
215 checkParsedScript("Script ending with a backslash",
216 "foo Hello; bar 'How are you?' \\",
217 [["foo", "Hello"]]);
218
191 test.done(); 219 test.done();
192 }; 220 };
193 221
194 exports.testScriptCompilation = function(test) 222 exports.testScriptCompilation = function(test)
195 { 223 {
196 let libraries = [ 224 let libraries = [
197 ` 225 `
198 let foo = 0; 226 let foo = 0;
199 227
200 exports.setFoo = function(value) 228 exports.setFoo = function(value)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // between executions. In the example below, assertFoo does not find 456 but 281 // between executions. In the example below, assertFoo does not find 456 but
254 // it doesn't find 123 either. It's the initial value 0. 282 // it doesn't find 123 either. It's the initial value 0.
255 new Function( 283 new Function(
256 compileScript("setFoo 456; assertFoo 0", [ 284 compileScript("setFoo 456; assertFoo 0", [
257 ...libraries, "let foo = 1; exports.setFoo = value => { foo = value; };" 285 ...libraries, "let foo = 1; exports.setFoo = value => { foo = value; };"
258 ]) 286 ])
259 )(); 287 )();
260 288
261 test.done(); 289 test.done();
262 }; 290 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld