|
Packit |
bfcc33 |
#include "../ast.hpp"
|
|
Packit |
bfcc33 |
#include "../context.hpp"
|
|
Packit |
bfcc33 |
#include "../parser.hpp"
|
|
Packit |
bfcc33 |
#include <string>
|
|
Packit |
bfcc33 |
|
|
Packit |
bfcc33 |
using namespace Sass;
|
|
Packit |
bfcc33 |
|
|
Packit |
bfcc33 |
Context ctx = Context(Context::Data());
|
|
Packit |
bfcc33 |
|
|
Packit |
bfcc33 |
Compound_Selector* compound_selector(std::string src)
|
|
Packit |
bfcc33 |
{ return Parser::from_c_str(src.c_str(), ctx, "", Position()).parse_compound_selector(); }
|
|
Packit |
bfcc33 |
|
|
Packit |
bfcc33 |
Complex_Selector* complex_selector(std::string src)
|
|
Packit |
bfcc33 |
{ return Parser::from_c_str(src.c_str(), ctx, "", Position()).parse_complex_selector(false); }
|
|
Packit |
bfcc33 |
|
|
Packit |
bfcc33 |
void check_compound(std::string s1, std::string s2)
|
|
Packit |
bfcc33 |
{
|
|
Packit |
bfcc33 |
std::cout << "Is "
|
|
Packit |
bfcc33 |
<< s1
|
|
Packit |
bfcc33 |
<< " a superselector of "
|
|
Packit |
bfcc33 |
<< s2
|
|
Packit |
bfcc33 |
<< "?\t"
|
|
Packit |
bfcc33 |
<< compound_selector(s1 + ";")->is_superselector_of(compound_selector(s2 + ";"))
|
|
Packit |
bfcc33 |
<< std::endl;
|
|
Packit |
bfcc33 |
}
|
|
Packit |
bfcc33 |
|
|
Packit |
bfcc33 |
void check_complex(std::string s1, std::string s2)
|
|
Packit |
bfcc33 |
{
|
|
Packit |
bfcc33 |
std::cout << "Is "
|
|
Packit |
bfcc33 |
<< s1
|
|
Packit |
bfcc33 |
<< " a superselector of "
|
|
Packit |
bfcc33 |
<< s2
|
|
Packit |
bfcc33 |
<< "?\t"
|
|
Packit |
bfcc33 |
<< complex_selector(s1 + ";")->is_superselector_of(complex_selector(s2 + ";"))
|
|
Packit |
bfcc33 |
<< std::endl;
|
|
Packit |
bfcc33 |
}
|
|
Packit |
bfcc33 |
|
|
Packit |
bfcc33 |
int main()
|
|
Packit |
bfcc33 |
{
|
|
Packit |
bfcc33 |
check_compound(".foo", ".foo.bar");
|
|
Packit |
bfcc33 |
check_compound(".foo.bar", ".foo");
|
|
Packit |
bfcc33 |
check_compound(".foo.bar", "div.foo");
|
|
Packit |
bfcc33 |
check_compound(".foo", "div.foo");
|
|
Packit |
bfcc33 |
check_compound("div.foo", ".foo");
|
|
Packit |
bfcc33 |
check_compound("div.foo", "div.bar.foo");
|
|
Packit |
bfcc33 |
check_compound("p.foo", "div.bar.foo");
|
|
Packit |
bfcc33 |
check_compound(".hux", ".mumble");
|
|
Packit |
bfcc33 |
|
|
Packit |
bfcc33 |
std::cout << std::endl;
|
|
Packit |
bfcc33 |
|
|
Packit |
bfcc33 |
check_complex(".foo ~ .bar", ".foo + .bar");
|
|
Packit |
bfcc33 |
check_complex(".foo .bar", ".foo + .bar");
|
|
Packit |
bfcc33 |
check_complex(".foo .bar", ".foo > .bar");
|
|
Packit |
bfcc33 |
check_complex(".foo .bar > .hux", ".foo.a .bar.b > .hux");
|
|
Packit |
bfcc33 |
check_complex(".foo ~ .bar .hux", ".foo.a + .bar.b > .hux");
|
|
Packit |
bfcc33 |
check_complex(".foo", ".bar .foo");
|
|
Packit |
bfcc33 |
check_complex(".foo", ".foo.a");
|
|
Packit |
bfcc33 |
check_complex(".foo.bar", ".foo");
|
|
Packit |
bfcc33 |
check_complex(".foo .bar .hux", ".bar .hux");
|
|
Packit |
bfcc33 |
check_complex(".foo ~ .bar .hux.x", ".foo.a + .bar.b > .hux.y");
|
|
Packit |
bfcc33 |
check_complex(".foo ~ .bar .hux", ".foo.a + .bar.b > .mumble");
|
|
Packit |
bfcc33 |
check_complex(".foo + .bar", ".foo ~ .bar");
|
|
Packit |
bfcc33 |
check_complex("a c e", "a b c d e");
|
|
Packit |
bfcc33 |
check_complex("c a e", "a b c d e");
|
|
Packit |
bfcc33 |
|
|
Packit |
bfcc33 |
return 0;
|
|
Packit |
bfcc33 |
}
|
|
Packit |
bfcc33 |
|
|
Packit |
bfcc33 |
|