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

Side by Side Diff: test/snippets.js

Issue 29852568: Issue 6811 - Parse blank arguments to snippets correctly (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Aug. 10, 2018, 3:25 p.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 | « lib/snippets.js ('k') | 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 checkParsedScript("Script with command names containing " + 174 checkParsedScript("Script with command names containing " +
175 "whitespace (spaces, tabs, newlines, etc.), " + 175 "whitespace (spaces, tabs, newlines, etc.), " +
176 "quotes, and semicolons", 176 "quotes, and semicolons",
177 "fo\\'\\ \\ \\\t\\\n\\;o 1 2 3; 'b a r' 1 2", 177 "fo\\'\\ \\ \\\t\\\n\\;o 1 2 3; 'b a r' 1 2",
178 [["fo' \t\n;o", "1", "2", "3"], ["b a r", "1", "2"]]); 178 [["fo' \t\n;o", "1", "2", "3"], ["b a r", "1", "2"]]);
179 checkParsedScript("Script containing Unicode composite characters", 179 checkParsedScript("Script containing Unicode composite characters",
180 "f\ud83d\ude42\ud83d\ude42 b\ud83d\ude02r", 180 "f\ud83d\ude42\ud83d\ude42 b\ud83d\ude02r",
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",
185 [["foo", "", "Hello"]]);
186 checkParsedScript("Script with blank argument at the end", "foo Hello ''",
187 [["foo", "Hello", ""]]);
188 checkParsedScript("Script with consecutive blank arguments", "foo '' ''",
189 [["foo", "", ""]]);
184 190
185 test.done(); 191 test.done();
186 }; 192 };
187 193
188 exports.testScriptCompilation = function(test) 194 exports.testScriptCompilation = function(test)
189 { 195 {
190 let libraries = [ 196 let libraries = [
191 ` 197 `
192 let foo = 0; 198 let foo = 0;
193 199
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // between executions. In the example below, assertFoo does not find 456 but 253 // between executions. In the example below, assertFoo does not find 456 but
248 // it doesn't find 123 either. It's the initial value 0. 254 // it doesn't find 123 either. It's the initial value 0.
249 new Function( 255 new Function(
250 compileScript("setFoo 456; assertFoo 0", [ 256 compileScript("setFoo 456; assertFoo 0", [
251 ...libraries, "let foo = 1; exports.setFoo = value => { foo = value; };" 257 ...libraries, "let foo = 1; exports.setFoo = value => { foo = value; };"
252 ]) 258 ])
253 )(); 259 )();
254 260
255 test.done(); 261 test.done();
256 }; 262 };
OLDNEW
« no previous file with comments | « lib/snippets.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld