summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/ext/Devel/PPPort/t/test.t
blob: f0f30352d757941bfb34993f1c55e81dcd385121 (plain)
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
BEGIN {
    chdir 't' if -d 't';
    @INC = '../lib' if -d '../lib';
}

use Devel::PPPort;
use strict;

print "1..17\n";

my $total = 0;
my $good = 0;

my $test = 0;   
sub ok {
    my ($name, $test_sub) = @_;
    my $line = (caller)[2];
    my $value;

    eval { $value = &{ $test_sub }() } ;

    ++ $test ;

    if ($@) {
        printf "not ok $test # Testing '$name', line $line $@\n";
    }
    elsif ($value != 1){
        printf "not ok $test # Testing '$name', line $line, value != 1 ($value)\n";
    }
    else {
        print "ok $test\n";
    }

} 

ok "Static newCONSTSUB()", 
   sub { Devel::PPPort::test1(); Devel::PPPort::test_value_1() == 1} ;

ok "Global newCONSTSUB()", 
   sub { Devel::PPPort::test2(); Devel::PPPort::test_value_2() == 2} ;

ok "Extern newCONSTSUB()", 
   sub { Devel::PPPort::test3(); Devel::PPPort::test_value_3() == 3} ;

ok "newRV_inc()", sub { Devel::PPPort::test4()} ;

ok "newRV_noinc()", sub { Devel::PPPort::test5()} ;

ok "PL_sv_undef", sub { not defined Devel::PPPort::test6()} ;

ok "PL_sv_yes", sub { Devel::PPPort::test7()} ;

ok "PL_sv_no", sub { !Devel::PPPort::test8()} ;

ok "PL_na", sub { Devel::PPPort::test9("abcd") == 4} ;

ok "boolSV 1", sub { Devel::PPPort::test10(1) } ;

ok "boolSV 0", sub { ! Devel::PPPort::test10(0) } ;

ok "newSVpvn", sub { Devel::PPPort::test11("abcde", 3) eq "abc" } ;

ok "DEFSV", sub { $_ = "Fred"; Devel::PPPort::test12() eq "Fred" } ;

ok "ERRSV", sub { eval { 1; }; ! Devel::PPPort::test13() };

ok "ERRSV", sub { eval { fred() }; Devel::PPPort::test13() };

ok "CXT 1", sub { Devel::PPPort::test14()} ;

ok "CXT 2", sub { Devel::PPPort::test15()} ;

__END__
# TODO

PERL_VERSION
PERL_BCDVERSION

PL_stdingv
PL_hints
PL_curcop
PL_curstash
PL_copline
PL_Sv
PL_compiling
PL_dirty

PTR2IV
INT2PTR

dTHR
gv_stashpvn
NOOP
SAVE_DEFSV
PERL_UNUSED_DECL
dNOOP