1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Add more tests for switch fallthrough

This commit is contained in:
Matthew Brown 2016-08-30 00:04:54 -04:00
parent 4a88a376df
commit a441bef349

View File

@ -195,6 +195,54 @@ class ScopeTest extends PHPUnit_Framework_TestCase
$file_checker->check();
}
public function testSwitchVariableWithFallthrough()
{
$stmts = self::$_parser->parse('<?php
foreach ([\'a\', \'b\', \'c\'] as $letter) {
switch ($letter) {
case \'a\':
case \'b\':
$foo = 2;
break;
default:
$foo = 3;
break;
}
$moo = $foo;
}
');
$file_checker = new \Psalm\Checker\FileChecker('somefile.php', $stmts);
$file_checker->check();
}
public function testSwitchVariableWithFallthroughStatement()
{
$stmts = self::$_parser->parse('<?php
foreach ([\'a\', \'b\', \'c\'] as $letter) {
switch ($letter) {
case \'a\':
$bar = 1;
case \'b\':
$foo = 2;
break;
default:
$foo = 3;
break;
}
$moo = $foo;
}
');
$file_checker = new \Psalm\Checker\FileChecker('somefile.php', $stmts);
$file_checker->check();
}
public function testTryCatchVar()
{
$stmts = self::$_parser->parse('<?php