From 0cf8118f5d024aaf3d8fec381980d5aeffb7c434 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 7 Mar 2022 14:25:06 +0100 Subject: [PATCH] improved tests --- tests/Neon/Encoder.nodes.phpt | 2 +- tests/Neon/Parser.nodes.phpt | 2 +- tests/Neon/fixtures/Encoder.nodes.txt | 26 +++- tests/Neon/fixtures/Parser.nodes.txt | 200 +++++++++++++++++++++++++- 4 files changed, 221 insertions(+), 9 deletions(-) diff --git a/tests/Neon/Encoder.nodes.phpt b/tests/Neon/Encoder.nodes.phpt index bdd4d070..edfc86ae 100644 --- a/tests/Neon/Encoder.nodes.phpt +++ b/tests/Neon/Encoder.nodes.phpt @@ -32,5 +32,5 @@ $node = $encoder->valueToNode($input); Assert::matchFile( __DIR__ . '/fixtures/Encoder.nodes.txt', - Dumper::toText($node, [Dumper::HASH => false]) + Dumper::toText($node, [Dumper::HASH => false, Dumper::DEPTH => 20]) ); diff --git a/tests/Neon/Parser.nodes.phpt b/tests/Neon/Parser.nodes.phpt index 61b9156c..237e4fcb 100644 --- a/tests/Neon/Parser.nodes.phpt +++ b/tests/Neon/Parser.nodes.phpt @@ -66,5 +66,5 @@ $traverser->traverse($node, function (Node $node) use ($stream) { Assert::matchFile( __DIR__ . '/fixtures/Parser.nodes.txt', - Dumper::toText($node, [Dumper::HASH => false]) + Dumper::toText($node, [Dumper::HASH => false, Dumper::DEPTH => 20]) ); diff --git a/tests/Neon/fixtures/Encoder.nodes.txt b/tests/Neon/fixtures/Encoder.nodes.txt index 99784bd0..d505e10f 100644 --- a/tests/Neon/fixtures/Encoder.nodes.txt +++ b/tests/Neon/fixtures/Encoder.nodes.txt @@ -247,8 +247,30 @@ Nette\Neon\Node\InlineArrayNode | | | | | | startLine: null | | | | | | endLine: null | | | | | attributes: array (2) - | | | | | | 0 => Nette\Neon\Node\ArrayItemNode ... - | | | | | | 1 => Nette\Neon\Node\ArrayItemNode ... + | | | | | | 0 => Nette\Neon\Node\ArrayItemNode + | | | | | | | key: null + | | | | | | | value: Nette\Neon\Node\LiteralNode + | | | | | | | | value: 'a' + | | | | | | | | startTokenPos: null + | | | | | | | | endTokenPos: null + | | | | | | | | startLine: null + | | | | | | | | endLine: null + | | | | | | | startTokenPos: null + | | | | | | | endTokenPos: null + | | | | | | | startLine: null + | | | | | | | endLine: null + | | | | | | 1 => Nette\Neon\Node\ArrayItemNode + | | | | | | | key: null + | | | | | | | value: Nette\Neon\Node\LiteralNode + | | | | | | | | value: 'b' + | | | | | | | | startTokenPos: null + | | | | | | | | endTokenPos: null + | | | | | | | | startLine: null + | | | | | | | | endLine: null + | | | | | | | startTokenPos: null + | | | | | | | endTokenPos: null + | | | | | | | startLine: null + | | | | | | | endLine: null | | | | | startTokenPos: null | | | | | endTokenPos: null | | | | | startLine: null diff --git a/tests/Neon/fixtures/Parser.nodes.txt b/tests/Neon/fixtures/Parser.nodes.txt index 177816ec..f7d7a478 100644 --- a/tests/Neon/fixtures/Parser.nodes.txt +++ b/tests/Neon/fixtures/Parser.nodes.txt @@ -87,7 +87,69 @@ Nette\Neon\Node\BlockArrayNode | | | | | | | \t \t l, m:\n | | | | | | | \t n]' | | | | | | bracket: '[' - | | | | | | items: array (4) ... + | | | | | | items: array (4) + | | | | | | | 0 => Nette\Neon\Node\ArrayItemNode + | | | | | | | | code: 'k' + | | | | | | | | key: null + | | | | | | | | value: Nette\Neon\Node\LiteralNode + | | | | | | | | | code: 'k' + | | | | | | | | | value: 'k' + | | | | | | | | | startTokenPos: unset + | | | | | | | | | endTokenPos: unset + | | | | | | | | | startLine: 7 + | | | | | | | | | endLine: 7 + | | | | | | | | startTokenPos: unset + | | | | | | | | endTokenPos: unset + | | | | | | | | startLine: 7 + | | | | | | | | endLine: 7 + | | | | | | | 1 => Nette\Neon\Node\ArrayItemNode + | | | | | | | | code: 'l' + | | | | | | | | key: null + | | | | | | | | value: Nette\Neon\Node\LiteralNode + | | | | | | | | | code: 'l' + | | | | | | | | | value: 'l' + | | | | | | | | | startTokenPos: unset + | | | | | | | | | endTokenPos: unset + | | | | | | | | | startLine: 8 + | | | | | | | | | endLine: 8 + | | | | | | | | startTokenPos: unset + | | | | | | | | endTokenPos: unset + | | | | | | | | startLine: 8 + | | | | | | | | endLine: 8 + | | | | | | | 2 => Nette\Neon\Node\ArrayItemNode + | | | | | | | | code: 'm:\n' + | | | | | | | | key: Nette\Neon\Node\LiteralNode + | | | | | | | | | code: 'm' + | | | | | | | | | value: 'm' + | | | | | | | | | startTokenPos: unset + | | | | | | | | | endTokenPos: unset + | | | | | | | | | startLine: 8 + | | | | | | | | | endLine: 8 + | | | | | | | | value: Nette\Neon\Node\LiteralNode + | | | | | | | | | code: '\n' + | | | | | | | | | value: null + | | | | | | | | | startTokenPos: unset + | | | | | | | | | endTokenPos: unset + | | | | | | | | | startLine: 8 + | | | | | | | | | endLine: 9 + | | | | | | | | startTokenPos: unset + | | | | | | | | endTokenPos: unset + | | | | | | | | startLine: 8 + | | | | | | | | endLine: 9 + | | | | | | | 3 => Nette\Neon\Node\ArrayItemNode + | | | | | | | | code: 'n' + | | | | | | | | key: null + | | | | | | | | value: Nette\Neon\Node\LiteralNode + | | | | | | | | | code: 'n' + | | | | | | | | | value: 'n' + | | | | | | | | | startTokenPos: unset + | | | | | | | | | endTokenPos: unset + | | | | | | | | | startLine: 9 + | | | | | | | | | endLine: 9 + | | | | | | | | startTokenPos: unset + | | | | | | | | endTokenPos: unset + | | | | | | | | startLine: 9 + | | | | | | | | endLine: 9 | | | | | | startTokenPos: unset | | | | | | endTokenPos: unset | | | | | | startLine: 7 @@ -141,7 +203,47 @@ Nette\Neon\Node\BlockArrayNode | | | | | | | 'a: 1\n | | | | | | | \t \t b: 2' | | | | | | indentation: '\t ' - | | | | | | items: array (2) ... + | | | | | | items: array (2) + | | | | | | | 0 => Nette\Neon\Node\ArrayItemNode + | | | | | | | | code: 'a: 1' + | | | | | | | | key: Nette\Neon\Node\LiteralNode + | | | | | | | | | code: 'a' + | | | | | | | | | value: 'a' + | | | | | | | | | startTokenPos: unset + | | | | | | | | | endTokenPos: unset + | | | | | | | | | startLine: 12 + | | | | | | | | | endLine: 12 + | | | | | | | | value: Nette\Neon\Node\LiteralNode + | | | | | | | | | code: '1' + | | | | | | | | | value: 1 + | | | | | | | | | startTokenPos: unset + | | | | | | | | | endTokenPos: unset + | | | | | | | | | startLine: 12 + | | | | | | | | | endLine: 12 + | | | | | | | | startTokenPos: unset + | | | | | | | | endTokenPos: unset + | | | | | | | | startLine: 12 + | | | | | | | | endLine: 12 + | | | | | | | 1 => Nette\Neon\Node\ArrayItemNode + | | | | | | | | code: 'b: 2' + | | | | | | | | key: Nette\Neon\Node\LiteralNode + | | | | | | | | | code: 'b' + | | | | | | | | | value: 'b' + | | | | | | | | | startTokenPos: unset + | | | | | | | | | endTokenPos: unset + | | | | | | | | | startLine: 13 + | | | | | | | | | endLine: 13 + | | | | | | | | value: Nette\Neon\Node\LiteralNode + | | | | | | | | | code: '2' + | | | | | | | | | value: 2 + | | | | | | | | | startTokenPos: unset + | | | | | | | | | endTokenPos: unset + | | | | | | | | | startLine: 13 + | | | | | | | | | endLine: 13 + | | | | | | | | startTokenPos: unset + | | | | | | | | endTokenPos: unset + | | | | | | | | startLine: 13 + | | | | | | | | endLine: 13 | | | | | | startTokenPos: unset | | | | | | endTokenPos: unset | | | | | | startLine: 12 @@ -181,8 +283,34 @@ Nette\Neon\Node\BlockArrayNode | | | | | key: null | | | | | value: Nette\Neon\Node\EntityNode | | | | | | code: 'entity(a: 1)' - | | | | | | value: Nette\Neon\Node\LiteralNode ... - | | | | | | attributes: array (1) ... + | | | | | | value: Nette\Neon\Node\LiteralNode + | | | | | | | code: 'entity' + | | | | | | | value: 'entity' + | | | | | | | startTokenPos: unset + | | | | | | | endTokenPos: unset + | | | | | | | startLine: 15 + | | | | | | | endLine: 15 + | | | | | | attributes: array (1) + | | | | | | | 0 => Nette\Neon\Node\ArrayItemNode + | | | | | | | | code: 'a: 1' + | | | | | | | | key: Nette\Neon\Node\LiteralNode + | | | | | | | | | code: 'a' + | | | | | | | | | value: 'a' + | | | | | | | | | startTokenPos: unset + | | | | | | | | | endTokenPos: unset + | | | | | | | | | startLine: 15 + | | | | | | | | | endLine: 15 + | | | | | | | | value: Nette\Neon\Node\LiteralNode + | | | | | | | | | code: '1' + | | | | | | | | | value: 1 + | | | | | | | | | startTokenPos: unset + | | | | | | | | | endTokenPos: unset + | | | | | | | | | startLine: 15 + | | | | | | | | | endLine: 15 + | | | | | | | | startTokenPos: unset + | | | | | | | | endTokenPos: unset + | | | | | | | | startLine: 15 + | | | | | | | | endLine: 15 | | | | | | startTokenPos: unset | | | | | | endTokenPos: unset | | | | | | startLine: 15 @@ -196,7 +324,69 @@ Nette\Neon\Node\BlockArrayNode | | | | | key: null | | | | | value: Nette\Neon\Node\EntityChainNode | | | | | | code: 'entity(a: 1)foo()bar' - | | | | | | chain: array (3) ... + | | | | | | chain: array (3) + | | | | | | | 0 => Nette\Neon\Node\EntityNode + | | | | | | | | code: 'entity(a: 1)' + | | | | | | | | value: Nette\Neon\Node\LiteralNode + | | | | | | | | | code: 'entity' + | | | | | | | | | value: 'entity' + | | | | | | | | | startTokenPos: unset + | | | | | | | | | endTokenPos: unset + | | | | | | | | | startLine: 16 + | | | | | | | | | endLine: 16 + | | | | | | | | attributes: array (1) + | | | | | | | | | 0 => Nette\Neon\Node\ArrayItemNode + | | | | | | | | | | code: 'a: 1' + | | | | | | | | | | key: Nette\Neon\Node\LiteralNode + | | | | | | | | | | | code: 'a' + | | | | | | | | | | | value: 'a' + | | | | | | | | | | | startTokenPos: unset + | | | | | | | | | | | endTokenPos: unset + | | | | | | | | | | | startLine: 16 + | | | | | | | | | | | endLine: 16 + | | | | | | | | | | value: Nette\Neon\Node\LiteralNode + | | | | | | | | | | | code: '1' + | | | | | | | | | | | value: 1 + | | | | | | | | | | | startTokenPos: unset + | | | | | | | | | | | endTokenPos: unset + | | | | | | | | | | | startLine: 16 + | | | | | | | | | | | endLine: 16 + | | | | | | | | | | startTokenPos: unset + | | | | | | | | | | endTokenPos: unset + | | | | | | | | | | startLine: 16 + | | | | | | | | | | endLine: 16 + | | | | | | | | startTokenPos: unset + | | | | | | | | endTokenPos: unset + | | | | | | | | startLine: 16 + | | | | | | | | endLine: 16 + | | | | | | | 1 => Nette\Neon\Node\EntityNode + | | | | | | | | code: 'foo()' + | | | | | | | | value: Nette\Neon\Node\LiteralNode + | | | | | | | | | code: 'foo' + | | | | | | | | | value: 'foo' + | | | | | | | | | startTokenPos: unset + | | | | | | | | | endTokenPos: unset + | | | | | | | | | startLine: 16 + | | | | | | | | | endLine: 16 + | | | | | | | | attributes: array (0) + | | | | | | | | startTokenPos: unset + | | | | | | | | endTokenPos: unset + | | | | | | | | startLine: 16 + | | | | | | | | endLine: 16 + | | | | | | | 2 => Nette\Neon\Node\EntityNode + | | | | | | | | code: 'bar' + | | | | | | | | value: Nette\Neon\Node\LiteralNode + | | | | | | | | | code: 'bar' + | | | | | | | | | value: 'bar' + | | | | | | | | | startTokenPos: unset + | | | | | | | | | endTokenPos: unset + | | | | | | | | | startLine: 16 + | | | | | | | | | endLine: 16 + | | | | | | | | attributes: array (0) + | | | | | | | | startTokenPos: unset + | | | | | | | | endTokenPos: unset + | | | | | | | | startLine: 16 + | | | | | | | | endLine: 16 | | | | | | startTokenPos: unset | | | | | | endTokenPos: unset | | | | | | startLine: 16