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

Unified 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.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/filterClasses.js
===================================================================
new file mode 100644
--- /dev/null
+++ b/test/filterClasses.js
@@ -0,0 +1,52 @@
+"use strict";
+
+let filterClasses = require("../lib/filterClassesNew");
+let Filter = filterClasses.Filter;
+let InvalidFilter = filterClasses.InvalidFilter;
+let CommentFilter = filterClasses.CommentFilter;
+let RegExpFilter = filterClasses.RegExpFilter;
+let ElemHideFilter = filterClasses.ElemHideFilter;
+let ElemHideException = filterClasses.ElemHideException;
+
+exports.testFromText = function(test)
+{
+ let tests = [
+ ["!asdf", CommentFilter, "comment"],
+ ["asdf", RegExpFilter, "blocking"],
+ ["##asdf", ElemHideFilter, "elemhide"],
+ ["#@#asdf", ElemHideException, "elemhideexception"],
+ ["foobar##asdf", ElemHideFilter, "elemhide"],
+ ["foobar#@#asdf", ElemHideException, "elemhideexception"],
+ ["foobar##a", ElemHideFilter, "elemhide"],
+ ["foobar#@#a", ElemHideException, "elemhideexception"],
+
+ ["foobar#asdf", RegExpFilter, "blocking"],
+ ["foobar|foobas##asdf", RegExpFilter, "blocking"],
+ ["foobar##asdf{asdf}", RegExpFilter, "blocking"],
+ ["foobar##", RegExpFilter, "blocking"],
+ ["foobar#@#", RegExpFilter, "blocking"],
+ ];
+ for (let [text, type, typeName] of tests)
+ {
+ let filter = Filter.fromText(text);
+ test.ok(filter, "Got filter for " + text);
+ test.ok(filter instanceof type, "Correct filter type for " + text);
+ test.equal(filter.type, typeName, "Type name for " + text + " is " + typeName);
+ }
+ test.done();
+}
+
+exports.testNormalize = function(test)
+{
+ let tests = [
+ [" foo bar ", "foobar"],
+ ["foobar", "foobar"],
+ [" ! comment something ", "! comment something"],
+ [" ! \n comment something ", "! comment something"],
+ [" foo , bar ## foo > bar ", "foo,bar##foo > bar"],
+ [" foo , bar #@# foo > bar ", "foo,bar#@#foo > bar"],
+ ];
+ for (let [text, expected] of tests)
+ test.equal(Filter.normalize(text), expected);
+ test.done();
+}
« no previous file with comments | « test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld