Created
November 5, 2011 10:00
-
-
Save israelst/1341346 to your computer and use it in GitHub Desktop.
Mini tester
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function test($expected, $obtained){ | |
if($expected != $obtained){ | |
return "Falha, $expected é diferente de $obtained"; | |
}else{ | |
return "Ok"; | |
} | |
} | |
function test_runner($test_list){ | |
foreach($test_list as $test_name => $test){ | |
echo $test_name . ": " . $test() . "\n"; | |
} | |
} | |
function soma($a, $b){ | |
return $a + $b; | |
} | |
$test_list = array( | |
'Soma deve retornar 2 ao receber 1 e 1' => function(){ | |
return test(2, soma(1, 1)); | |
}, | |
'Soma deve retornar 4 ao receber 2 e 2' => function(){ | |
return test(4, soma(2, 2)); | |
} | |
); | |
test_runner($test_list); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment