/
any-type.t
52 lines (46 loc) 路 1.9 KB
/
any-type.t
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use Test;
plan 4;
#L<S03/Smart matching/type membership>
subtest "Basics" => {
plan 3;
class Dog {}
class Cat {}
class Chihuahua is Dog {} # i'm afraid class Pugs will get in the way ;-)
role SomeRole { };
class Something does SomeRole { };
ok (Chihuahua ~~ Dog), "chihuahua isa dog";
ok (Something ~~ SomeRole), 'something does dog';
ok !(Chihuahua ~~ Cat), "chihuahua is not a cat";
}
# https://github.com/Raku/old-issue-tracker/issues/1449
subtest "RT 71462" => {
plan 10;
is 'RT71462' ~~ Str, True, '~~ Str returns a Bool (1)';
is 5 ~~ Str, False, '~~ Str returns a Bool (2)';
is 'RT71462' ~~ Int, False, '~~ Int returns a Bool (1)';
is 5 ~~ Int, True, '~~ Int returns a Bool (2)';
is 'RT71462' ~~ Set, False, '~~ Set returns a Bool (1)';
is set(1, 3) ~~ Set, True, '~~ Set returns a Bool (2)';
is 'RT71462' ~~ Numeric, False, '~~ Numeric returns a Bool (1)';
is 5 ~~ Numeric, True, '~~ Numeric returns a Bool (2)';
is &say ~~ Callable, True, '~~ Callable returns a Bool (1)';
is 5 ~~ Callable, False, '~~ Callable returns a Bool (2)';
}
# https://github.com/Raku/old-issue-tracker/issues/1956
subtest "RT 76610" => {
plan 2;
module M { };
lives-ok { 42 ~~ M }, '~~ module lives';
ok not $/, '42 is not a module';
}
# https://github.com/rakudo/rakudo/issues/3383
subtest "GH 3383" => {
plan 6;
ok Array ~~ Positional, "Array ~~ Positional";
ok Array[Str] ~~ Positional, "Array[Str] ~~ Positional";
ok Array[Str] ~~ Positional[Str], "Array[Str] ~~ Positional[Str]";
ok Array[Str:D] ~~ Positional, "Array[Str:D] ~~ Positional";
ok Array[Str:D] ~~ Positional[Str], "Array[Str:D] ~~ Positional[Str]";
ok Array[Str:D] ~~ Positional[Str:D], "Array[Str:D] ~~ Positional[Str:D]";
}
# vim: expandtab shiftwidth=4