Skip to content

Commit

Permalink
[gsoc_spectest] Simplistic S13 (overloading) typecasting tests (long …
Browse files Browse the repository at this point in the history
…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.
45 changes: 45 additions & 0 deletions S13-overloading/typecasting-long.t
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)');
}

0 comments on commit 69a5550

Please sign in to comment.