add {break} and {continue} tests

This commit is contained in:
uwetews
2016-01-29 02:33:40 +01:00
parent 39631cce4b
commit 33bdb44723
7 changed files with 74 additions and 0 deletions

View File

@@ -269,4 +269,40 @@ class CompileForeachTest extends PHPUnit_Smarty
$this->assertEquals("outer=0#0-9inner=1#0-4inner=2#0-10##outer=1#1-8inner=1#1-4inner=2#1-10#####hallo",
$this->smarty->fetch('028_foreach.tpl'));
}
public function testForeachBreak_29()
{
$this->assertEquals("12",
$this->smarty->fetch('029_foreach.tpl'));
}
public function testForeachBreak_30()
{
$this->assertEquals("a1a2b1b2",
$this->smarty->fetch('030_foreach.tpl'));
}
public function testForeachBreak_31()
{
$this->assertEquals("a1a2",
$this->smarty->fetch('031_foreach.tpl'));
}
public function testForeachContinue_32()
{
$this->assertEquals("1245",
$this->smarty->fetch('032_foreach.tpl'));
}
public function testForeachContinue_33()
{
$this->assertEquals("a1a2a4a5b1b2b4b5",
$this->smarty->fetch('033_foreach.tpl'));
}
public function testForeachContinue_34()
{
$this->assertEquals("a1a2b1b2",
$this->smarty->fetch('034_foreach.tpl'));
}
}

View File

@@ -0,0 +1,5 @@
{strip}
{foreach [1,2,3,4,5] as $i}
{if $i == 3}{break}{/if}
{$i}
{/foreach}

View File

@@ -0,0 +1,7 @@
{strip}
{foreach ['a','b'] as $a}
{foreach [1,2,3,4,5] as $i}
{if $i == 3}{break}{/if}
{$a}{$i}
{/foreach}
{/foreach}

View File

@@ -0,0 +1,7 @@
{strip}
{foreach ['a','b'] as $a}
{foreach [1,2,3,4,5] as $i}
{if $i == 3}{break 2}{/if}
{$a}{$i}
{/foreach}
{/foreach}

View File

@@ -0,0 +1,5 @@
{strip}
{foreach [1,2,3,4,5] as $i}
{if $i == 3}{continue}{/if}
{$i}
{/foreach}

View File

@@ -0,0 +1,7 @@
{strip}
{foreach ['a','b'] as $a}
{foreach [1,2,3,4,5] as $i}
{if $i == 3}{continue}{/if}
{$a}{$i}
{/foreach}
{/foreach}

View File

@@ -0,0 +1,7 @@
{strip}
{foreach ['a','b'] as $a}
{foreach [1,2,3,4,5] as $i}
{if $i == 3}{continue 2}{/if}
{$a}{$i}
{/foreach}
{/foreach}