-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH Include filename of script in predictable_random_int()
- Loading branch information
1 parent
1eaf525
commit 7cb4fe3
Showing
2 changed files
with
36 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class FuncsScriptsTest extends TestCase | ||
{ | ||
public function testPredictableRandomInt() | ||
{ | ||
global $MODULE_DIR; | ||
$MODULE_DIR = 'lorem'; | ||
$this->assertSame(0, predictable_random_int(15)); | ||
$this->assertSame(25, predictable_random_int(30)); | ||
$this->assertSame(45, predictable_random_int(30, 20)); | ||
$MODULE_DIR = 'donuts'; | ||
$this->assertSame(13, predictable_random_int(15)); | ||
// use eval to simulate calling from a different file | ||
// it will suffix "(19) : eval()'d code" to the calling file in debug_backtrace() | ||
$ret = null; | ||
eval('$ret = predictable_random_int(15);'); | ||
$this->assertSame(2, $ret); | ||
} | ||
} |