@@ -4,15 +4,16 @@ use Test;
4
4
5
5
plan 17 ;
6
6
7
+ # ?rakudo.parrot skip 'Metamodel::Primitives NYI'
7
8
{
8
9
my $ union-type-checks = 0 ;
9
10
my $ union-find-method-calls = 0 ;
10
-
11
+
11
12
class UnionTypeHOW {
12
13
has @ ! types ;
13
-
14
+
14
15
submethod BUILD (: @ ! types ) { }
15
-
16
+
16
17
method new_type (* @ types ) {
17
18
my $ how = self . new (: @ types );
18
19
my $ type = Metamodel ::Primitives. create_type($ how , ' Uninstantiable' );
@@ -35,10 +36,10 @@ plan 17;
35
36
% cache {. key } // = . value ;
36
37
}
37
38
Metamodel ::Primitives. install_method_cache($ type , % cache );
38
-
39
+
39
40
$ type
40
41
}
41
-
42
+
42
43
method type_check (Mu $ , Mu \check) {
43
44
$ union-type-checks ++ ;
44
45
for @ ! types , Any , Mu {
@@ -78,16 +79,15 @@ plan 17;
78
79
$ int-or-rat .^ compose;
79
80
$ union-type-checks = 0 ;
80
81
$ union-find-method-calls = 0 ;
82
+ # ?rakudo.jvm 4 todo 'RT #123426'
81
83
ok Int ~~ $ int-or-rat , ' Union type works with cache (1)' ;
82
84
ok Rat ~~ $ int-or-rat , ' Union type works with cache (2)' ;
83
85
ok 420 ~~ $ int-or-rat , ' Union type works with cache (3)' ;
84
86
ok 4.2 ~~ $ int-or-rat , ' Union type works with cache (4)' ;
85
87
nok Str ~~ $ int-or-rat , ' Union type works with cache (5)' ;
86
88
nok ' w' ~~ $ int-or-rat , ' Union type works with cache (6)' ;
87
-
89
+
90
+ # ?rakudo.jvm 2 todo 'RT #123426'
88
91
is $ union-type-checks , 0 , ' Really did use type cache' ;
89
92
is $ union-find-method-calls , 0 , ' Really did use method cache' ;
90
93
}
91
-
92
-
93
-
0 commit comments