コード例 #1
0
ファイル: ES6Test.php プロジェクト: mck89/peast
 public function testTokenizeEmptySource()
 {
     $tree = \Peast\Peast::ES6("")->tokenize();
     $this->assertSame(0, count($tree));
 }
コード例 #2
0
ファイル: TraverserTest.php プロジェクト: mck89/peast
 public function testTraverseTemplate()
 {
     $source = '`foo${exp()}bar`';
     $types = array();
     \Peast\Peast::ES7($source)->parse()->traverse(function ($node) use(&$types) {
         $type = $node->getType();
         $types[] = $type;
     });
     $this->assertEquals(array("Program", "ExpressionStatement", "TemplateLiteral", "TemplateElement", "CallExpression", "Identifier", "TemplateElement"), $types);
 }