PHP code example of sophie-spec / versus

1. Go to this page and download the library: Download sophie-spec/versus 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/ */

    

sophie-spec / versus example snippets


use function Sophie\Versus\versus;

$add = function ($a, $b) {
    return $a + $b;
};

versus($add, function () {
    yield [1, 2] => 3;
    yield [-2, -3] => -5;
    yield [10, -20] => -10;
});

versus($add, function () {
    yield [1, 2] => 100;
});
/*
    Both values are not equal.

    Provided value:
        3

    Expected value:
        100
*/