Skip to content

Commit

Permalink
Modify tests to account for method cache changes
Browse files Browse the repository at this point in the history
Pre-calculated method caches are not a part of new-disp. The built-in
meta-objects will stop producing them soon on MoarVM; hopefully, with
time, we'll adopt the new-disp approach on JVM too, and can fully
deprecate the method caching related functionality in the metamodel
primitives class.

For now, at least, make the tests not depend on the semantics of the
legacy method caching strategy. Method caches were always just an
optimization, and it was a pragmatic choice to allow user-defined
meta-objects to opt in to it. However, it should not have been
relied upon for semantic effect, which is what these tests did.
  • Loading branch information
jnthn committed Jul 27, 2021
1 parent 6b7c4f2 commit c07c5b9
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions S12-meta/primitives.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 20;
plan 19;

{
my $union-type-checks = 0;
Expand All @@ -29,13 +29,6 @@ plan 20;
[@!types, Any, Mu],
:authoritative, :call_accepts);

# Steal methods of Any/Mu for our method cache.
my %cache;
for flat Any.^method_table.pairs, Mu.^method_table.pairs {
%cache{.key} //= .value;
}
Metamodel::Primitives.install_method_cache($type, %cache);

$type
}

Expand Down Expand Up @@ -73,7 +66,7 @@ plan 20;
nok 4.2 ~~ $int-or-rat, 'Union type broken before compose (4)';

ok $union-type-checks >= 4, 'Type checking called method before compose';
ok $union-find-method-calls >= 4, 'ACCEPTS method lookup before compose';
ok $union-find-method-calls >= 1, 'ACCEPTS method lookup before compose';

$int-or-rat.^compose;
$union-type-checks = 0;
Expand All @@ -88,9 +81,8 @@ plan 20;
nok 'w' ~~ $int-or-rat, 'Union type works with cache (6)';

# https://github.com/Raku/old-issue-tracker/issues/3606
#?rakudo.jvm 2 todo 'RT #123426'
#?rakudo.jvm 1 todo 'RT #123426'
is $union-type-checks, 0, 'Really did use type cache';
is $union-find-method-calls, 0, 'Really did use method cache';
}

{
Expand Down

0 comments on commit c07c5b9

Please sign in to comment.