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