定制 hhspecify/hhassert 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hhspecify/hhassert

最新稳定版本:0.2.0

Composer 安装命令:

composer require hhspecify/hhassert

包简介

Simple assertion library for Hack

README 文档

README

hhassert is simple assertion library for Hack.
You can use easily as assert module of nodejs.

Build Status HHVM Status Dependency Status

Basic Usage

It will specify the hhassert\Assert in the use keyword.

use hhassert\Assert;

Assert::ok(1 === 1);      //Passed
Assert::ok("a" === "b");  //Failed

Assert::equal("a", "a");  //Passed
Assert::equal(1, 1);      //Passed
Assert::equal(1.0, 2.0);  //Failed

Assert::notEqual("a", "b"); //Passed
Assert::notEqual("a", "a"); //Failed

Assert::throws(() ==> {
    throw new InvalidArgumentException("exception!!");
}, InvalidArgumentException::class);

Custom matcher

You can be the registration of the matcher in the configure method. Matcher specified in the lambda expression.

Assert::configure((ContextBuilder $builder) ==> {

    $builder->registerMatcher('custom_matcher', (...) ==> {
        list($a, $b) = func_get_args();

        if ($a !== $b) {
            throw new AssertionFailedException("custom matcher");
        }
    });

});

Assert::custom_matcher("a", "b");

Run the test

composer install
composer test

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Hack

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-25