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

Delta Between Two Patch Sets: test/filterClasses.js

Issue 29333474: Issue 4125 - [emscripten] Convert filter classes to C++ (Closed)
Left Patch Set: Updated unit test framework to the current state of the repository Created Nov. 24, 2016, 3:40 p.m.
Right Patch Set: Addressed comments from Patch Set 28 Created March 21, 2017, 10:04 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « test/domainRestrictions.js ('k') | test/regexpFilters_matching.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 test.ok(!(filter instanceof eval(cls)), 137 test.ok(!(filter instanceof eval(cls)),
138 "Filter " + filter.text + " isn't an instance of " + cls); 138 "Filter " + filter.text + " isn't an instance of " + cls);
139 } 139 }
140 } 140 }
141 filter.delete(); 141 filter.delete();
142 } 142 }
143 143
144 test.done(); 144 test.done();
145 }; 145 };
146 146
147 exports.testGetKnownFilter = function(test) 147 exports.testGC = function(test)
148 { 148 {
149 let filter1 = Filter.getKnownFilter("someknownfilter"); 149 let filter1 = Filter.fromText("someknownfilter");
150 test.ok(!filter1, "Unknown filter returns null"); 150 test.equal(filter1.hitCount, 0, "Initial hit count");
151
152 filter1.hitCount = 432;
151 153
152 let filter2 = Filter.fromText("someknownfilter"); 154 let filter2 = Filter.fromText("someknownfilter");
153 filter1 = Filter.getKnownFilter("someknownfilter"); 155 test.equal(filter2.hitCount, 432, "Known filter returned");
154 test.ok(filter1, "Known filter returned"); 156
155 157 filter2.hitCount = 234;
156 filter2.hitCount = 432; 158 test.equal(filter1.hitCount, 234, "Changing second wrapper modifies original a s well");
157 test.equal(filter1.hitCount, 432, "Changes on previous instance are reflected on new instance");
158 159
159 filter1.delete(); 160 filter1.delete();
160 filter2.delete(); 161 filter2.delete();
162
163 let filter3 = Filter.fromText("someknownfilter");
164 test.equal(filter3.hitCount, 0, "Filter data has been reset once previous inst ances have been released");
165 filter3.delete();
161 166
162 test.done(); 167 test.done();
163 }; 168 };
164 169
165 exports.testNormalize = function(test) 170 exports.testNormalize = function(test)
166 { 171 {
167 let tests = [ 172 let tests = [
168 [" ! comment something ", "! comment something"], 173 [" ! comment something ", "! comment something"],
169 [" ! \n comment something ", "! comment something"], 174 [" ! \n comment something ", "! comment something"],
170 [" foo bar ", "foobar"], 175 [" foo bar ", "foobar"],
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 { 384 {
380 let filter = Filter.fromText(text); 385 let filter = Filter.fromText(text);
381 test.equal(filter.regexpString, regexp, "Regular expression of " + text); 386 test.equal(filter.regexpString, regexp, "Regular expression of " + text);
382 test.equal(filter.selectorPrefix, prefix, "Selector prefix of " + text); 387 test.equal(filter.selectorPrefix, prefix, "Selector prefix of " + text);
383 test.equal(filter.selectorSuffix, suffix, "Selector suffix of " + text); 388 test.equal(filter.selectorSuffix, suffix, "Selector suffix of " + text);
384 filter.delete(); 389 filter.delete();
385 } 390 }
386 391
387 test.done(); 392 test.done();
388 }; 393 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld