Skip to content

Commit

Permalink
test: updated
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Apr 28, 2024
1 parent b332ea2 commit 2efdf8b
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 53 deletions.
66 changes: 66 additions & 0 deletions tests/Neon/Decoder.entity.phpt
@@ -0,0 +1,66 @@
<?php

/**
* Test: decode entity
*/

declare(strict_types=1);

use Nette\Neon\Entity;
use Nette\Neon\Neon;
use Tester\Assert;

require __DIR__ . '/../bootstrap.php';


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<item>', ['a', 'b']),
Neon::decode('@item<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()'),
);
53 changes: 0 additions & 53 deletions tests/Neon/Decoder.inline.array.phpt
Expand Up @@ -6,7 +6,6 @@

declare(strict_types=1);

use Nette\Neon\Entity;
use Nette\Neon\Neon;
use Tester\Assert;

Expand Down Expand Up @@ -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<item>', ['a', 'b']),
Neon::decode('@item<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}'));

0 comments on commit 2efdf8b

Please sign in to comment.