Skip re tests if re not built.
[p5sagit/p5-mst-13.2.git] / ext / Devel / PPPort / t / test.t
1 BEGIN {
2     chdir 't' if -d 't';
3     @INC = '../lib' if -d '../lib';
4 }
5
6 use Devel::PPPort;
7 use strict;
8
9 print "1..17\n";
10
11 my $total = 0;
12 my $good = 0;
13
14 my $test = 0;   
15 sub ok {
16     my ($name, $test_sub) = @_;
17     my $line = (caller)[2];
18     my $value;
19
20     eval { $value = &{ $test_sub }() } ;
21
22     ++ $test ;
23
24     if ($@) {
25         printf "not ok $test # Testing '$name', line $line $@\n";
26     }
27     elsif ($value != 1){
28         printf "not ok $test # Testing '$name', line $line, value != 1 ($value)\n";
29     }
30     else {
31         print "ok $test\n";
32     }
33
34
35
36 ok "Static newCONSTSUB()", 
37    sub { Devel::PPPort::test1(); Devel::PPPort::test_value_1() == 1} ;
38
39 ok "Global newCONSTSUB()", 
40    sub { Devel::PPPort::test2(); Devel::PPPort::test_value_2() == 2} ;
41
42 ok "Extern newCONSTSUB()", 
43    sub { Devel::PPPort::test3(); Devel::PPPort::test_value_3() == 3} ;
44
45 ok "newRV_inc()", sub { Devel::PPPort::test4()} ;
46
47 ok "newRV_noinc()", sub { Devel::PPPort::test5()} ;
48
49 ok "PL_sv_undef", sub { not defined Devel::PPPort::test6()} ;
50
51 ok "PL_sv_yes", sub { Devel::PPPort::test7()} ;
52
53 ok "PL_sv_no", sub { !Devel::PPPort::test8()} ;
54
55 ok "PL_na", sub { Devel::PPPort::test9("abcd") == 4} ;
56
57 ok "boolSV 1", sub { Devel::PPPort::test10(1) } ;
58
59 ok "boolSV 0", sub { ! Devel::PPPort::test10(0) } ;
60
61 ok "newSVpvn", sub { Devel::PPPort::test11("abcde", 3) eq "abc" } ;
62
63 ok "DEFSV", sub { $_ = "Fred"; Devel::PPPort::test12() eq "Fred" } ;
64
65 ok "ERRSV", sub { eval { 1; }; ! Devel::PPPort::test13() };
66
67 ok "ERRSV", sub { eval { fred() }; Devel::PPPort::test13() };
68
69 ok "CXT 1", sub { Devel::PPPort::test14()} ;
70
71 ok "CXT 2", sub { Devel::PPPort::test15()} ;
72
73 __END__
74 # TODO
75
76 PERL_VERSION
77 PERL_BCDVERSION
78
79 PL_stdingv
80 PL_hints
81 PL_curcop
82 PL_curstash
83 PL_copline
84 PL_Sv
85 PL_compiling
86 PL_dirty
87
88 PTR2IV
89 INT2PTR
90
91 dTHR
92 gv_stashpvn
93 NOOP
94 SAVE_DEFSV
95 PERL_UNUSED_DECL
96 dNOOP
97
98 call_argv
99 call_method
100 call_pv
101 call_sv
102
103 get_cv
104 get_av
105 get_hv
106 get_sv
107
108 grok_hex
109 grok_oct
110 grok_bin
111
112 grok_number
113 grok_numeric_radix