faissaloux/pest-plugin-math
Math plugin for Pest PHP
10
12
| Install | |
|---|---|
composer require faissaloux/pest-plugin-math |
|
| Latest Version: | v1.6.0 |
| PHP: | ^8.1 |
| License: | MIT |
| Last Updated: | Nov 21, 2025 |
| Links: | GitHub · Packagist |
Maintainer: faissaloux
PEST PLUGIN MATH
This plugin affords math related expectations.
Requirements
| pest | php | pest-plugin-math |
|---|---|---|
| ^2.0 | ^8.1 | ^1.0.0 |
| ^3.0 | ^8.2 | ^1.3.0 |
| ^4.0 | ^8.3 | ^1.5.0 |
toBeDivisibleBy()
expect(8)->toBeDivisibleBy(4);
expect(8)->not->toBeDivisibleBy(3);
toBePowerOf()
expect(4096)->toBePowerOf(8);
expect(128)->not->toBePowerOf(3);
toBeMaxOf()
expect(6)->toBeMaxOf([-6, 0, 6]);
expect(5.5)->not->toBeMaxOf([2, 4.2, 5.5, 6]);
toBeMinOf()
expect(-6)->toBeMinOf([-6, 0, 1]);
expect(5.5)->not->toBeMinOf([2, 4.2, 5.5, 6]);
toBeEven()
expect(6)->toBeEven();
expect(7)->not->toBeEven();
toBeOdd()
expect(7)->toBeOdd();
expect(6)->not->toBeOdd();
toBePrime()
expect(3)->toBePrime();
expect(6)->not->toBePrime();
toBePositive()
expect(1)->toBePositive();
expect(-2)->not->toBePositive();
toBeNegative()
expect(-1)->toBeNegative();
expect(2)->not->toBeNegative();
toBeSqrtOf()
expect(3)->toBeSqrtOf(9);
expect(3.16)->toBeSqrtOf(10, 2);
expect(2)->not->toBeSqrtOf(9);
toBeFactorialOf()
expect(6)->toBeFactorialOf(3);
expect(4)->not->toBeFactorialOf(2);
toBeAbsoluteOf()
$$\mid -3 \mid$$
expect(3)->toBeAbsoluteOf(-3);
expect(-3)->not->toBeAbsoluteOf(-3);
toBeLogarithmOf()
$$\log_{base}(number)$$
Base default is euler's number.
expect(0.69897000433602)->toBeLogarithmOf(number: 5, base: 10);
expect(1)->not->toBeLogarithmOf(number: 1);
toBeSumOf()
expect(6)->toBeSumOf([1, 2, 3]);
expect(4)->not->toBeSumOf([2, 3]);
toBeSummationOf()
$$\sum\limits_n^k x * 2$$
expect(2)->toBeSummationOf(fn (int $x) => $x * 2, from: 0, to: 1);
expect(3)->not->toBeSummationOf(fn (int $x) => $x * 2, from: 0, to: 1);
toBeProdOf()
expect(6)->toBeProdOf([1, 2, 3]);
expect(4)->not->toBeProdOf([2, 3]);
toBeProductOf()
$$\prod\limits_n^k x * 2$$
expect(3715891200)->toBeProductOf(fn (int $x) => $x * 2, from: 1, to: 10);
expect(1)->not->toBeProductOf(fn (int $x) => $x * 2, from: 1, to: 10);