Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create sv_streq() API family, as a stringy copy of the sv_numeq() ones
- Loading branch information
Showing
8 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!perl | ||
|
||
use Test::More tests => 7; | ||
use XS::APItest; | ||
|
||
my $abc = "abc"; | ||
ok sv_streq($abc, "abc"), '$abc eq "abc"'; | ||
ok !sv_streq($abc, "def"), '$abc ne "def"'; | ||
|
||
# consider also UTF-8 vs not | ||
|
||
# GMAGIC | ||
"ABC" =~ m/(\w+)/; | ||
ok !sv_streq_flags($1, "ABC", 0), 'sv_streq_flags with no flags does not GETMAGIC'; | ||
ok sv_streq_flags($1, "ABC", SV_GMAGIC), 'sv_streq_flags with SV_GMAGIC does'; | ||
|
||
# overloading | ||
{ | ||
package AlwaysABC { | ||
use overload | ||
'eq' => sub { return $_[1] eq "ABC" }, | ||
'""' => sub { "not-a-string" }; | ||
} | ||
|
||
ok sv_streq(bless([], "AlwaysABC"), "ABC"), 'AlwaysABC is "ABC"'; | ||
ok !sv_streq(bless([], "AlwaysABC"), "DEF"), 'AlwaysABC is not "DEF"'; | ||
|
||
ok !sv_streq_flags(bless([], "AlwaysABC"), "ABC", SV_SKIP_OVERLOAD), 'AlwaysABC is not "ABC" with SV_SKIP_OVERLOAD'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters