diff options
author | Zefram <zefram@fysh.org> | 2010-12-12 20:09:00 +0000 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-07-12 21:46:51 -0700 |
commit | c12735bbf21c427d9828557cda9e0c2ea60962c0 (patch) | |
tree | d433838bf5695b6d3b98bcb4f07885957106da28 | |
parent | cc76b5cc1552a60539ae1e99cc0b9817087d4bc4 (diff) | |
download | perl-c12735bbf21c427d9828557cda9e0c2ea60962c0.tar.gz |
API test for find_rundefsv()
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | ext/XS-APItest/APItest.xs | 14 | ||||
-rw-r--r-- | ext/XS-APItest/t/underscore_length.t | 20 |
3 files changed, 35 insertions, 0 deletions
@@ -3763,6 +3763,7 @@ ext/XS-APItest/t/svsetsv.t Test behaviour of sv_setsv with/without PERL_CORE ext/XS-APItest/t/swaplabel.t test recursive descent label parsing ext/XS-APItest/t/swaptwostmts.t test recursive descent statement parsing ext/XS-APItest/t/temp_lv_sub.t XS::APItest: tests for lvalue subs returning temps +ext/XS-APItest/t/underscore_length.t Test find_rundefsv() ext/XS-APItest/t/utf16_to_utf8.t Test behaviour of utf16_to_utf8{,reversed} ext/XS-APItest/t/utf8.t Tests for code in utf8.c ext/XS-APItest/t/xs_special_subs_require.t for require too diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs index 0b3a6cba3d..d3d7274fca 100644 --- a/ext/XS-APItest/APItest.xs +++ b/ext/XS-APItest/APItest.xs @@ -2861,6 +2861,20 @@ CODE: OUTPUT: RETVAL +STRLEN +underscore_length() +PROTOTYPE: +PREINIT: + SV *u; + U8 *pv; + STRLEN bytelen; +CODE: + u = find_rundefsv(); + pv = (U8*)SvPV(u, bytelen); + RETVAL = SvUTF8(u) ? utf8_length(pv, pv+bytelen) : bytelen; +OUTPUT: + RETVAL + MODULE = XS::APItest PACKAGE = XS::APItest::Magic PROTOTYPES: DISABLE diff --git a/ext/XS-APItest/t/underscore_length.t b/ext/XS-APItest/t/underscore_length.t new file mode 100644 index 0000000000..7ca6906322 --- /dev/null +++ b/ext/XS-APItest/t/underscore_length.t @@ -0,0 +1,20 @@ +use warnings; +use strict; + +use Test::More tests => 4; + +use XS::APItest qw(underscore_length); + +$_ = "foo"; +is underscore_length(), 3; + +$_ = "snowman \x{2603}"; +is underscore_length(), 9; + +my $_ = "xyzzy"; +is underscore_length(), 5; + +$_ = "pile of poo \x{1f4a9}"; +is underscore_length(), 13; + +1; |