Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #153: Support for new finally keyword implemented.
- Loading branch information
Manuel Pichler
committed
Apr 23, 2014
1 parent
337b381
commit e536e7a
Showing
15 changed files
with
344 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
170 changes: 170 additions & 0 deletions
170
src/test/php/PDepend/Source/AST/ASTFinallyStatementTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
<?php | ||
/** | ||
* This file is part of PDepend. | ||
* | ||
* PHP Version 5 | ||
* | ||
* Copyright (c) 2008-2013, Manuel Pichler <mapi@pdepend.org>. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* | ||
* * Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in | ||
* the documentation and/or other materials provided with the | ||
* distribution. | ||
* | ||
* * Neither the name of Manuel Pichler nor the names of his | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* @copyright 2008-2013 Manuel Pichler. All rights reserved. | ||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License | ||
*/ | ||
|
||
namespace PDepend\Source\AST; | ||
|
||
/** | ||
* Test case for the {@link \PDepend\Source\AST\ASTFinallyStatement} class. | ||
* | ||
* @copyright 2008-2013 Manuel Pichler. All rights reserved. | ||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License | ||
* | ||
* @covers \PDepend\Source\Language\PHP\AbstractPHPParser | ||
* @covers \PDepend\Source\AST\ASTFinallyStatement | ||
* @group unittest | ||
*/ | ||
class ASTFinallyStatementTest extends ASTNodeTest | ||
{ | ||
/** | ||
* Tests the start line value. | ||
* | ||
* @return void | ||
*/ | ||
public function testFinallyStatementHasExpectedStartLine() | ||
{ | ||
$stmt = $this->_getFirstFinallyStatementInFunction(__METHOD__); | ||
$this->assertEquals(8, $stmt->getStartLine()); | ||
} | ||
|
||
/** | ||
* Tests the start column value. | ||
* | ||
* @return void | ||
*/ | ||
public function testFinallyStatementHasExpectedStartColumn() | ||
{ | ||
$stmt = $this->_getFirstFinallyStatementInFunction(__METHOD__); | ||
$this->assertEquals(7, $stmt->getStartColumn()); | ||
} | ||
|
||
/** | ||
* Tests the end line value. | ||
* | ||
* @return void | ||
*/ | ||
public function testFinallyStatementHasExpectedEndLine() | ||
{ | ||
$stmt = $this->_getFirstFinallyStatementInFunction(__METHOD__); | ||
$this->assertEquals(10, $stmt->getEndLine()); | ||
} | ||
|
||
/** | ||
* Tests the end column value. | ||
* | ||
* @return void | ||
*/ | ||
public function testFinallyStatementHasExpectedEndColumn() | ||
{ | ||
$stmt = $this->_getFirstFinallyStatementInFunction(__METHOD__); | ||
$this->assertEquals(5, $stmt->getEndColumn()); | ||
} | ||
|
||
/** | ||
* testOnlyFinallyStatementHasExpectedStartLine | ||
* | ||
* @return void | ||
*/ | ||
public function testOnlyFinallyStatementHasExpectedStartLine() | ||
{ | ||
$stmt = $this->_getFirstFinallyStatementInFunction(__METHOD__); | ||
$this->assertEquals(6, $stmt->getStartLine()); | ||
} | ||
|
||
/** | ||
* testOnlyFinallyStatementHasExpectedStartColumn | ||
* | ||
* @return void | ||
*/ | ||
public function testOnlyFinallyStatementHasExpectedStartColumn() | ||
{ | ||
$stmt = $this->_getFirstFinallyStatementInFunction(__METHOD__); | ||
$this->assertEquals(7, $stmt->getStartColumn()); | ||
} | ||
|
||
/** | ||
* testOnlyFinallyStatementHasExpectedEndLine | ||
* | ||
* @return void | ||
*/ | ||
public function testOnlyFinallyStatementHasExpectedEndLine() | ||
{ | ||
$stmt = $this->_getFirstFinallyStatementInFunction(__METHOD__); | ||
$this->assertEquals(8, $stmt->getEndLine()); | ||
} | ||
|
||
/** | ||
* testOnlyFinallyStatementHasExpectedEndColumn | ||
* | ||
* @return void | ||
*/ | ||
public function testOnlyFinallyStatementHasExpectedEndColumn() | ||
{ | ||
$stmt = $this->_getFirstFinallyStatementInFunction(__METHOD__); | ||
$this->assertEquals(5, $stmt->getEndColumn()); | ||
} | ||
|
||
/** | ||
* testThirdChildOfFinallyStatementIsScopeStatement | ||
* | ||
* @return void | ||
*/ | ||
public function testChildOfFinallyStatementIsScopeStatement() | ||
{ | ||
$stmt = $this->_getFirstFinallyStatementInFunction(__METHOD__); | ||
$this->assertInstanceOf('PDepend\\Source\\AST\\ASTScopeStatement', $stmt->getChild(0)); | ||
} | ||
|
||
/** | ||
* Returns a node instance for the currently executed test case. | ||
* | ||
* @param string $testCase Name of the calling test case. | ||
* | ||
* @return \PDepend\Source\AST\ASTFinallyStatement | ||
*/ | ||
private function _getFirstFinallyStatementInFunction($testCase) | ||
{ | ||
return $this->getFirstNodeOfTypeInFunction( | ||
$testCase, | ||
'PDepend\\Source\\AST\\ASTFinallyStatement' | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...rces/files/Source/AST/ASTFinallyStatement/testChildOfFinallyStatementIsScopeStatement.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
function testChildOfFinallyStatementIsScopeStatement() | ||
{ | ||
try { | ||
fooBar(); | ||
} catch (Exception $e) { | ||
// Hello World | ||
} finally { | ||
echo "FOO"; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...sources/files/Source/AST/ASTFinallyStatement/testFinallyStatementHasExpectedEndColumn.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
function testFinallyStatementHasExpectedEndColumn() | ||
{ | ||
try { | ||
throw Exception(); | ||
} catch (Exception $e) { | ||
|
||
} finally { | ||
echo "FOO"; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...resources/files/Source/AST/ASTFinallyStatement/testFinallyStatementHasExpectedEndLine.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
function testFinallyStatementHasExpectedEndLine() | ||
{ | ||
try { | ||
throw Exception(); | ||
} catch (Exception $e) { | ||
|
||
} finally { | ||
echo "FOO"; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...urces/files/Source/AST/ASTFinallyStatement/testFinallyStatementHasExpectedStartColumn.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
function testFinallyStatementHasExpectedStartColumn() | ||
{ | ||
try { | ||
throw Exception(); | ||
} catch (Exception $e) { | ||
|
||
} finally { | ||
echo "FOO"; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...sources/files/Source/AST/ASTFinallyStatement/testFinallyStatementHasExpectedStartLine.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
function testFinallyStatementHasExpectedStartLine() | ||
{ | ||
try { | ||
throw Exception(); | ||
} catch (Exception $e) { | ||
|
||
} finally { | ||
echo "FOO"; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...ces/files/Source/AST/ASTFinallyStatement/testOnlyFinallyStatementHasExpectedEndColumn.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
function testFinallyStatementHasExpectedEndColumn() | ||
{ | ||
try { | ||
throw Exception(); | ||
} finally { | ||
echo "FOO"; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...urces/files/Source/AST/ASTFinallyStatement/testOnlyFinallyStatementHasExpectedEndLine.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
function testFinallyStatementHasExpectedEndLine() | ||
{ | ||
try { | ||
throw Exception(); | ||
} finally { | ||
echo "FOO"; | ||
} | ||
} |
Oops, something went wrong.