Skip to content

Commit f7a2f6e

Browse files
committed
Add unit test for for statement
1 parent 0688fcb commit f7a2f6e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/Phug/Compiler/ForCompilerTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,23 @@ public function testCompile()
3535
' p?!=$item',
3636
]
3737
);
38+
$this->assertCompile(
39+
[
40+
'<?php $__pug_temp_empty = true; foreach ($items as $item) { ?>',
41+
'<?php $__pug_temp_empty = false ?>',
42+
'<p><?= $item ?></p>',
43+
'<?php } ?>',
44+
'<?php if ($__pug_temp_empty) { ?>',
45+
'<p>no items</p>',
46+
'<?php } ?>',
47+
],
48+
[
49+
'for $item in $items'."\n",
50+
' p?!=$item'."\n",
51+
'else'."\n",
52+
' p no items',
53+
]
54+
);
3855
$this->assertCompile(
3956
[
4057
'<?php foreach ($items as $key => $item) { ?>',

0 commit comments

Comments
 (0)