You've already forked MyDSL
原始输出类及测试
This commit is contained in:
33
tests/Output/RawOutputTest.php
Normal file
33
tests/Output/RawOutputTest.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* @filename RawOutputTest.php
|
||||
* @author Jerry Yan <792602257@qq.com>
|
||||
* @date 2021/2/19 11:10
|
||||
*/
|
||||
|
||||
namespace JerryYan\DSL\Test\Output;
|
||||
|
||||
use JerryYan\DSL\Grammar\DefaultGrammar;
|
||||
use JerryYan\DSL\Output\RawOutput;
|
||||
use JerryYan\DSL\Reader\StringReader;
|
||||
use JerryYan\DSL\Tokenizer\Tokenizer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class RawOutputTest extends TestCase
|
||||
{
|
||||
private $text = "当 另外那个 与 另外一个 不相等时 或者 那个 和 这个 等于 -0.5 的时候";
|
||||
private $output;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$tokenizer = new Tokenizer(new DefaultGrammar());
|
||||
$reader = new StringReader($this->text);
|
||||
$token = $tokenizer->tokenize($reader);
|
||||
$this->output = new RawOutput($token);
|
||||
}
|
||||
|
||||
public function testOutput()
|
||||
{
|
||||
$this->assertEquals($this->text, $this->output->output(), '输出与预期不一致');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user