Skip to content

Commit 7b2783d

Browse files
committed
Unfudge / fix "of Type" related tests
1 parent b337aa4 commit 7b2783d

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

S02-types/keybag.t

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ sub showkv($x) {
380380
#?niecza skip "Trait name not available on variables"
381381
{
382382
my %h of KeyBag;
383-
#?rakudo todo '%h of TypeObject syntax not working yet'
384383
ok %h.of.perl eq 'KeyBag', 'is the hash really a KeyBag';
385384
#?rakudo 2 todo 'in flux'
386385
lives_ok { %h = bag <a b c d c b> }, 'Assigning a Bag to a KeyBag';

S09-typed-arrays/arrays.t

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use v6;
22
use Test;
33

4-
plan 58;
4+
plan 61;
55

66
# L<S09/Typed arrays/>
77

@@ -20,26 +20,28 @@ plan 58;
2020
is @x.unshift(2), [2, 2, 3], 'can unshift from typed array';
2121
} #9
2222

23-
#?rakudo skip 'of Int'
2423
{
25-
my @x of Int;
26-
ok @x.of === Int, '@x.of of typed array (my @x of Int)';
27-
lives_ok { @x = 1, 2, 3 }, 'can assign values of the right type (@x of Int)';
28-
lives_ok { @x = 1..3 }, 'can assign range of the right type (@x of Int)';
29-
lives_ok { @x.push: 3, 4}, 'can push values of the right type (@x of Int)';
30-
lives_ok { @x.unshift: 3}, 'can unshift values of the right type (@x of Int)';
31-
lives_ok { @x[0, 2] = 2, 3}, 'can assign values to a slice (@x of Int)';
24+
my Int @x;
25+
ok @x.VAR.of === Int, '@x.VAR.of of typed array (my Int @x)';
26+
lives_ok { @x = 1, 2, 3 }, 'can assign values of the right type (Int @x)';
27+
lives_ok { @x = 1..3 }, 'can assign range of the right type (Int @x)';
28+
lives_ok { @x.push: 3, 4}, 'can push values of the right type (Int @x)';
29+
lives_ok { @x.unshift: 3}, 'can unshift values of the right type (Int @x)';
30+
lives_ok { @x[0, 2] = 2, 3}, 'can assign values to a slice (Int @x)';
3231
@x = 2, 3, 4;
33-
is @x.pop, 4, 'can pop from typed array (@x of Int)';
34-
is @x.unshift(1), [1, 2, 3], 'can unshift from typed array (@x of Int)';
32+
is @x.pop, 4, 'can pop from typed array (Int @x)';
33+
is @x.unshift(1), [1, 2, 3], 'can unshift from typed array (Int @x)';
3534
} #8
3635

3736
# initialization
38-
lives_ok { my @x = 1, 2, 3 }, 'initialization of typed array';
39-
lives_ok { my @x = 1 .. 3 }, 'initialization of typed array from range';
37+
{
38+
lives_ok { my Int @x = 1, 2, 3 }, 'initialization of typed array';
39+
lives_ok { my Int @x = 1 .. 3 }, 'initialization of typed array from range';
40+
} #2
4041

4142
{
4243
my @x of Int;
44+
ok @x.VAR.of === Int, '@x.VAR.of of typed array (my @x of Int)';
4345
lives_ok { @x = 1, 2, 3 }, 'can assign values of the right type (@x of Int)';
4446
lives_ok { @x = 1..3 }, 'can assign range of the right type (@x of Int)';
4547
lives_ok { @x.push: 3, 4}, 'can push values of the right type (@x of Int)';
@@ -49,10 +51,11 @@ lives_ok { my @x = 1 .. 3 }, 'initialization of typed array from range';
4951
is @x.pop, 4, 'can pop from typed array (@x of Int)';
5052

5153
ok @x.unshift, 'can unshift from typed array (@x of Int)';
52-
} #7
54+
} #8
5355

5456
{
5557
my Array @x;
58+
ok @x.VAR.of === Array, '@x.VAR.of of typed array (my Array @x)';
5659
dies_ok { @x = 1, 2, 3 }, 'can not assign values of the wrong type';
5760
dies_ok { @x = 1..3 }, 'can not assign range of the wrong type';
5861
dies_ok { @x.push: 3, 4}, 'can not push values of the wrong type';
@@ -61,28 +64,30 @@ lives_ok { my @x = 1 .. 3 }, 'initialization of typed array from range';
6164
'can not assign values of wrong type to a slice';
6265
lives_ok { @x = [1, 2], [3, 4] },
6366
'... but assigning values of the right type is OK';
64-
} #6
67+
} #7
6568

6669
{
6770
my @x of Array;
71+
ok @x.VAR.of === Array, '@x.VAR.of of typed array (my @x of Array)';
6872
dies_ok { @x = 1, 2, 3 }, 'can not assign values of the wrong type';
6973
dies_ok { @x = 1..3 }, 'can not assign range of the wrong type';
70-
#?rakudo 3 todo "no parametrization"
7174
dies_ok { @x.push: 3, 4}, 'can not push values of the wrong type';
7275
dies_ok { @x.unshift: 3}, 'can not unshift values of the wrong type';
7376
dies_ok { @x[0, 2] = 2, 3},
7477
'can not assign values of wrong type to a slice';
7578
lives_ok { @x = [1, 2], [3, 4] },
7679
'... but assigning values of the right type is OK';
77-
} #6
80+
} #7
7881

79-
#?rakudo skip 'Array not parametric'
8082
{
8183
my Array of Int @x;
8284
ok @x.of === Array[Int], 'my Array of Int @x declares a nested array';
85+
#?rakudo skip "nested typechecks are borked"
8386
lives_ok { @x = [2, 3], [5, 6] }, 'assignment works';
87+
#?rakudo todo "nested typechecks are borked"
8488
lives_ok { @x.push: [8, 9] }, 'pushing works';
8589
dies_ok { @x.push: 8 }, 'type constraint is enforced';
90+
#?rakudo todo "nested typechecks are borked"
8691
lives_ok { @x[0].push: 3 }, 'pushing to the inner array is OK';
8792
dies_ok { @x[0].push: 'foo' }, 'inner array enforces the type constraint';
8893
} #6
@@ -100,7 +105,7 @@ lives_ok { my @x = 1 .. 3 }, 'initialization of typed array from range';
100105
#?rakudo skip 'initialization'
101106
{
102107
my Str @c = <foo bar baz>;
103-
ok @c.keys.of.WHICH eqv Str.WHICH, '@array.keys is typed with Int';
108+
ok @c.keys.of.WHICH eqv Str.WHICH, '@array.keys is typed with Str';
104109
} #1
105110

106111
# test that we can have parametric array return types

0 commit comments

Comments
 (0)