当前位置: 首页>>代码示例>>PHP>>正文


PHP Test::assert方法代码示例

本文整理汇总了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);
 }
开发者ID:mk-pmb,项目名称:js2php,代码行数:8,代码来源:Test.php

示例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');
 }
开发者ID:stievie,项目名称:hyperlight,代码行数:20,代码来源:tests.php

示例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');
开发者ID:mk-pmb,项目名称:js2php,代码行数:31,代码来源:tests.php


注:本文中的Test::assert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。