1 ################################################################################
3 # !!!!! Do NOT edit this file directly! !!!!!
5 # Edit mktests.PL and/or parts/inc/magic instead.
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.
11 ################################################################################
14 if ($ENV{'PERL_CORE'}) {
16 @INC = ('../lib', '../ext/Devel-PPPort/t') if -d '../lib' && -d '../ext';
17 require Config; import Config;
19 if (" $Config{'extensions'} " !~ m[ Devel/PPPort ]) {
20 print "1..0 # Skip -- Perl configured without Devel::PPPort module\n";
30 require 'testutil.pl' if $@;
43 package Devel::PPPort;
46 @ISA = qw(DynaLoader);
47 bootstrap Devel::PPPort;
52 ok(my $obj1 = Devel::PPPort->new_with_mg());
53 ok(Devel::PPPort::as_string($obj1), 'hello');
56 my $obj = bless {}, 'Fake::Class';
57 ok(Devel::PPPort::as_string($obj), "Sorry, your princess is in another castle.");
59 # Find with other magic (not the magic we are looking for)
60 ok($obj = Devel::PPPort->new_with_other_mg());
61 ok(Devel::PPPort::as_string($obj), "Sorry, your princess is in another castle.");
63 # Okay, attempt to remove magic that isn't there
64 Devel::PPPort::remove_other_magic($obj1);
65 ok(Devel::PPPort::as_string($obj1), 'hello');
67 # Remove magic that IS there
68 Devel::PPPort::remove_null_magic($obj1);
69 ok(Devel::PPPort::as_string($obj1), "Sorry, your princess is in another castle.");
71 # Removing when no magic present
72 Devel::PPPort::remove_null_magic($obj1);
73 ok(Devel::PPPort::as_string($obj1), "Sorry, your princess is in another castle.");
77 tie %h, 'Tie::StdHash';
81 &Devel::PPPort::sv_catpv_mg($h{foo}, 'bar');
82 ok($h{foo}, 'foobar');
84 &Devel::PPPort::sv_catpvn_mg($h{bar}, 'baz');
87 &Devel::PPPort::sv_catsv_mg($h{foo}, '42');
88 ok($h{foo}, 'foobar42');
90 &Devel::PPPort::sv_setiv_mg($h{bar}, 42);
93 &Devel::PPPort::sv_setnv_mg($h{PI}, 3.14159);
94 ok(abs($h{PI} - 3.14159) < 0.01);
96 &Devel::PPPort::sv_setpv_mg($h{mhx}, 'mhx');
99 &Devel::PPPort::sv_setpvn_mg($h{mhx}, 'Marcus');
100 ok($h{mhx}, 'Marcus');
102 &Devel::PPPort::sv_setsv_mg($h{sv}, 'SV');
105 &Devel::PPPort::sv_setuv_mg($h{sv}, 4711);
108 &Devel::PPPort::sv_usepvn_mg($h{sv}, 'Perl');
111 # v1 is treated as a bareword in older perls...
112 my $ver = do { local $SIG{'__WARN__'} = sub {}; eval qq[v1.2.0] };
113 ok($] < 5.009 || $@ eq '');
114 ok($] < 5.009 || Devel::PPPort::SvVSTRING_mg($ver));
115 ok(!Devel::PPPort::SvVSTRING_mg(4711));
118 ok(Devel::PPPort::sv_magic_portable($foo));