本文整理汇总了PHP中Test::assert方法的典型用法代码示例。如果您正苦于以下问题:PHP Test::assert方法的具体用法?PHP Test::assert怎么用?PHP Test::assert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Test
的用法示例。
在下文中一共展示了Test::assert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: suite
static function suite($name, $fn)
{
array_push(self::$stack, $name);
$fn(function ($description, $condition) {
Test::assert($description, $condition);
});
array_pop(self::$stack);
}
示例2: backrefs
static function backrefs()
{
$r = preg_merge('', array('/(a)/', '/(b)\\1/'));
Test::assert($r, 'preg_merge');
Test::assertNoMatch($r, 'aba');
Test::assertMatch($r, 'abb');
Test::assertNoMatch($r, 'ab');
Test::assertNoMatch($r, 'xbb');
$r = preg_merge('', array('/(a)/', '/(b)\\\\1/'));
Test::assert($r, 'preg_merge');
Test::assertMatch($r, 'ab\\1');
$r = preg_merge('', array('/(a)/', '/(b)\\\\\\1/'));
var_dump('/(b)\\\\\\1/');
var_dump($r);
Test::assert($r, 'preg_merge');
Test::assertMatch($r, 'ab\\b');
$r = preg_merge('', array('/(a)/', '/(b)\\\\\\1/', '/c((d)\\2)/'));
Test::assert($r, 'preg_merge');
Test::assertMatch($r, 'ab\\bcdd');
}
示例3: is_nan
Test::assert('parseInt 2', $num === 5.0);
$num = $Number->callMethod('parseInt', ' -15.0');
Test::assert('parseInt 3', $num === -15.0);
$num = $Number->callMethod('parseInt', 'x');
Test::assert('parseInt 4', is_nan($num));
$num = $Number->callMethod('parseFloat', '-05e2x');
Test::assert('parseFloat 1', $num === -500.0);
$num = $Number->callMethod('parseFloat', ' +05.0');
Test::assert('parseFloat 2', $num === 5.0);
$num = $Number->callMethod('parseFloat', 'x');
Test::assert('parseFloat 3', is_nan($num));
});
Test::suite('JSON', function () use($JSON, $Object, $Array) {
$str = '{"a": [1], "b": false, "c": []}';
$obj = $JSON->callMethod('parse', $str);
Test::assert('parsed empty array', $obj->get('c')->get('length') === 0.0);
Test::assert('parsed array', $obj->get('a')->get(0) === 1.0);
Test::assert('parsed boolean', $obj->get('b') === false);
$str2 = $JSON->callMethod('stringify', $obj);
Test::assert('stringify', $str2 === '{"a":[1],"b":false,"c":[]}');
});
require_once 'test/compiled/helpers.php';
require_once 'test/compiled/core.php';
require_once 'test/compiled/number.php';
require_once 'test/compiled/string.php';
require_once 'test/compiled/regex.php';
require_once 'test/compiled/array.php';
require_once 'test/compiled/buffer.php';
require_once 'test/compiled/json.php';
require_once 'test/compiled/module-fs.php';
$console->callMethod('log', 'Success');