Skip to content

Commit

Permalink
Moved test to FindEndOfStatementTest file
Browse files Browse the repository at this point in the history
  • Loading branch information
michalbundyra committed Dec 8, 2019
1 parent 1be4196 commit 17f5e17
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
5 changes: 5 additions & 0 deletions tests/Core/File/FindEndOfStatementTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ $a = [
'a' => fn() => return 1,
'b' => fn() => return 1,
];

/* testArrowFunctionEndOfStatement */
static fn ($a) => $a;

return 0;
18 changes: 18 additions & 0 deletions tests/Core/File/FindEndOfStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,22 @@ public function testArrowFunctionArrayValue()
}//end testArrowFunctionArrayValue()


/**
* Test end of statement for fn closure.
*
* @return void
*/
public function testArrayFunctionEndOfStatement()
{
$static = (self::$phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testArrowFunctionEndOfStatement */') + 2);
$fn = self::$phpcsFile->findNext(T_FN, ($static + 1));

$endOfStatementStatic = self::$phpcsFile->findEndOfStatement($static);
$endOfStatementFn = self::$phpcsFile->findEndOfStatement($fn);

$this->assertSame($endOfStatementFn, $endOfStatementStatic);

}//end testArrayFunctionEndOfStatement()


}//end class
5 changes: 0 additions & 5 deletions tests/Core/Tokenizer/BackfillFnTokenTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,3 @@ fn(callable $a) : callable => $a;

/* testTernary */
$fn = fn($a) => $a ? /* testTernaryThen */ fn() : string => 'a' : /* testTernaryElse */ fn() : string => 'b';

/* testEndOfStatement */
static fn ($a) => $a;

return 0;
19 changes: 0 additions & 19 deletions tests/Core/Tokenizer/BackfillFnTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,23 +594,4 @@ private function backfillHelper($token)
}//end backfillHelper()


/**
* Test end of statement for fn closure.
*
* @return void
*/
public function testEndOfStatement()
{
$token = $this->getTargetToken('/* testEndOfStatement */', T_FN);
$this->backfillHelper($token);

$static = self::$phpcsFile->findPrevious(T_STATIC, ($token - 1));
$endOfStatementStatic = self::$phpcsFile->findEndOfStatement($static);
$endOfStatementFn = self::$phpcsFile->findEndOfStatement($token);

$this->assertSame($endOfStatementFn, $endOfStatementStatic);

}//end testEndOfStatement()


}//end class

0 comments on commit 17f5e17

Please sign in to comment.