-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from fredemmott/fastroute-hhi
HHI: Change the options arrays for dispatchers to shapes
- Loading branch information
Showing
6 changed files
with
108 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
assume_php=false |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace FastRoute; | ||
|
||
class HackTypecheckerTest extends \PhpUnit_Framework_TestCase { | ||
const SERVER_ALREADY_RUNNING_CODE = 77; | ||
public function testTypechecks($recurse = true) { | ||
if (!defined('HHVM_VERSION')) { | ||
$this->markTestSkipped("HHVM only"); | ||
} | ||
if (!version_compare(HHVM_VERSION, '3.9.0', '>=')) { | ||
$this->markTestSkipped('classname<T> requires HHVM 3.9+'); | ||
} | ||
|
||
// The typechecker recurses the whole tree, so it makes sure | ||
// that everything in fixtures/ is valid when this runs. | ||
|
||
$output = array(); | ||
$exit_code = null; | ||
exec( | ||
'hh_server --check '.escapeshellarg(__DIR__.'/../../').' 2>&1', | ||
$output, | ||
$exit_code | ||
); | ||
if ($exit_code === self::SERVER_ALREADY_RUNNING_CODE) { | ||
$this->assertTrue( | ||
$recurse, | ||
"Typechecker still running after running hh_client stop" | ||
); | ||
// Server already running - 3.10 => 3.11 regression: | ||
// https://github.com/facebook/hhvm/issues/6646 | ||
exec('hh_client stop 2>/dev/null'); | ||
$this->testTypechecks(/* recurse = */ false); | ||
return; | ||
|
||
} | ||
$this->assertSame(0, $exit_code, implode("\n", $output)); | ||
} | ||
} |
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,29 @@ | ||
<?hh | ||
|
||
namespace FastRoute\TestFixtures; | ||
|
||
function all_options_simple(): \FastRoute\Dispatcher { | ||
return \FastRoute\simpleDispatcher( | ||
$collector ==> {}, | ||
shape( | ||
'routeParser' => \FastRoute\RouteParser\Std::class, | ||
'dataGenerator' => \FastRoute\DataGenerator\GroupCountBased::class, | ||
'dispatcher' => \FastRoute\Dispatcher\GroupCountBased::class, | ||
'routeCollector' => \FastRoute\RouteCollector::class, | ||
), | ||
); | ||
} | ||
|
||
function all_options_cached(): \FastRoute\Dispatcher { | ||
return \FastRoute\cachedDispatcher( | ||
$collector ==> {}, | ||
shape( | ||
'routeParser' => \FastRoute\RouteParser\Std::class, | ||
'dataGenerator' => \FastRoute\DataGenerator\GroupCountBased::class, | ||
'dispatcher' => \FastRoute\Dispatcher\GroupCountBased::class, | ||
'routeCollector' => \FastRoute\RouteCollector::class, | ||
'cacheFile' => '/dev/null', | ||
'cacheDisabled' => false, | ||
), | ||
); | ||
} |
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 @@ | ||
<?hh | ||
|
||
namespace FastRoute\TestFixtures; | ||
|
||
function empty_options_simple(): \FastRoute\Dispatcher { | ||
return \FastRoute\simpleDispatcher($collector ==> {}, shape()); | ||
} | ||
|
||
function empty_options_cached(): \FastRoute\Dispatcher { | ||
return \FastRoute\cachedDispatcher($collector ==> {}, shape()); | ||
} |
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 @@ | ||
<?hh | ||
|
||
namespace FastRoute\TestFixtures; | ||
|
||
function no_options_simple(): \FastRoute\Dispatcher { | ||
return \FastRoute\simpleDispatcher($collector ==> {}); | ||
} | ||
|
||
function no_options_cached(): \FastRoute\Dispatcher { | ||
return \FastRoute\cachedDispatcher($collector ==> {}); | ||
} |