2 #include "../context.hpp"
3 #include "../parser.hpp"
8 Context ctx = Context(Context::Data());
10 Compound_Selector* compound_selector(std::string src)
11 { return Parser::from_c_str(src.c_str(), ctx, "", Position()).parse_compound_selector(); }
13 Complex_Selector* complex_selector(std::string src)
14 { return Parser::from_c_str(src.c_str(), ctx, "", Position()).parse_complex_selector(false); }
16 void check_compound(std::string s1, std::string s2)
20 << " a superselector of "
23 << compound_selector(s1 + ";")->is_superselector_of(compound_selector(s2 + ";"))
27 void check_complex(std::string s1, std::string s2)
31 << " a superselector of "
34 << complex_selector(s1 + ";")->is_superselector_of(complex_selector(s2 + ";"))
40 check_compound(".foo", ".foo.bar");
41 check_compound(".foo.bar", ".foo");
42 check_compound(".foo.bar", "div.foo");
43 check_compound(".foo", "div.foo");
44 check_compound("div.foo", ".foo");
45 check_compound("div.foo", "div.bar.foo");
46 check_compound("p.foo", "div.bar.foo");
47 check_compound(".hux", ".mumble");
49 std::cout << std::endl;
51 check_complex(".foo ~ .bar", ".foo + .bar");
52 check_complex(".foo .bar", ".foo + .bar");
53 check_complex(".foo .bar", ".foo > .bar");
54 check_complex(".foo .bar > .hux", ".foo.a .bar.b > .hux");
55 check_complex(".foo ~ .bar .hux", ".foo.a + .bar.b > .hux");
56 check_complex(".foo", ".bar .foo");
57 check_complex(".foo", ".foo.a");
58 check_complex(".foo.bar", ".foo");
59 check_complex(".foo .bar .hux", ".bar .hux");
60 check_complex(".foo ~ .bar .hux.x", ".foo.a + .bar.b > .hux.y");
61 check_complex(".foo ~ .bar .hux", ".foo.a + .bar.b > .mumble");
62 check_complex(".foo + .bar", ".foo ~ .bar");
63 check_complex("a c e", "a b c d e");
64 check_complex("c a e", "a b c d e");