Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[gsoc_spectest] s/module/class/ in typecasting-long.t. Added typecast…

…ing-short.t to test the same things but with the shorter syntax form.

git-svn-id: http://svn.pugscode.org/pugs@20574 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
commit a29196f1dc5370f41fbbb410520b5e4c7400a82d 1 parent 69a5550
Auzon authored
View
6 S13-overloading/typecasting-long.t
@@ -7,7 +7,7 @@ plan 14;
# basic tests to see if the methods overload correctly.
{
- module TypeCastSub {
+ class TypeCastSub {
method postcircumfix:<( )> (|$capture) {return 'pretending to be a sub'}
}
@@ -17,7 +17,7 @@ plan 14;
}
{
- module TypeCastArray {
+ class TypeCastArray {
method postcircumfix:<[ ]> (*@@slice) {return 'pretending to be an array'}
}
@@ -29,7 +29,7 @@ plan 14;
}
{
- module TypeCastHash {
+ class TypeCastHash {
method postcircumfix:<{ }> (*@@slice) {return 'pretending to be a hash'}
}
View
45 S13-overloading/typecasting-short.t
@@ -0,0 +1,45 @@
+use v6;
+use Test;
+
+plan 14;
+
+# L<S13/"Type Casting"/"method %.{ *@@slice } {...}">
+# basic tests to see if the methods overload correctly.
+
+{
+ class TypeCastSub {
+ method &.( |$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');
+}
+
+{
+ class TypeCastArray {
+ method @.[ *@@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)');
+}
+
+{
+ class TypeCastHash {
+ method %.{ *@@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)');
+}
Please sign in to comment.
Something went wrong with that request. Please try again.