PHP code example of faissaloux / pest-plugin-math

1. Go to this page and download the library: Download faissaloux/pest-plugin-math library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

faissaloux / pest-plugin-math example snippets


    expect(8)->toBeDivisibleBy(4);
    expect(8)->not->toBeDivisibleBy(3);

    expect(4096)->toBePowerOf(8);
    expect(128)->not->toBePowerOf(3);

    expect(6)->toBeMaxOf([-6, 0, 6]);
    expect(5.5)->not->toBeMaxOf([2, 4.2, 5.5, 6]);

    expect(-6)->toBeMinOf([-6, 0, 1]);
    expect(5.5)->not->toBeMinOf([2, 4.2, 5.5, 6]);

    expect(6)->toBeEven();
    expect(7)->not->toBeEven();

    expect(7)->toBeOdd();
    expect(6)->not->toBeOdd();

    expect(3)->toBePrime();
    expect(6)->not->toBePrime();

    expect(1)->toBePositive();
    expect(-2)->not->toBePositive();

    expect(-1)->toBeNegative();
    expect(2)->not->toBeNegative();

    expect(3)->toBeSqrtOf(9);
    expect(3.16)->toBeSqrtOf(10, 2);
    expect(2)->not->toBeSqrtOf(9);

    expect(6)->toBeFactorialOf(3);
    expect(4)->not->toBeFactorialOf(2);

    expect(3)->toBeAbsoluteOf(-3);
    expect(-3)->not->toBeAbsoluteOf(-3);

    expect(0.69897000433602)->toBeLogarithmOf(number: 5, base: 10);
    expect(1)->not->toBeLogarithmOf(number: 1);

    expect(6)->toBeSumOf([1, 2, 3]);
    expect(4)->not->toBeSumOf([2, 3]);

    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);