Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 1baebc1f6c
Fetching contributors…

Cannot retrieve contributors at this time

file 26 lines (18 sloc) 0.546 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
use v6;

use Test;

plan 5;

=begin description

Testing coercion types.

=end description

sub t1(Int() $x) {
    is($x.WHAT.gist, 'Int()', 'object bound .WHATs to the right thing');
    is($x, 1, 'object bound was coerced to the right value');
}
t1(4/3);

sub t2(Int(Rat) $x) {
    is($x.WHAT.gist, 'Int()', 'object bound .WHATs to the right thing');
    is($x, 2, 'object bound was coerced to the right value');
}
t2(7/3);
dies_ok { eval("t2('omg hedgehog!')") }, 'Type checks still enforced';

# vim: ft=perl6
Something went wrong with that request. Please try again.