-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gsoc_spectest] Simplistic S13 (overloading) typecasting tests (long …
…form). git-svn-id: http://svn.pugscode.org/pugs@20573 c213334d-75ef-0310-aa23-eaa082d1ae64
- Loading branch information
Auzon
authored and
Auzon
committed
May 28, 2008
1 parent
2a55815
commit 69a5550
Showing
1 changed file
with
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use v6; | ||
use Test; | ||
|
||
plan 14; | ||
|
||
# L<S13/"Type Casting"/"method postcircumfix:<{ }> (*@@slice) {...}"> | ||
# basic tests to see if the methods overload correctly. | ||
|
||
{ | ||
module TypeCastSub { | ||
method postcircumfix:<( )> (|$capture) {return 'pretending to be a sub'} | ||
} | ||
|
||
my $thing = TypeCastSub.new; | ||
is($thing(), 'pretending to be a sub', 'overloaded () call works'); | ||
is($thing.(), 'pretending to be a sub', 'overloaded .() call works'); | ||
} | ||
|
||
{ | ||
module TypeCastArray { | ||
method postcircumfix:<[ ]> (*@@slice) {return 'pretending to be an array'} | ||
} | ||
|
||
my $thing = TypeCastArray.new; | ||
is($thing[1], 'pretending to be an array', 'overloaded [] call works'); | ||
is($thing[2,3], 'pretending to be an array', 'overloaded [] call works (slice)'); | ||
is($thing.[4], 'pretending to be an array', 'overloaded .[] call works'); | ||
is($thing.[5,6], 'pretending to be an array', 'overloaded .[] call works (slice)'); | ||
} | ||
|
||
{ | ||
module TypeCastHash { | ||
method postcircumfix:<{ }> (*@@slice) {return 'pretending to be a hash'} | ||
} | ||
|
||
my $thing = TypeCastHash.new; | ||
is($thing{'a'}, 'pretending to be a hash', 'overloaded {} call works'); | ||
is($thing{'b','c'}, 'pretending to be a hash', 'overloaded {} call works (slice)'); | ||
is($thing.{'d'}, 'pretending to be a hash', 'overloaded .{} call works'); | ||
is($thing.{'e','f'}, 'pretending to be a hash', 'overloaded .{} call works (slice)'); | ||
is($thing<a>, 'pretending to be a hash', 'overloaded <> call works'); | ||
is($thing<b c>, 'pretending to be a hash', 'overloaded <> call works (slice)'); | ||
is($thing.<d>, 'pretending to be a hash', 'overloaded .<> call works'); | ||
is($thing.<e f>, 'pretending to be a hash', 'overloaded .<> call works (slice)'); | ||
} |