Disable problem code. Add more tests

This commit is contained in:
Ivan Shalganov 2013-09-19 23:10:19 +04:00
parent b1b81cdce7
commit 5770c5aea9
3 changed files with 29 additions and 9 deletions

View File

@ -570,12 +570,12 @@ class Compiler
$tpl->addDepend($donor); $tpl->addDepend($donor);
return '?>' . $donor->getBody() . '<?php '; return '?>' . $donor->getBody() . '<?php ';
} else { } else {
// throw new InvalidUsageException('template name must be given explicitly yet'); throw new InvalidUsageException('template name must be given explicitly yet');
// under construction // under construction
$tpl->_compatible = true; // $tpl->_compatible = true;
return '$donor = $tpl->getStorage()->getTemplate(' . $cname . ', \Fenom\Template::EXTENDED);' . PHP_EOL . // return '$donor = $tpl->getStorage()->getTemplate(' . $cname . ', \Fenom\Template::EXTENDED);' . PHP_EOL .
'$donor->fetch((array)$tpl);' . PHP_EOL . // '$donor->fetch((array)$tpl);' . PHP_EOL .
'$tpl->b += (array)$donor->b'; // '$tpl->b += (array)$donor->b';
} }
} }
@ -1000,10 +1000,10 @@ class Compiler
$tag = $tpl->getStorage()->getTag($func, $tpl); $tag = $tpl->getStorage()->getTag($func, $tpl);
if ($tag["type"] == \Fenom::INLINE_FUNCTION) { if ($tag["type"] == \Fenom::INLINE_FUNCTION) {
$code = $tpl->parseAct($tokens); $code = $tpl->parseAct($tokens);
} elseif ($tag["type"] == \Fenom::BLOCK_FUNCTION) { // } elseif ($tag["type"] == \Fenom::BLOCK_FUNCTION) {
$code = $tpl->parseAct($tokens); // $code = $tpl->parseAct($tokens);
$tpl->getLastScope()->escape = false; // $tpl->getLastScope()->escape = false;
return $code; // return $code;
} else { } else {
throw new InvalidUsageException("Raw mode allow for expressions or functions"); throw new InvalidUsageException("Raw mode allow for expressions or functions");
} }

View File

@ -102,5 +102,17 @@ class ProviderTest extends TestCase
"template2.tpl" "template2.tpl"
), $list); ), $list);
} }
public function testRm() {
$this->assertTrue(is_dir(FENOM_RESOURCES . '/template/sub'));
Provider::rm(FENOM_RESOURCES . '/template/sub');
$this->assertFalse(is_dir(FENOM_RESOURCES . '/template/sub'));
$this->assertTrue(is_file(FENOM_RESOURCES . '/template/template1.tpl'));
Provider::rm(FENOM_RESOURCES . '/template/template1.tpl');
$this->assertFalse(is_file(FENOM_RESOURCES . '/template/template1.tpl'));
$this->assertTrue(is_file(FENOM_RESOURCES . '/template/template2.tpl'));
Provider::clean(FENOM_RESOURCES . '/template/');
$this->assertFalse(is_file(FENOM_RESOURCES . '/template/template2.tpl'));
}
} }

View File

@ -10,6 +10,7 @@ class TokenizerTest extends \PHPUnit_Framework_TestCase
{ {
$code = 'hello, please resolve this example: sin($x)+tan($x*$t) = {U|[0,1]}'; $code = 'hello, please resolve this example: sin($x)+tan($x*$t) = {U|[0,1]}';
$tokens = new Tokenizer($code); $tokens = new Tokenizer($code);
$this->assertSame(27, $tokens->count());
$this->assertSame($tokens, $tokens->back()); $this->assertSame($tokens, $tokens->back());
$this->assertSame(T_STRING, $tokens->key()); $this->assertSame(T_STRING, $tokens->key());
$this->assertSame("hello", $tokens->current()); $this->assertSame("hello", $tokens->current());
@ -55,6 +56,8 @@ class TokenizerTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($tokens->is(T_DNUMBER)); $this->assertFalse($tokens->is(T_DNUMBER));
$this->assertFalse($tokens->is(":")); $this->assertFalse($tokens->is(":"));
$this->assertSame("(", $tokens->getNext("(", ")")); $this->assertSame("(", $tokens->getNext("(", ")"));
$this->assertTrue($tokens->hasBackList(T_STRING, ':'));
$this->assertFalse($tokens->hasBackList(T_LNUMBER, ':'));
$tokens->next(); $tokens->next();
$tokens->next(); $tokens->next();
@ -87,6 +90,11 @@ class TokenizerTest extends \PHPUnit_Framework_TestCase
$this->assertSame(")", $tokens->current()); $this->assertSame(")", $tokens->current());
$this->assertTrue($tokens->isLast()); $this->assertTrue($tokens->isLast());
$this->assertSame($tokens, $tokens->next()); $this->assertSame($tokens, $tokens->next());
$tokens->p = 1000;
$this->assertSame($tokens, $tokens->next());
$tokens->p = -1000;
$this->assertSame($tokens, $tokens->back());
$this->assertNull($tokens->undef);
} }
} }