exercism / php-test-runner

GNU Affero General Public License v3.0
0 stars 6 forks source link

Top-level status is `pass` when tests `fail` #14

Closed iHiD closed 2 years ago

iHiD commented 2 years ago

Top-level status is pass when tests fail


This code:

<?php

/*
 * By adding type hints and enabling strict type checking, code can become
 * easier to read, self-documenting and reduce the number of potential bugs.
 * By default, type declarations are non-strict, which means they will attempt
 * to change the original type to match the type specified by the
 * type-declaration.
 *
 * In other words, if you pass a string to a function requiring a float,
 * it will attempt to convert the string value to a float.
 *
 * To enable strict mode, a single declare directive must be placed at the top
 * of the file.
 * This means that the strictness of typing is configured on a per-file basis.
 * This directive not only affects the type declarations of parameters, but also
 * a function's return type.
 *
 * For more info review the Concept on strict type checking in the PHP track
 * <link>.
 *
 * To disable strict typing, comment out the directive below.
 */

declare(strict_types=1);

function distance(string $strandA, string $strandB): int
{
    return count(array_diff(str_split($strandA), str_split($strandB)));
}

Gives this output:

{"version"=>2, "tests"=>[{"name"=>"testNoDifferenceBetweenIdenticalStrands", "status"=>"fail", "message"=>"HammingTest::testLargeHammingDistance\nFailed asserting that 0 matches expected 4.\n\n/mnt/exercism-iteration/HammingTest.php:61HammingTest::testHammingDistanceInVeryLongStrand\nFailed asserting that 0 matches expected 9.\n\n/mnt/exercism-iteration/HammingTest.php:66HammingTest::testExceptionThrownWhenStrandsAreDifferentLength\nFailed asserting that exception of type \"InvalidArgumentException\" is thrown.", "output"=>""}], "status"=>"pass"}
neenjaw commented 2 years ago

Sounds good, will look at this asap, thanks for providing the code sample causing the bug.

iHiD commented 2 years ago

Thanks! 🙂