diff --git a/src/css/libdom_test.zig b/src/css/libdom_test.zig index 0e5a255d..b8444f06 100644 --- a/src/css/libdom_test.zig +++ b/src/css/libdom_test.zig @@ -37,9 +37,107 @@ test "matchFirst" { exp: usize, }{ .{ .q = "address", .html = "
This address...", .exp = 1 }, + .{ .q = "*", .html = "text", .exp = 1 }, + .{ .q = "*", .html = "", .exp = 1 }, .{ .q = "#foo", .html = "", .exp = 1 }, - .{ .q = ".t1", .html = "
", .exp = 1 }, .{ .q = ".t3", .html = "
", .exp = 1 }, + .{ .q = "div.teST", .html = "
", .exp = 0 }, + .{ .q = "p.t1.t2", .html = "
", .exp = 1 }, + .{ .q = "p.--t1", .html = "
", .exp = 1 }, + .{ .q = "p.--t1.--t2", .html = "
", .exp = 1 }, + .{ .q = "p[title]", .html = "
", .exp = 1 }, + .{ .q = "div[class=\"red\" i]", .html = "
", .exp = 1 }, + .{ .q = "[ title ~= foo ]", .html = "
", .exp = 1 }, + .{ .q = "p[title~=\"FOO\" i]", .html = "
", .exp = 1 }, + .{ .q = "p[title~=toofoo i]", .html = "
", .exp = 0 }, + .{ .q = "[title~=\"hello world\"]", .html = "
", .exp = 0 }, + .{ .q = "[title~=\"hello\" i]", .html = "
", .exp = 1 }, + .{ .q = "[title~=\"hello\" I]", .html = "
", .exp = 1 }, + .{ .q = "[lang|=\"en\"]", .html = "
", .exp = 1 }, + .{ .q = "[lang|=\"EN\" i]", .html = "
", .exp = 1 }, + .{ .q = "[lang|=\"EN\" i]", .html = "
", .exp = 1 }, + .{ .q = "[title^=\"foo\"]", .html = "
", .exp = 1 }, + .{ .q = "[title^=\"foo\" i]", .html = "
", .exp = 1 }, + .{ .q = "[title$=\"bar\"]", .html = "
", .exp = 1 }, + .{ .q = "[title$=\"BAR\" i]", .html = "
", .exp = 1 }, + .{ .q = "[title*=\"bar\"]", .html = "
", .exp = 1 }, + .{ .q = "[title*=\"BaRu\" i]", .html = "
", .exp = 1 }, + .{ .q = "[title*=\"BaRu\" I]", .html = "
", .exp = 1 }, + .{ .q = "p[class$=\" \"]", .html = "
This text should be green.
This text should be green.
", .exp = 0 }, + .{ .q = "p[class$=\"\"]", .html = "This text should be green.
This text should be green.
", .exp = 0 }, + .{ .q = "p[class^=\" \"]", .html = "This text should be green.
This text should be green.
", .exp = 0 }, + .{ .q = "p[class^=\"\"]", .html = "This text should be green.
This text should be green.
", .exp = 0 }, + .{ .q = "p[class*=\" \"]", .html = "This text should be green.
This text should be green.
", .exp = 0 }, + .{ .q = "p[class*=\"\"]", .html = "This text should be green.
This text should be green.
", .exp = 0 }, + .{ .q = "input[name=Sex][value=F]", .html = "", .exp = 1 }, + .{ .q = "table[border=\"0\"][cellpadding=\"0\"][cellspacing=\"0\"]", .html = "", .exp = 0 }, + .{ .q = "div:not(.t1)", .html = "
some text and a span and another
", .exp = 1 }, + .{ .q = "span:last-child", .html = "a span and some text", .exp = 1 }, + .{ .q = "p:nth-of-type(2)", .html = "", .exp = 1 }, + .{ .q = "p:nth-last-of-type(2)", .html = "
", .exp = 1 }, + .{ .q = "p:last-of-type", .html = "", .exp = 1 }, + .{ .q = "p:first-of-type", .html = "", .exp = 1 }, + .{ .q = "p:only-child", .html = "Hello
", .exp = 1 },
+ .{ .q = "div p", .html = " ", .exp = 1 },
+ .{ .q = "div table p", .html = " ", .exp = 1 },
+ .{ .q = "div > p", .html = " ", .exp = 1 },
+ .{ .q = "p + p", .html = " ", .exp = 1 },
+ .{ .q = "li, p", .html = " ", .exp = 1 },
+ .{ .q = "p +/*This is a comment*/ p", .html = " ", .exp = 1 },
+ .{ .q = "p:contains(\"that wraps\")", .html = " Text block that wraps inner text and continues Text block that wraps inner text and continues Text block that wraps inner text and continues Text block that wraps inner text and continues text content contents 1 contents 2 contents 1 contents 2 contents 1 contents 2 0123456789 abcdef 0123ABCD 0123456789 abcdef 0123ABCD 0123456789 abcdef 0123ABCD 0123456789 abcdef 0123ABCD 0123456789 abcdef 0123ABCD 0123456789 abcdef 0123ABCD 0123456789 abcdef 0123ABCD 0123456789 ", .exp = 1 },
- .{ .q = ".t1", .html = " ", .exp = 1 },
.{ .q = ".t3", .html = " ", .exp = 1 },
+ .{ .q = "div.teST", .html = " ", .exp = 0 },
+ .{ .q = "p.t1.t2", .html = " ", .exp = 1 },
+ .{ .q = "p.--t1", .html = " ", .exp = 1 },
+ .{ .q = "p.--t1.--t2", .html = " ", .exp = 1 },
+ .{ .q = "p[title]", .html = " ", .exp = 1 },
+ .{ .q = "div[class=\"red\" i]", .html = " ", .exp = 1 },
+ .{ .q = "[ title ~= foo ]", .html = " ", .exp = 1 },
+ .{ .q = "p[title~=\"FOO\" i]", .html = " ", .exp = 1 },
+ .{ .q = "p[title~=toofoo i]", .html = " ", .exp = 0 },
+ .{ .q = "[title~=\"hello world\"]", .html = " ", .exp = 0 },
+ .{ .q = "[title~=\"hello\" i]", .html = " ", .exp = 1 },
+ .{ .q = "[title~=\"hello\" I]", .html = " ", .exp = 1 },
+ .{ .q = "[lang|=\"en\"]", .html = " ", .exp = 2 },
+ .{ .q = "[lang|=\"EN\" i]", .html = " ", .exp = 2 },
+ .{ .q = "[lang|=\"EN\" i]", .html = " ", .exp = 2 },
+ .{ .q = "[title^=\"foo\"]", .html = " ", .exp = 1 },
+ .{ .q = "[title^=\"foo\" i]", .html = " ", .exp = 1 },
+ .{ .q = "[title$=\"bar\"]", .html = " ", .exp = 1 },
+ .{ .q = "[title$=\"BAR\" i]", .html = " ", .exp = 1 },
+ .{ .q = "[title*=\"bar\"]", .html = " ", .exp = 1 },
+ .{ .q = "[title*=\"BaRu\" i]", .html = " ", .exp = 1 },
+ .{ .q = "[title*=\"BaRu\" I]", .html = " ", .exp = 1 },
+ .{ .q = "p[class$=\" \"]", .html = " This text should be green. This text should be green. This text should be green. This text should be green. This text should be green. This text should be green. This text should be green. This text should be green. This text should be green. This text should be green. This text should be green. This text should be green. ", .exp = 0 },
+ .{ .q = "div:not(.t1)", .html = " some text and a span and another ", .exp = 1 },
+ .{ .q = "p:nth-last-of-type(2)", .html = " Hello ", .exp = 3 },
+ .{ .q = "div p", .html = " ", .exp = 2 },
+ .{ .q = "div table p", .html = " ", .exp = 1 },
+ .{ .q = "div > p", .html = " ", .exp = 2 },
+ .{ .q = "p + p", .html = " ", .exp = 1 },
+ .{ .q = "li, p", .html = " ", .exp = 3 },
+ .{ .q = "p +/*This is a comment*/ p", .html = " ", .exp = 1 },
+ .{ .q = "p:contains(\"that wraps\")", .html = " Text block that wraps inner text and continues Text block that wraps inner text and continues Text block that wraps inner text and continues Text block that wraps inner text and continues text content contents 1 contents 2 contents 1 contents 2 contents 1 contents 2 0123456789 abcdef 0123ABCD 0123456789 abcdef 0123ABCD 0123456789 abcdef 0123ABCD 0123456789 abcdef 0123ABCD 0123456789 abcdef 0123ABCD 0123456789 abcdef 0123ABCD 0123456789 abcdef 0123ABCD 0123456789
", .exp = 1 },
+ .{ .q = ".t1:not(.t2)", .html = "aaa ", .exp = 2 },
+ .{ .q = "li:nth-child(even)", .html = "
", .exp = 1 },
+ .{ .q = "li:nth-child(-n+2)", .html = "
", .exp = 2 },
+ .{ .q = "li:nth-child(3n+1)", .html = "
", .exp = 1 },
+ .{ .q = "li:nth-last-child(odd)", .html = "
", .exp = 2 },
+ .{ .q = "li:nth-last-child(even)", .html = "
", .exp = 2 },
+ .{ .q = "li:nth-last-child(-n+2)", .html = "
", .exp = 2 },
+ .{ .q = "li:nth-last-child(3n+1)", .html = "
", .exp = 2 },
+ .{ .q = "span:first-child", .html = "