當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。