hhspecify / hhassert
Simple assertion library for Hack
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:Hack
Requires
- hhvm: >=3.5.0
Requires (Dev)
This package is not auto-updated.
Last update: 2024-10-26 18:17:30 UTC
README
hhassert is simple assertion library for Hack.
You can use easily as assert module of nodejs.
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