Initial commit
[yaffs-website] / node_modules / node-sass / src / libsass / test / test_unification.cpp
1 #include "../ast.hpp"
2 #include "../context.hpp"
3 #include "../parser.hpp"
4 #include <string>
5
6 using namespace Sass;
7
8 Context ctx = Context(Context::Data());
9
10 Compound_Selector* selector(std::string src)
11 { return Parser::from_c_str(src.c_str(), ctx, "", Position()).parse_compound_selector(); }
12
13 void unify(std::string lhs, std::string rhs)
14 {
15   Compound_Selector* unified = selector(lhs + ";")->unify_with(selector(rhs + ";"), ctx);
16   std::cout << lhs << " UNIFIED WITH " << rhs << " =\t" << (unified ? unified->to_string() : "NOTHING") << std::endl;
17 }
18
19 int main()
20 {
21   unify(".foo", ".foo.bar");
22   unify("div:nth-of-type(odd)", "div:first-child");
23   unify("div", "span:whatever");
24   unify("div", "span");
25   unify("foo:bar::after", "foo:bar::first-letter");
26   unify(".foo#bar.hux", ".hux.foo#bar");
27   unify(".foo#bar.hux", ".hux.foo#baz");
28   unify("*:blah:fudge", "p:fudge:blah");
29
30   return 0;
31 }