Commit | Line | Data |
adfe19db |
1 | ################################################################################ |
2 | # |
3 | # !!!!! Do NOT edit this file directly! !!!!! |
4 | # |
5 | # Edit mktests.PL and/or parts/inc/magic instead. |
6 | # |
cac25305 |
7 | # This file was automatically generated from the definition files in the |
8 | # parts/inc/ subdirectory by mktests.PL. To learn more about how all this |
9 | # works, please read the F<HACKERS> file that came with this distribution. |
10 | # |
adfe19db |
11 | ################################################################################ |
12 | |
13 | BEGIN { |
14 | if ($ENV{'PERL_CORE'}) { |
15 | chdir 't' if -d 't'; |
0ff33da8 |
16 | @INC = ('../lib', '../ext/Devel-PPPort/t') if -d '../lib' && -d '../ext'; |
adfe19db |
17 | require Config; import Config; |
18 | use vars '%Config'; |
a745474a |
19 | if (" $Config{'extensions'} " !~ m[ Devel/PPPort ]) { |
adfe19db |
20 | print "1..0 # Skip -- Perl configured without Devel::PPPort module\n"; |
21 | exit 0; |
22 | } |
23 | } |
24 | else { |
25 | unshift @INC, 't'; |
26 | } |
27 | |
c07deaaf |
28 | sub load { |
29 | eval "use Test"; |
30 | require 'testutil.pl' if $@; |
adfe19db |
31 | } |
c07deaaf |
32 | |
679ad62d |
33 | if (15) { |
c07deaaf |
34 | load(); |
679ad62d |
35 | plan(tests => 15); |
adfe19db |
36 | } |
37 | } |
38 | |
39 | use Devel::PPPort; |
40 | use strict; |
41 | $^W = 1; |
42 | |
236afa0a |
43 | package Devel::PPPort; |
44 | use vars '@ISA'; |
45 | require DynaLoader; |
46 | @ISA = qw(DynaLoader); |
47 | bootstrap Devel::PPPort; |
48 | |
49 | package main; |
50 | |
adfe19db |
51 | use Tie::Hash; |
52 | my %h; |
53 | tie %h, 'Tie::StdHash'; |
54 | $h{foo} = 'foo'; |
55 | $h{bar} = ''; |
56 | |
57 | &Devel::PPPort::sv_catpv_mg($h{foo}, 'bar'); |
58 | ok($h{foo}, 'foobar'); |
59 | |
60 | &Devel::PPPort::sv_catpvn_mg($h{bar}, 'baz'); |
61 | ok($h{bar}, 'baz'); |
62 | |
63 | &Devel::PPPort::sv_catsv_mg($h{foo}, '42'); |
64 | ok($h{foo}, 'foobar42'); |
65 | |
66 | &Devel::PPPort::sv_setiv_mg($h{bar}, 42); |
67 | ok($h{bar}, 42); |
68 | |
69 | &Devel::PPPort::sv_setnv_mg($h{PI}, 3.14159); |
70 | ok(abs($h{PI} - 3.14159) < 0.01); |
71 | |
72 | &Devel::PPPort::sv_setpv_mg($h{mhx}, 'mhx'); |
73 | ok($h{mhx}, 'mhx'); |
74 | |
75 | &Devel::PPPort::sv_setpvn_mg($h{mhx}, 'Marcus'); |
76 | ok($h{mhx}, 'Marcus'); |
77 | |
78 | &Devel::PPPort::sv_setsv_mg($h{sv}, 'SV'); |
79 | ok($h{sv}, 'SV'); |
80 | |
81 | &Devel::PPPort::sv_setuv_mg($h{sv}, 4711); |
82 | ok($h{sv}, 4711); |
83 | |
84 | &Devel::PPPort::sv_usepvn_mg($h{sv}, 'Perl'); |
85 | ok($h{sv}, 'Perl'); |
86 | |
f2ab5a41 |
87 | my $ver = eval qq[qv("v1.2.0")]; |
88 | ok($[ < 5.009 || $@ eq ''); |
89 | ok($@ || Devel::PPPort::SvVSTRING_mg($ver)); |
90 | ok(!Devel::PPPort::SvVSTRING_mg(4711)); |
91 | |
679ad62d |
92 | my $foo = 'bar'; |
93 | ok(Devel::PPPort::sv_magic_portable($foo)); |
94 | ok($foo eq 'bar'); |
95 | |