| 1 |
|
| 2 |
# Tests for the get_*v functions. |
| 3 |
|
| 4 |
use Test::More tests => 5; |
| 5 |
use XS::APItest; |
| 6 |
|
| 7 |
# XXX So far we only test get_cv. |
| 8 |
|
| 9 |
is get_cv("utf8::encode"), \&utf8::encode, 'get_cv(utf8::encode)'; |
| 10 |
|
| 11 |
sub foo { " ooof" } # should be stored in the stash as a subref |
| 12 |
die "Test has been sabotaged: sub foo{} should not create a full glob" |
| 13 |
unless ref $::{foo} eq 'CODE'; |
| 14 |
|
| 15 |
my $subref = get_cv("foo"); |
| 16 |
is ref $subref, "CODE", 'got a coderef from get_cv("globless sub")'; |
| 17 |
is &$subref, " ooof", 'got the right sub'; |
| 18 |
|
| 19 |
sub bar { "burr" } |
| 20 |
$subref = get_cv_flags("bar",GV_NOADD_NOINIT); |
| 21 |
is ref $subref, "CODE", 'got a coderef from get_cv with GV_NOADD_NOINIT'; |
| 22 |
is &$subref, "burr", 'got the right sub'; |