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

Side by Side Diff: test/filterClasses.js

Issue 29900557: Issue 7016 - Convert serialization functions into generators (Closed)
Patch Set: Address PS5 Comments Created Oct. 22, 2018, 10:58 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
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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 addDefaults(expected); 190 addDefaults(expected);
191 191
192 let filter = Filter.fromText(text); 192 let filter = Filter.fromText(text);
193 if (postInit) 193 if (postInit)
194 postInit(filter); 194 postInit(filter);
195 let result = serializeFilter(filter); 195 let result = serializeFilter(filter);
196 test.equal(result.sort().join("\n"), expected.sort().join("\n"), text); 196 test.equal(result.sort().join("\n"), expected.sort().join("\n"), text);
197 197
198 // Test round-trip 198 // Test round-trip
199 let filter2; 199 let filter2;
200 let buffer = []; 200 let buffer = [...filter.serialize()];
201 filter.serialize(buffer);
202 if (buffer.length) 201 if (buffer.length)
203 { 202 {
204 let map = Object.create(null); 203 let map = Object.create(null);
205 for (let line of buffer.slice(1)) 204 for (let line of buffer.slice(1))
206 { 205 {
207 if (/(.*?)=(.*)/.test(line)) 206 if (/(.*?)=(.*)/.test(line))
208 map[RegExp.$1] = RegExp.$2; 207 map[RegExp.$1] = RegExp.$2;
209 } 208 }
210 filter2 = Filter.fromObject(map); 209 filter2 = Filter.fromObject(map);
211 } 210 }
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 628
630 test.notEqual(filter2.domains, filter5.domains); 629 test.notEqual(filter2.domains, filter5.domains);
631 630
632 // Check twice for element hiding filters to make sure the internal cached 631 // Check twice for element hiding filters to make sure the internal cached
633 // values are also not equal. 632 // values are also not equal.
634 test.notEqual(filter4.domains, filter6.domains); 633 test.notEqual(filter4.domains, filter6.domains);
635 test.notEqual(filter4.domains, filter6.domains); 634 test.notEqual(filter4.domains, filter6.domains);
636 635
637 test.done(); 636 test.done();
638 }; 637 };
OLDNEW

Powered by Google App Engine
This is Rietveld