Blame test/test_unification.cpp

Packit Service 7770af
#include "../ast.hpp"
Packit Service 7770af
#include "../context.hpp"
Packit Service 7770af
#include "../parser.hpp"
Packit Service 7770af
#include <string>
Packit Service 7770af
Packit Service 7770af
using namespace Sass;
Packit Service 7770af
Packit Service 7770af
Context ctx = Context(Context::Data());
Packit Service 7770af
Packit Service 7770af
Compound_Selector* selector(std::string src)
Packit Service 7770af
{ return Parser::from_c_str(src.c_str(), ctx, "", Position()).parse_compound_selector(); }
Packit Service 7770af
Packit Service 7770af
void unify(std::string lhs, std::string rhs)
Packit Service 7770af
{
Packit Service 7770af
  Compound_Selector* unified = selector(lhs + ";")->unify_with(selector(rhs + ";"), ctx);
Packit Service 7770af
  std::cout << lhs << " UNIFIED WITH " << rhs << " =\t" << (unified ? unified->to_string() : "NOTHING") << std::endl;
Packit Service 7770af
}
Packit Service 7770af
Packit Service 7770af
int main()
Packit Service 7770af
{
Packit Service 7770af
  unify(".foo", ".foo.bar");
Packit Service 7770af
  unify("div:nth-of-type(odd)", "div:first-child");
Packit Service 7770af
  unify("div", "span:whatever");
Packit Service 7770af
  unify("div", "span");
Packit Service 7770af
  unify("foo:bar::after", "foo:bar::first-letter");
Packit Service 7770af
  unify(".foo#bar.hux", ".hux.foo#bar");
Packit Service 7770af
  unify(".foo#bar.hux", ".hux.foo#baz");
Packit Service 7770af
  unify("*:blah:fudge", "p:fudge:blah");
Packit Service 7770af
Packit Service 7770af
  return 0;
Packit Service 7770af
}