Para el uso del módulo con Test::More utilice
el módulo Test::LectroTest::Compat .
Este módulo permite mezclar la comprobación mediante propiedades
con la familia de los módulos Test::.
Es posible llamar a las funciones is() y ok()
dentro del código de especificación de una propiedad.
Véase el uso de cmp_ok en la línea 10 del siguiente ejemplo:
lhp@nereida:~/Lperl/src/LectroTest/Titi$ cat -n t/01lectro.t
1 use Titi; # contains code we want to test
2 use Test::More tests => 2;
3 use Test::LectroTest::Compat;
4
5 # property specs can now use Test::Builder-based
6 # tests such as Test::More's cmp_ok()
7
8 my $prop_nonnegative = Property {
9 ##[ x <- Int, y <- Int ]##
10 cmp_ok(Titi::my_function( $x, $y ), '>=', 0);
11 }, name => "my_function output is non-negative" ;
12
13 # and we can now check whether properties hold
14 # as Test::Builder-style tests that integrate
15 # with other T::B tests
16
17 holds( $prop_nonnegative ); # test whether prop holds
18 cmp_ok( 0, '<', 1, "trivial 0<1 test" ); # a "normal" test
Como se ve en la línea 17 se provee también una función holds
la cual somete a pruebas la propiedad que recibe como argumento.
Casiano Rodríguez León
