Skip to content

Commit dad6890

Browse files
committed
test: updated
1 parent a30cdca commit dad6890

File tree

2 files changed

+66
-53
lines changed

2 files changed

+66
-53
lines changed

tests/Neon/Decoder.entity.phpt

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
/**
4+
* Test: decode entity
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
use Nette\Neon\Entity;
10+
use Nette\Neon\Neon;
11+
use Tester\Assert;
12+
13+
require __DIR__ . '/../bootstrap.php';
14+
15+
16+
Assert::type(Nette\Neon\Entity::class, Neon::decode('@item(a, b)'));
17+
18+
19+
Assert::equal(
20+
new Entity('@item', ['a', 'b']),
21+
Neon::decode('@item(a, b)'),
22+
);
23+
24+
25+
Assert::equal(
26+
new Entity('@item<item>', ['a', 'b']),
27+
Neon::decode('@item<item>(a, b)'),
28+
);
29+
30+
31+
Assert::equal(
32+
new Entity('item', ['a', 'b']),
33+
Neon::decode('item (a, b)'),
34+
);
35+
36+
37+
Assert::equal(
38+
new Entity([], []),
39+
Neon::decode('[]()'),
40+
);
41+
42+
43+
Assert::equal(
44+
new Entity(Neon::Chain, [
45+
new Entity('first', ['a', 'b']),
46+
new Entity('second'),
47+
]),
48+
Neon::decode('first(a, b)second'),
49+
);
50+
51+
52+
Assert::equal(
53+
new Entity(Neon::Chain, [
54+
new Entity('first', ['a', 'b']),
55+
new Entity('second', [1, 2]),
56+
]),
57+
Neon::decode('first(a, b)second(1, 2)'),
58+
);
59+
60+
Assert::equal(
61+
new Entity(Neon::Chain, [
62+
new Entity(1, []),
63+
new Entity(2, []),
64+
]),
65+
Neon::decode('1() 2()'),
66+
);

tests/Neon/Decoder.inline.array.phpt

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
declare(strict_types=1);
88

9-
use Nette\Neon\Entity;
109
use Nette\Neon\Neon;
1110
use Tester\Assert;
1211

@@ -65,57 +64,5 @@ Assert::same(
6564
);
6665

6766

68-
Assert::type(Nette\Neon\Entity::class, Neon::decode('@item(a, b)'));
69-
70-
71-
Assert::equal(
72-
new Entity('@item', ['a', 'b']),
73-
Neon::decode('@item(a, b)'),
74-
);
75-
76-
77-
Assert::equal(
78-
new Entity('@item<item>', ['a', 'b']),
79-
Neon::decode('@item<item>(a, b)'),
80-
);
81-
82-
83-
Assert::equal(
84-
new Entity('item', ['a', 'b']),
85-
Neon::decode('item (a, b)'),
86-
);
87-
88-
89-
Assert::equal(
90-
new Entity([], []),
91-
Neon::decode('[]()'),
92-
);
93-
94-
95-
Assert::equal(
96-
new Entity(Neon::Chain, [
97-
new Entity('first', ['a', 'b']),
98-
new Entity('second'),
99-
]),
100-
Neon::decode('first(a, b)second'),
101-
);
102-
103-
104-
Assert::equal(
105-
new Entity(Neon::Chain, [
106-
new Entity('first', ['a', 'b']),
107-
new Entity('second', [1, 2]),
108-
]),
109-
Neon::decode('first(a, b)second(1, 2)'),
110-
);
111-
112-
Assert::equal(
113-
new Entity(Neon::Chain, [
114-
new Entity(1, []),
115-
new Entity(2, []),
116-
]),
117-
Neon::decode('1() 2()'),
118-
);
119-
12067
// JSON compatibility
12168
Assert::same(['a' => true], Neon::decode('{"a":true}'));

0 commit comments

Comments
 (0)