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

Side by Side Diff: test/filterClasses.js

Issue 29333474: Issue 4125 - [emscripten] Convert filter classes to C++ (Closed)
Patch Set: Created Jan. 14, 2016, 4:40 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 | « test.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
(Empty)
1 "use strict";
2
3 let filterClasses = require("../lib/filterClassesNew");
4 let Filter = filterClasses.Filter;
5 let InvalidFilter = filterClasses.InvalidFilter;
6 let CommentFilter = filterClasses.CommentFilter;
7 let RegExpFilter = filterClasses.RegExpFilter;
8 let ElemHideFilter = filterClasses.ElemHideFilter;
9 let ElemHideException = filterClasses.ElemHideException;
10
11 exports.testFromText = function(test)
12 {
13 let tests = [
14 ["!asdf", CommentFilter, "comment"],
15 ["asdf", RegExpFilter, "blocking"],
16 ["##asdf", ElemHideFilter, "elemhide"],
17 ["#@#asdf", ElemHideException, "elemhideexception"],
18 ["foobar##asdf", ElemHideFilter, "elemhide"],
19 ["foobar#@#asdf", ElemHideException, "elemhideexception"],
20 ["foobar##a", ElemHideFilter, "elemhide"],
21 ["foobar#@#a", ElemHideException, "elemhideexception"],
22
23 ["foobar#asdf", RegExpFilter, "blocking"],
24 ["foobar|foobas##asdf", RegExpFilter, "blocking"],
25 ["foobar##asdf{asdf}", RegExpFilter, "blocking"],
26 ["foobar##", RegExpFilter, "blocking"],
27 ["foobar#@#", RegExpFilter, "blocking"],
28 ];
29 for (let [text, type, typeName] of tests)
30 {
31 let filter = Filter.fromText(text);
32 test.ok(filter, "Got filter for " + text);
33 test.ok(filter instanceof type, "Correct filter type for " + text);
34 test.equal(filter.type, typeName, "Type name for " + text + " is " + typeNam e);
35 }
36 test.done();
37 }
38
39 exports.testNormalize = function(test)
40 {
41 let tests = [
42 [" foo bar ", "foobar"],
43 ["foobar", "foobar"],
44 [" ! comment something ", "! comment something"],
45 [" ! \n comment something ", "! comment something"],
46 [" foo , bar ## foo > bar ", "foo,bar##foo > bar"],
47 [" foo , bar #@# foo > bar ", "foo,bar#@#foo > bar"],
48 ];
49 for (let [text, expected] of tests)
50 test.equal(Filter.normalize(text), expected);
51 test.done();
52 }
OLDNEW
« no previous file with comments | « test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld