diff options
author | Karl Williamson <public@khwilliamson.com> | 2012-12-02 21:34:41 -0700 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2012-12-09 10:30:01 -0700 |
commit | 981746b9bd7bd3708bfb2d1d84ddfee97bd5ee63 (patch) | |
tree | 8646e72f76cc3ce6e94d0297e6127c5906f3871e /ext/XS-APItest | |
parent | e85ea4f9037a4e5bb28f0ffaa4c34ef35c39f547 (diff) | |
download | perl-981746b9bd7bd3708bfb2d1d84ddfee97bd5ee63.tar.gz |
XS-APItest: Add tests for handy.h
This adds missing tests for the locale versions of the macros in
handy.h, plus some to make sure that WORDCHAR and ALNUM are synonyms
Diffstat (limited to 'ext/XS-APItest')
-rw-r--r-- | ext/XS-APItest/APItest.pm | 2 | ||||
-rw-r--r-- | ext/XS-APItest/APItest.xs | 405 | ||||
-rw-r--r-- | ext/XS-APItest/t/handy.t | 60 |
3 files changed, 455 insertions, 12 deletions
diff --git a/ext/XS-APItest/APItest.pm b/ext/XS-APItest/APItest.pm index 24d5ceae36..9471ce9a38 100644 --- a/ext/XS-APItest/APItest.pm +++ b/ext/XS-APItest/APItest.pm @@ -5,7 +5,7 @@ use strict; use warnings; use Carp; -our $VERSION = '0.47'; +our $VERSION = '0.48'; require XSLoader; diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs index 4889acdf55..4edef935ac 100644 --- a/ext/XS-APItest/APItest.xs +++ b/ext/XS-APItest/APItest.xs @@ -3564,6 +3564,13 @@ test_isBLANK_uni(UV ord) RETVAL bool +test_isBLANK_LC_uvchr(UV ord) + CODE: + RETVAL = isBLANK_LC_uvchr(ord); + OUTPUT: + RETVAL + +bool test_isBLANK_A(UV ord) CODE: RETVAL = isBLANK_A(ord); @@ -3578,6 +3585,13 @@ test_isBLANK_L1(UV ord) RETVAL bool +test_isBLANK_LC(UV ord) + CODE: + RETVAL = isBLANK_LC(ord); + OUTPUT: + RETVAL + +bool test_isBLANK_utf8(unsigned char * p) CODE: RETVAL = isBLANK_utf8(p); @@ -3585,6 +3599,13 @@ test_isBLANK_utf8(unsigned char * p) RETVAL bool +test_isBLANK_LC_utf8(unsigned char * p) + CODE: + RETVAL = isBLANK_LC_utf8(p); + OUTPUT: + RETVAL + +bool test_isVERTWS_uni(UV ord) CODE: RETVAL = isVERTWS_uni(ord); @@ -3606,6 +3627,13 @@ test_isUPPER_uni(UV ord) RETVAL bool +test_isUPPER_LC_uvchr(UV ord) + CODE: + RETVAL = isUPPER_LC_uvchr(ord); + OUTPUT: + RETVAL + +bool test_isUPPER_A(UV ord) CODE: RETVAL = isUPPER_A(ord); @@ -3620,6 +3648,13 @@ test_isUPPER_L1(UV ord) RETVAL bool +test_isUPPER_LC(UV ord) + CODE: + RETVAL = isUPPER_LC(ord); + OUTPUT: + RETVAL + +bool test_isUPPER_utf8(unsigned char * p) CODE: RETVAL = isUPPER_utf8( p); @@ -3627,6 +3662,13 @@ test_isUPPER_utf8(unsigned char * p) RETVAL bool +test_isUPPER_LC_utf8(unsigned char * p) + CODE: + RETVAL = isUPPER_LC_utf8( p); + OUTPUT: + RETVAL + +bool test_isLOWER_uni(UV ord) CODE: RETVAL = isLOWER_uni(ord); @@ -3634,6 +3676,13 @@ test_isLOWER_uni(UV ord) RETVAL bool +test_isLOWER_LC_uvchr(UV ord) + CODE: + RETVAL = isLOWER_LC_uvchr(ord); + OUTPUT: + RETVAL + +bool test_isLOWER_A(UV ord) CODE: RETVAL = isLOWER_A(ord); @@ -3648,6 +3697,13 @@ test_isLOWER_L1(UV ord) RETVAL bool +test_isLOWER_LC(UV ord) + CODE: + RETVAL = isLOWER_LC(ord); + OUTPUT: + RETVAL + +bool test_isLOWER_utf8(unsigned char * p) CODE: RETVAL = isLOWER_utf8( p); @@ -3655,6 +3711,13 @@ test_isLOWER_utf8(unsigned char * p) RETVAL bool +test_isLOWER_LC_utf8(unsigned char * p) + CODE: + RETVAL = isLOWER_LC_utf8( p); + OUTPUT: + RETVAL + +bool test_isALPHA_uni(UV ord) CODE: RETVAL = isALPHA_uni(ord); @@ -3662,6 +3725,13 @@ test_isALPHA_uni(UV ord) RETVAL bool +test_isALPHA_LC_uvchr(UV ord) + CODE: + RETVAL = isALPHA_LC_uvchr(ord); + OUTPUT: + RETVAL + +bool test_isALPHA_A(UV ord) CODE: RETVAL = isALPHA_A(ord); @@ -3676,6 +3746,13 @@ test_isALPHA_L1(UV ord) RETVAL bool +test_isALPHA_LC(UV ord) + CODE: + RETVAL = isALPHA_LC(ord); + OUTPUT: + RETVAL + +bool test_isALPHA_utf8(unsigned char * p) CODE: RETVAL = isALPHA_utf8( p); @@ -3683,27 +3760,132 @@ test_isALPHA_utf8(unsigned char * p) RETVAL bool -test_isALNUM_uni(UV ord) +test_isALPHA_LC_utf8(unsigned char * p) CODE: - RETVAL = isALNUM_uni(ord); + RETVAL = isALPHA_LC_utf8( p); + OUTPUT: + RETVAL + +bool +test_isWORDCHAR_uni(UV ord) + CODE: + RETVAL = isWORDCHAR_uni(ord); + OUTPUT: + RETVAL + +bool +test_isWORDCHAR_LC_uvchr(UV ord) + CODE: + RETVAL = isWORDCHAR_LC_uvchr(ord); OUTPUT: RETVAL bool -test_isALNUM_A(UV ord) +test_isWORDCHAR_A(UV ord) CODE: RETVAL = isWORDCHAR_A(ord); OUTPUT: RETVAL bool -test_isALNUM_L1(UV ord) +test_isWORDCHAR_L1(UV ord) CODE: RETVAL = isWORDCHAR_L1(ord); OUTPUT: RETVAL bool +test_isWORDCHAR_LC(UV ord) + CODE: + RETVAL = isWORDCHAR_LC(ord); + OUTPUT: + RETVAL + +bool +test_isWORDCHAR_utf8(unsigned char * p) + CODE: + RETVAL = isWORDCHAR_utf8( p); + OUTPUT: + RETVAL + +bool +test_isWORDCHAR_LC_utf8(unsigned char * p) + CODE: + RETVAL = isWORDCHAR_LC_utf8( p); + OUTPUT: + RETVAL + +bool +test_isALNUMC_uni(UV ord) + CODE: + RETVAL = isALNUMC_uni(ord); + OUTPUT: + RETVAL + +bool +test_isALNUMC_LC_uvchr(UV ord) + CODE: + RETVAL = isALNUMC_LC_uvchr(ord); + OUTPUT: + RETVAL + +bool +test_isALNUMC_A(UV ord) + CODE: + RETVAL = isALNUMC_A(ord); + OUTPUT: + RETVAL + +bool +test_isALNUMC_L1(UV ord) + CODE: + RETVAL = isALNUMC_L1(ord); + OUTPUT: + RETVAL + +bool +test_isALNUMC_LC(UV ord) + CODE: + RETVAL = isALNUMC_LC(ord); + OUTPUT: + RETVAL + +bool +test_isALNUMC_utf8(unsigned char * p) + CODE: + RETVAL = isALNUMC_utf8( p); + OUTPUT: + RETVAL + +bool +test_isALNUMC_LC_utf8(unsigned char * p) + CODE: + RETVAL = isALNUMC_LC_utf8( p); + OUTPUT: + RETVAL + +bool +test_isALNUM_uni(UV ord) + CODE: + RETVAL = isALNUM_uni(ord); + OUTPUT: + RETVAL + +bool +test_isALNUM_LC_uvchr(UV ord) + CODE: + RETVAL = isALNUM_LC_uvchr(ord); + OUTPUT: + RETVAL + +bool +test_isALNUM_LC(UV ord) + CODE: + RETVAL = isALNUM_LC(ord); + OUTPUT: + RETVAL + +bool test_isALNUM_utf8(unsigned char * p) CODE: RETVAL = isALNUM_utf8( p); @@ -3711,6 +3893,13 @@ test_isALNUM_utf8(unsigned char * p) RETVAL bool +test_isALNUM_LC_utf8(unsigned char * p) + CODE: + RETVAL = isALNUM_LC_utf8( p); + OUTPUT: + RETVAL + +bool test_isDIGIT_uni(UV ord) CODE: RETVAL = isDIGIT_uni(ord); @@ -3718,6 +3907,13 @@ test_isDIGIT_uni(UV ord) RETVAL bool +test_isDIGIT_LC_uvchr(UV ord) + CODE: + RETVAL = isDIGIT_LC_uvchr(ord); + OUTPUT: + RETVAL + +bool test_isDIGIT_utf8(unsigned char * p) CODE: RETVAL = isDIGIT_utf8( p); @@ -3725,6 +3921,13 @@ test_isDIGIT_utf8(unsigned char * p) RETVAL bool +test_isDIGIT_LC_utf8(unsigned char * p) + CODE: + RETVAL = isDIGIT_LC_utf8( p); + OUTPUT: + RETVAL + +bool test_isDIGIT_A(UV ord) CODE: RETVAL = isDIGIT_A(ord); @@ -3739,6 +3942,13 @@ test_isDIGIT_L1(UV ord) RETVAL bool +test_isDIGIT_LC(UV ord) + CODE: + RETVAL = isDIGIT_LC(ord); + OUTPUT: + RETVAL + +bool test_isIDFIRST_uni(UV ord) CODE: RETVAL = isIDFIRST_uni(ord); @@ -3746,6 +3956,13 @@ test_isIDFIRST_uni(UV ord) RETVAL bool +test_isIDFIRST_LC_uvchr(UV ord) + CODE: + RETVAL = isIDFIRST_LC_uvchr(ord); + OUTPUT: + RETVAL + +bool test_isIDFIRST_A(UV ord) CODE: RETVAL = isIDFIRST_A(ord); @@ -3760,6 +3977,13 @@ test_isIDFIRST_L1(UV ord) RETVAL bool +test_isIDFIRST_LC(UV ord) + CODE: + RETVAL = isIDFIRST_LC(ord); + OUTPUT: + RETVAL + +bool test_isIDFIRST_utf8(unsigned char * p) CODE: RETVAL = isIDFIRST_utf8( p); @@ -3767,6 +3991,13 @@ test_isIDFIRST_utf8(unsigned char * p) RETVAL bool +test_isIDFIRST_LC_utf8(unsigned char * p) + CODE: + RETVAL = isIDFIRST_LC_utf8( p); + OUTPUT: + RETVAL + +bool test_isSPACE_uni(UV ord) CODE: RETVAL = isSPACE_uni(ord); @@ -3774,6 +4005,13 @@ test_isSPACE_uni(UV ord) RETVAL bool +test_isSPACE_LC_uvchr(UV ord) + CODE: + RETVAL = isSPACE_LC_uvchr(ord); + OUTPUT: + RETVAL + +bool test_isSPACE_A(UV ord) CODE: RETVAL = isSPACE_A(ord); @@ -3788,6 +4026,13 @@ test_isSPACE_L1(UV ord) RETVAL bool +test_isSPACE_LC(UV ord) + CODE: + RETVAL = isSPACE_LC(ord); + OUTPUT: + RETVAL + +bool test_isSPACE_utf8(unsigned char * p) CODE: RETVAL = isSPACE_utf8( p); @@ -3795,6 +4040,13 @@ test_isSPACE_utf8(unsigned char * p) RETVAL bool +test_isSPACE_LC_utf8(unsigned char * p) + CODE: + RETVAL = isSPACE_LC_utf8( p); + OUTPUT: + RETVAL + +bool test_isASCII_uni(UV ord) CODE: RETVAL = isASCII_uni(ord); @@ -3802,6 +4054,13 @@ test_isASCII_uni(UV ord) RETVAL bool +test_isASCII_LC_uvchr(UV ord) + CODE: + RETVAL = isASCII_LC_uvchr(ord); + OUTPUT: + RETVAL + +bool test_isASCII_A(UV ord) CODE: RETVAL = isASCII_A(ord); @@ -3816,6 +4075,13 @@ test_isASCII_L1(UV ord) RETVAL bool +test_isASCII_LC(UV ord) + CODE: + RETVAL = isASCII_LC(ord); + OUTPUT: + RETVAL + +bool test_isASCII_utf8(unsigned char * p) CODE: RETVAL = isASCII_utf8( p); @@ -3823,6 +4089,13 @@ test_isASCII_utf8(unsigned char * p) RETVAL bool +test_isASCII_LC_utf8(unsigned char * p) + CODE: + RETVAL = isASCII_LC_utf8( p); + OUTPUT: + RETVAL + +bool test_isCNTRL_uni(UV ord) CODE: RETVAL = isCNTRL_uni(ord); @@ -3830,6 +4103,13 @@ test_isCNTRL_uni(UV ord) RETVAL bool +test_isCNTRL_LC_uvchr(UV ord) + CODE: + RETVAL = isCNTRL_LC_uvchr(ord); + OUTPUT: + RETVAL + +bool test_isCNTRL_A(UV ord) CODE: RETVAL = isCNTRL_A(ord); @@ -3844,6 +4124,13 @@ test_isCNTRL_L1(UV ord) RETVAL bool +test_isCNTRL_LC(UV ord) + CODE: + RETVAL = isCNTRL_LC(ord); + OUTPUT: + RETVAL + +bool test_isCNTRL_utf8(unsigned char * p) CODE: RETVAL = isCNTRL_utf8( p); @@ -3851,6 +4138,13 @@ test_isCNTRL_utf8(unsigned char * p) RETVAL bool +test_isCNTRL_LC_utf8(unsigned char * p) + CODE: + RETVAL = isCNTRL_LC_utf8( p); + OUTPUT: + RETVAL + +bool test_isPRINT_uni(UV ord) CODE: RETVAL = isPRINT_uni(ord); @@ -3858,6 +4152,13 @@ test_isPRINT_uni(UV ord) RETVAL bool +test_isPRINT_LC_uvchr(UV ord) + CODE: + RETVAL = isPRINT_LC_uvchr(ord); + OUTPUT: + RETVAL + +bool test_isPRINT_A(UV ord) CODE: RETVAL = isPRINT_A(ord); @@ -3872,6 +4173,13 @@ test_isPRINT_L1(UV ord) RETVAL bool +test_isPRINT_LC(UV ord) + CODE: + RETVAL = isPRINT_LC(ord); + OUTPUT: + RETVAL + +bool test_isPRINT_utf8(unsigned char * p) CODE: RETVAL = isPRINT_utf8( p); @@ -3879,6 +4187,13 @@ test_isPRINT_utf8(unsigned char * p) RETVAL bool +test_isPRINT_LC_utf8(unsigned char * p) + CODE: + RETVAL = isPRINT_LC_utf8( p); + OUTPUT: + RETVAL + +bool test_isGRAPH_uni(UV ord) CODE: RETVAL = isGRAPH_uni(ord); @@ -3886,6 +4201,13 @@ test_isGRAPH_uni(UV ord) RETVAL bool +test_isGRAPH_LC_uvchr(UV ord) + CODE: + RETVAL = isGRAPH_LC_uvchr(ord); + OUTPUT: + RETVAL + +bool test_isGRAPH_A(UV ord) CODE: RETVAL = isGRAPH_A(ord); @@ -3900,23 +4222,23 @@ test_isGRAPH_L1(UV ord) RETVAL bool -test_isGRAPH_utf8(unsigned char * p) +test_isGRAPH_LC(UV ord) CODE: - RETVAL = isGRAPH_utf8( p); + RETVAL = isGRAPH_LC(ord); OUTPUT: RETVAL bool -test_isALNUMC_A(UV ord) +test_isGRAPH_utf8(unsigned char * p) CODE: - RETVAL = isALNUMC_A(ord); + RETVAL = isGRAPH_utf8( p); OUTPUT: RETVAL bool -test_isALNUMC_L1(UV ord) +test_isGRAPH_LC_utf8(unsigned char * p) CODE: - RETVAL = isALNUMC_L1(ord); + RETVAL = isGRAPH_LC_utf8( p); OUTPUT: RETVAL @@ -3928,6 +4250,13 @@ test_isPUNCT_uni(UV ord) RETVAL bool +test_isPUNCT_LC_uvchr(UV ord) + CODE: + RETVAL = isPUNCT_LC_uvchr(ord); + OUTPUT: + RETVAL + +bool test_isPUNCT_A(UV ord) CODE: RETVAL = isPUNCT_A(ord); @@ -3942,6 +4271,13 @@ test_isPUNCT_L1(UV ord) RETVAL bool +test_isPUNCT_LC(UV ord) + CODE: + RETVAL = isPUNCT_LC(ord); + OUTPUT: + RETVAL + +bool test_isPUNCT_utf8(unsigned char * p) CODE: RETVAL = isPUNCT_utf8( p); @@ -3949,6 +4285,13 @@ test_isPUNCT_utf8(unsigned char * p) RETVAL bool +test_isPUNCT_LC_utf8(unsigned char * p) + CODE: + RETVAL = isPUNCT_LC_utf8( p); + OUTPUT: + RETVAL + +bool test_isXDIGIT_uni(UV ord) CODE: RETVAL = isXDIGIT_uni(ord); @@ -3956,6 +4299,13 @@ test_isXDIGIT_uni(UV ord) RETVAL bool +test_isXDIGIT_LC_uvchr(UV ord) + CODE: + RETVAL = isXDIGIT_LC_uvchr(ord); + OUTPUT: + RETVAL + +bool test_isXDIGIT_A(UV ord) CODE: RETVAL = isXDIGIT_A(ord); @@ -3970,6 +4320,13 @@ test_isXDIGIT_L1(UV ord) RETVAL bool +test_isXDIGIT_LC(UV ord) + CODE: + RETVAL = isXDIGIT_LC(ord); + OUTPUT: + RETVAL + +bool test_isXDIGIT_utf8(unsigned char * p) CODE: RETVAL = isXDIGIT_utf8( p); @@ -3977,6 +4334,13 @@ test_isXDIGIT_utf8(unsigned char * p) RETVAL bool +test_isXDIGIT_LC_utf8(unsigned char * p) + CODE: + RETVAL = isXDIGIT_LC_utf8( p); + OUTPUT: + RETVAL + +bool test_isPSXSPC_uni(UV ord) CODE: RETVAL = isPSXSPC_uni(ord); @@ -3984,6 +4348,13 @@ test_isPSXSPC_uni(UV ord) RETVAL bool +test_isPSXSPC_LC_uvchr(UV ord) + CODE: + RETVAL = isPSXSPC_LC_uvchr(ord); + OUTPUT: + RETVAL + +bool test_isPSXSPC_A(UV ord) CODE: RETVAL = isPSXSPC_A(ord); @@ -3998,6 +4369,13 @@ test_isPSXSPC_L1(UV ord) RETVAL bool +test_isPSXSPC_LC(UV ord) + CODE: + RETVAL = isPSXSPC_LC(ord); + OUTPUT: + RETVAL + +bool test_isPSXSPC_utf8(unsigned char * p) CODE: RETVAL = isPSXSPC_utf8( p); @@ -4005,6 +4383,13 @@ test_isPSXSPC_utf8(unsigned char * p) RETVAL bool +test_isPSXSPC_LC_utf8(unsigned char * p) + CODE: + RETVAL = isPSXSPC_LC_utf8( p); + OUTPUT: + RETVAL + +bool test_isQUOTEMETA(UV ord) CODE: RETVAL = _isQUOTEMETA(ord); diff --git a/ext/XS-APItest/t/handy.t b/ext/XS-APItest/t/handy.t index 4c852c51d4..d674b5fdf2 100644 --- a/ext/XS-APItest/t/handy.t +++ b/ext/XS-APItest/t/handy.t @@ -11,9 +11,25 @@ sub truth($) { # Converts values so is() works return (shift) ? 1 : 0; } +require POSIX; +my $locale = POSIX::setlocale( &POSIX::LC_ALL, "C"); +if (defined $locale && $locale eq 'C') { + use locale; + + # Some locale implementations don't have the 128-255 characters all + # mean nothing. Skip the locale tests in that situation + for my $i (128 .. 255) { + if (chr($i) =~ /[[:print:]]/) { + undef $locale; + last; + } + } +} + my %properties = ( # name => Lookup-property name alnum => 'Word', + wordchar => 'Word', alnumc => 'Alnum', alpha => 'Alpha', ascii => 'ASCII', @@ -92,7 +108,12 @@ foreach my $name (sort keys %properties) { } next; } + + # vertws is always all of Unicode; ALNUM_A and ALNUM_L1 are not + # defined as they were added later, after WORDCHAR was created to be a + # clearer synonym for ALNUM if ($name ne 'vertws') { + if ($name ne 'alnum') { $ret = truth eval "test_is${function}_A($i)"; if ($@) { fail($@); @@ -109,8 +130,20 @@ foreach my $name (sort keys %properties) { my $truth = truth($matches && $i < 256); is ($ret, $truth, "is${function}_L1( $display_name ) == $truth"); } + } + + next unless defined $locale; + use locale; + + $ret = truth eval "test_is${function}_LC($i)"; + if ($@) { + fail($@); + } + else { + my $truth = truth($matches && $i < 128); + is ($ret, $truth, "is${function}_LC( $display_name ) == $truth"); + } } - next if $name eq 'alnumc'; $ret = truth eval "test_is${function}_uni($i)"; if ($@) { @@ -120,6 +153,19 @@ foreach my $name (sort keys %properties) { is ($ret, $matches, "is${function}_uni( $display_name ) == $matches"); } + if (defined $locale && $name ne 'vertws') { + use locale; + + $ret = truth eval "test_is${function}_LC_uvchr('$i')"; + if ($@) { + fail($@); + } + else { + my $truth = truth($matches && ($i < 128 || $i > 255)); + is ($ret, $truth, "is${function}_LC_uvchr( $display_name ) == $truth"); + } + } + my $char = chr($i); utf8::upgrade($char); $char = quotemeta $char if $char eq '\\' || $char eq "'"; @@ -130,6 +176,18 @@ foreach my $name (sort keys %properties) { else { is ($ret, $matches, "is${function}_utf8( $display_name ) == $matches"); } + + next if $name eq 'vertws' || ! defined $locale; + use locale; + + $ret = truth eval "test_is${function}_LC_utf8('$char')"; + if ($@) { + fail($@); + } + else { + my $truth = truth($matches && ($i < 128 || $i > 255)); + is ($ret, $truth, "is${function}_LC_utf8( $display_name ) == $truth"); + } } } |