From 2efdf8ba214ea3c93036729b45a99a8d814069c0 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sun, 28 Apr 2024 22:27:33 +0200 Subject: [PATCH] test: updated --- tests/Neon/Decoder.entity.phpt | 66 ++++++++++++++++++++++++++++ tests/Neon/Decoder.inline.array.phpt | 53 ---------------------- 2 files changed, 66 insertions(+), 53 deletions(-) create mode 100644 tests/Neon/Decoder.entity.phpt diff --git a/tests/Neon/Decoder.entity.phpt b/tests/Neon/Decoder.entity.phpt new file mode 100644 index 0000000..6efa636 --- /dev/null +++ b/tests/Neon/Decoder.entity.phpt @@ -0,0 +1,66 @@ +', ['a', 'b']), + Neon::decode('@item(a, b)'), +); + + +Assert::equal( + new Entity('item', ['a', 'b']), + Neon::decode('item (a, b)'), +); + + +Assert::equal( + new Entity([], []), + Neon::decode('[]()'), +); + + +Assert::equal( + new Entity(Neon::Chain, [ + new Entity('first', ['a', 'b']), + new Entity('second'), + ]), + Neon::decode('first(a, b)second'), +); + + +Assert::equal( + new Entity(Neon::Chain, [ + new Entity('first', ['a', 'b']), + new Entity('second', [1, 2]), + ]), + Neon::decode('first(a, b)second(1, 2)'), +); + +Assert::equal( + new Entity(Neon::Chain, [ + new Entity(1, []), + new Entity(2, []), + ]), + Neon::decode('1() 2()'), +); diff --git a/tests/Neon/Decoder.inline.array.phpt b/tests/Neon/Decoder.inline.array.phpt index 3b0bcfe..967bb43 100644 --- a/tests/Neon/Decoder.inline.array.phpt +++ b/tests/Neon/Decoder.inline.array.phpt @@ -6,7 +6,6 @@ declare(strict_types=1); -use Nette\Neon\Entity; use Nette\Neon\Neon; use Tester\Assert; @@ -65,57 +64,5 @@ Assert::same( ); -Assert::type(Nette\Neon\Entity::class, Neon::decode('@item(a, b)')); - - -Assert::equal( - new Entity('@item', ['a', 'b']), - Neon::decode('@item(a, b)'), -); - - -Assert::equal( - new Entity('@item', ['a', 'b']), - Neon::decode('@item(a, b)'), -); - - -Assert::equal( - new Entity('item', ['a', 'b']), - Neon::decode('item (a, b)'), -); - - -Assert::equal( - new Entity([], []), - Neon::decode('[]()'), -); - - -Assert::equal( - new Entity(Neon::Chain, [ - new Entity('first', ['a', 'b']), - new Entity('second'), - ]), - Neon::decode('first(a, b)second'), -); - - -Assert::equal( - new Entity(Neon::Chain, [ - new Entity('first', ['a', 'b']), - new Entity('second', [1, 2]), - ]), - Neon::decode('first(a, b)second(1, 2)'), -); - -Assert::equal( - new Entity(Neon::Chain, [ - new Entity(1, []), - new Entity(2, []), - ]), - Neon::decode('1() 2()'), -); - // JSON compatibility Assert::same(['a' => true], Neon::decode('{"a":true}'));