예제 #1
0
<?php

require 'initialize.php';
$parser = new SCSS_Parser();
$t->comment('create declaration node');
$t->ok($decl = $parser->genDeclaration('margin', '0'), 'generate node');
$t->isa_ok($decl, 'SCSS_YYNode_Declaration', 'node isa SCSS_YYNode_Declaration');
$t->iss($decl->id, 0, 'id of first node is 0');
$t->is($decl->getType(), 'declaration', 'get node type');
$t->false($decl->hasChildren(), 'has not child nodes');
$t->false($decl->hasNext(), 'has not next node');
$t->is($decl->publish(), 'margin:0;', 'publish, not line breaking');
$t->comment('next node operation');
$t->ok($next = $parser->genDeclaration('padding', '10px'), 'generate node');
$t->is($parser->catNode($decl, $next), $decl, 'cat next node');
$t->true($decl->hasNext(), 'base declaration node has next one');
$t->is($decl->publish(), 'margin:0;', 'not publish next node');
$t->comment('without semicolon');
$t->ok($noSemi = $parser->genDeclaration('margin', '0'), 'generate node');
$t->is($noSemi->publish(), 'margin:0;', 'publish with semicolon');
$t->comment('blank spaces');
$t->ok($blank = $parser->genDeclaration('margin', '0'), 'generate node');
$t->is($blank->publish(), 'margin:0;', 'publish trimed');
$t->ok($blank = $parser->genDeclaration(' margin', ' 5px   10px  0 '), 'generate node');
$t->is($blank->publish(), 'margin:5px 10px 0;', 'space trimming and compressed');
/*
 * Expression formats.
 */
function through($property, $expr)
{
    global $t, $parser;