summaryrefslogtreecommitdiff
path: root/ext/Devel-PPPort/t/SvPV.t
blob: 63c7d72c43d70b5688f74735902c96cd705f108c (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
################################################################################
#
#            !!!!!   Do NOT edit this file directly!   !!!!!
#
#            Edit mktests.PL and/or parts/inc/SvPV instead.
#
#  This file was automatically generated from the definition files in the
#  parts/inc/ subdirectory by mktests.PL. To learn more about how all this
#  works, please read the F<HACKERS> file that came with this distribution.
#
################################################################################

BEGIN {
  if ($ENV{'PERL_CORE'}) {
    chdir 't' if -d 't';
    @INC = ('../lib', '../ext/Devel-PPPort/t') if -d '../lib' && -d '../ext';
    require Config; import Config;
    use vars '%Config';
    if (" $Config{'extensions'} " !~ m[ Devel/PPPort ]) {
      print "1..0 # Skip -- Perl configured without Devel::PPPort module\n";
      exit 0;
    }
  }
  else {
    unshift @INC, 't';
  }

  sub load {
    eval "use Test";
    require 'testutil.pl' if $@;
  }

  if (47) {
    load();
    plan(tests => 47);
  }
}

use Devel::PPPort;
use strict;
$^W = 1;

package Devel::PPPort;
use vars '@ISA';
require DynaLoader;
@ISA = qw(DynaLoader);
bootstrap Devel::PPPort;

package main;

my $mhx = "mhx";

ok(&Devel::PPPort::SvPVbyte($mhx), 3);

my $i = 42;

ok(&Devel::PPPort::SvPV_nolen($mhx), $i++);
ok(&Devel::PPPort::SvPV_const($mhx), $i++);
ok(&Devel::PPPort::SvPV_mutable($mhx), $i++);
ok(&Devel::PPPort::SvPV_flags($mhx), $i++);
ok(&Devel::PPPort::SvPV_flags_const($mhx), $i++);

ok(&Devel::PPPort::SvPV_flags_const_nolen($mhx), $i++);
ok(&Devel::PPPort::SvPV_flags_mutable($mhx), $i++);
ok(&Devel::PPPort::SvPV_force($mhx), $i++);
ok(&Devel::PPPort::SvPV_force_nolen($mhx), $i++);
ok(&Devel::PPPort::SvPV_force_mutable($mhx), $i++);

ok(&Devel::PPPort::SvPV_force_nomg($mhx), $i++);
ok(&Devel::PPPort::SvPV_force_nomg_nolen($mhx), $i++);
ok(&Devel::PPPort::SvPV_force_flags($mhx), $i++);
ok(&Devel::PPPort::SvPV_force_flags_nolen($mhx), $i++);
ok(&Devel::PPPort::SvPV_force_flags_mutable($mhx), $i++);

ok(&Devel::PPPort::SvPV_nolen_const($mhx), $i++);
ok(&Devel::PPPort::SvPV_nomg($mhx), $i++);
ok(&Devel::PPPort::SvPV_nomg_const($mhx), $i++);
ok(&Devel::PPPort::SvPV_nomg_const_nolen($mhx), $i++);

$mhx = 42; ok(&Devel::PPPort::SvPV_nolen($mhx), 0);
$mhx = 42; ok(&Devel::PPPort::SvPV_const($mhx), 2);
$mhx = 42; ok(&Devel::PPPort::SvPV_mutable($mhx), 2);
$mhx = 42; ok(&Devel::PPPort::SvPV_flags($mhx), 2);
$mhx = 42; ok(&Devel::PPPort::SvPV_flags_const($mhx), 2);

$mhx = 42; ok(&Devel::PPPort::SvPV_flags_const_nolen($mhx), 0);
$mhx = 42; ok(&Devel::PPPort::SvPV_flags_mutable($mhx), 2);
$mhx = 42; ok(&Devel::PPPort::SvPV_force($mhx), 2);
$mhx = 42; ok(&Devel::PPPort::SvPV_force_nolen($mhx), 0);
$mhx = 42; ok(&Devel::PPPort::SvPV_force_mutable($mhx), 2);

$mhx = 42; ok(&Devel::PPPort::SvPV_force_nomg($mhx), 2);
$mhx = 42; ok(&Devel::PPPort::SvPV_force_nomg_nolen($mhx), 0);
$mhx = 42; ok(&Devel::PPPort::SvPV_force_flags($mhx), 2);
$mhx = 42; ok(&Devel::PPPort::SvPV_force_flags_nolen($mhx), 0);
$mhx = 42; ok(&Devel::PPPort::SvPV_force_flags_mutable($mhx), 2);

$mhx = 42; ok(&Devel::PPPort::SvPV_nolen_const($mhx), 0);
$mhx = 42; ok(&Devel::PPPort::SvPV_nomg($mhx), 2);
$mhx = 42; ok(&Devel::PPPort::SvPV_nomg_const($mhx), 2);
$mhx = 42; ok(&Devel::PPPort::SvPV_nomg_const_nolen($mhx), 0);

my $str = "";
my($s2, $before, $after) = &Devel::PPPort::SvPV_renew($str, 81, "x"x80);
ok($str, "x"x80);
ok($s2, "x"x80);
ok($before < 81);
ok($after, 81);

$str = "x"x400;
($s2, $before, $after) = &Devel::PPPort::SvPV_renew($str, 41, "x"x40);
ok($str, "x"x40);
ok($s2, "x"x40);
ok($before > 41);
ok($after, 41);