This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Die on malformed isFOO_utf8() input
[perl5.git] / t / lib / overload_fallback.t
CommitLineData
c989e6a3
GD
1use warnings;
2use strict;
5cc9a776
DC
3
4BEGIN {
5 chdir 't' if -d 't';
6 @INC = '../lib';
7 require './test.pl';
8 plan( tests => 3 );
9}
c989e6a3
GD
10
11use overload '""' => sub { 'stringvalue' }, fallback => 1;
12
13BEGIN {
14my $x = bless {}, 'main';
15ok ($x eq 'stringvalue', 'fallback worked');
16}
17
18
19# NOTE: delete the next line and this test script will pass
20use overload '+' => sub { die "unused"; };
21
22my $x = bless {}, 'main';
23ok (eval {$x eq 'stringvalue'}, 'fallback worked again');
24
5cc9a776
DC
25TODO: {
26 local $::TODO = 'RT #43356: Autogeneration of ++ is incorrect';
27 fresh_perl_is(<<'EOC', '2', {}, 'RT #43356: Autogeneration of ++');
28use overload
29 "0+" => sub { ${$_[0]} },
30 "=" => sub { ${$_[0]} },
31 fallback => 1;
32my $value = bless \(my $dummy = 1), __PACKAGE__;
33print ++$value;
34EOC
35}