File: props2.t

package info (click to toggle)
libtest-lectrotest-perl 0.5001-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 412 kB
  • sloc: perl: 1,808; sh: 13; makefile: 6
file content (132 lines) | stat: -rwxr-xr-x 3,039 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/perl

use warnings;
use strict;

use Test::LectroTest::Generator ':all';
use Test::LectroTest::Property;
use Test::More tests => 12;

=head1 NAME

t/props2.t - Additional property checks

=head1 SYNOPSIS

    perl -Ilib t/props2.t

=head1 DESCRIPTION

These checks are designed to exercise Properties independent
of a test harness.

First, we see whether LectroTest::Property prevents you from
using the reserved identifier "tcon" in a generator-binding
declaration.

=cut

eval { 
    Property { [ tcon => 1 ] } sub {
        1;
    }
};
like($@, qr/cannot use reserved name 'tcon' in a generator binding/,
   "Property->new disallows use of 'tcon' in bindings");

eval { 
    Property { ##[ tcon <- 1 ]##
        1;
    }
};
like($@, qr/cannot use reserved name 'tcon' in a generator binding/,
   "magic Property syntax disallows use of 'tcon' in bindings");


=pod

Second, we check to see if C<new> catches and complains
about bad arguments in its pre-flight checks:

=cut

eval {
    Test::LectroTest::Property->new();
};
like( $@, qr/test subroutine must be provided/,
      "pre-flight: new w/ no args" );


eval {
    Test::LectroTest::Property->new('inputs');
};
like( $@, qr/invalid list of named parameters/,
      "pre-flight: unbalanced arguments list" );


eval {
    Test::LectroTest::Property->new(inputs=>[]);
};
like( $@, qr/test subroutine must be provided/,
      "pre-flight: new w/o test sub" );


eval { Property { ##[ x <- Unit(0)], [ ]##
                1 } 
};

like( $@, qr/\(\) does not match \(x\)/,
      "pre-flight: sets of bindings must have same vars (x) vs ()" );

eval { Property { ##[ x <- Unit(0)], [ y <- Unit(0) ]##
                1 } 
};

like( $@, qr/\(y\) does not match \(x\)/,
      "pre-flight: sets of bindings must have same vars (x) vs (y)" );

eval { Property { ##[ x <- Unit(0)], [ x <- Unit(0) ], [ ]##
                1 } 
};

like( $@, qr/\(\) does not match \(x\)/,
      "pre-flight: sets of bindings must have same vars (x) vs (x) vs ()" );


eval { Property { ##[ x <- Unit(0), 1 ]##
                1 } 
};

like( $@, qr/did not get a set of valid input-generator bindings/,
      "pre-flight: odd params in binding is caught" );



like( eval { Test::LectroTest::Property->new( inputs => [] ) } || $@,
      qr/test subroutine must be provided/,
      "pre-flight: no test subroutine" );

like( eval { Test::LectroTest::Property->new(inputs=>{1,1}, test=>sub{}) }
      || $@,
      qr/did not get a set of valid input-generator bindings/,
      "pre-flight: invalid set of generator bindings" );

like( eval { Test::LectroTest::Property->new(inputs=>[{1,1}], test=>sub{}) }
      || $@,
      qr/did not get a set of valid input-generator bindings/,
      "pre-flight: invalid inner set of generator bindings" );





=head1 AUTHOR

Tom Moertel (tom@moertel.com)

=head1 COPYRIGHT and LICENSE

Copyright (C) 2004 by Thomas G Moertel.  All rights reserved.

This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.