Author: tim.bunce
Date: Thu Nov 20 05:01:44 2008
New Revision: 617
Added:
trunk/xt/test45-overload.p
Modified:
trunk/MANIFEST
Log:
Add script to exercise calls made by overload
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST (original)
+++ trunk/MANIFEST Thu Nov 20 05:01:44 2008
@@ -108,5 +108,6 @@
t/test80-recurs.p
t/test80-recurs.rdt
typemap
+xt/test45-overload.p
xt/test71-while.p
xt/test90-stress.p
Added: trunk/xt/test45-overload.p
==============================================================================
--- (empty file)
+++ trunk/xt/test45-overload.p Thu Nov 20 05:01:44 2008
@@ -0,0 +1,29 @@
+# test to see that
+
+# example from the overload docs (with slight changes)
+{
+package two_face; # Scalars with separate string and numeric values.
+
+use overload
+ '""' => \&str, # ref to named sub
+ '0+' => sub {shift->[0]}, # ref to anon sub
+ '&{}' => "code", # name of method
+ fallback => 1;
+
+sub new {
+ my $p = shift;
+ bless [EMAIL PROTECTED], $p
+}
+sub str {
+ shift->[0]
+}
+sub code {
+ sub { 1 }
+}
+
+}
+
+my $seven = new two_face ("vii", 7);
+printf "seven=$seven, seven=%d, eight=%d\n", $seven, $seven+1;
+print "seven contains āiā\n" if $seven =~ /i/;
+$seven->();
--~--~---------~--~----~------------~-------~--~----~
You've received this message because you are subscribed to
the Devel::NYTProf Development User group.
Group hosted at: http://groups.google.com/group/develnytprof-dev
Project hosted at: http://perl-devel-nytprof.googlecode.com
CPAN distribution: http://search.cpan.org/dist/Devel-NYTProf
To post, email: [email protected]
To unsubscribe, email: [EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---