Skip to content

Commit 2b52ada

Browse files
committed
Merge branch 'master' of git://github.com/perl6/roast
2 parents d09de35 + 1858f90 commit 2b52ada

File tree

7 files changed

+102
-8
lines changed

7 files changed

+102
-8
lines changed

S02-literals/radix.t

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

4-
plan 133;
4+
plan 134;
55

66
# L<S02/General radices/":10<42>">
77
is( :10<0>, 0, 'got the correct int value from decimal 0' );
@@ -24,6 +24,9 @@ is( :10<42>, 0d42, ':10<42> and 0d42 are the same' );
2424
is(:10('0x20'), 0x20, ":10('0x20') overrides default decimal");
2525
is(:10('0o377'), 0o377, ":10('0o255') overrides default decimal");
2626
is(:10('0d37'), 0d37, ":10('0d37') overrides default decimal");
27+
28+
# RT #107756
29+
dies_ok { :10(42) }, ':10() really wants a string, not a number';
2730
}
2831

2932

S02-magicals/progname.t

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ if $*OS eq "browser" {
1010
exit;
1111
}
1212

13-
#?rakudo skip 'No PROCESS yet'
1413
ok(PROCESS::<$PROGRAM_NAME> ~~ / t['/'|'\\']spec['/'|'\\']S02'-'magicals['/'|'\\']progname'.'\w+$/, "progname var matches test file path");
1514
ok($*PROGRAM_NAME ~~ / t['/'|'\\']spec['/'|'\\']S02'-'magicals['/'|'\\']progname'.'\w+$/, "progname var accessible as context var");
1615

S03-operators/context.t

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use v6;
22

33
use Test;
44

5-
plan 29;
5+
plan 32;
66

77
# L<S03/List prefix precedence/The list contextualizer>
88

@@ -88,4 +88,22 @@ eval_dies_ok('@', 'Anonymous @ variable outside of declaration');
8888
eval_dies_ok('%', 'Anonymous % variable outside of declaration');
8989
eval_dies_ok('&', 'Anonymous & variable outside of declaration');
9090

91+
# RT #76320
92+
{
93+
my $h = <a b c d>;
94+
is ~%$h.keys.sort, 'a c', '%$var coercion';
95+
96+
my $c = 0;
97+
$c++ for @$h;
98+
is $c, 4, '@$var coercion';
99+
}
100+
101+
#?rakudo skip '$@var syntax'
102+
{
103+
my @a = <a b c d>;
104+
my $c = 0;
105+
$c++ for $@a;
106+
is $c, 1, '$@var itemization'
107+
}
108+
91109
# vim: ft=perl6

S03-operators/short-circuit.t

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ it is closely related to || and && and //.
1212
1313
=end description
1414

15-
# test cases by Andrew Savige
16-
17-
plan 79;
15+
plan 80;
1816

1917
my $accum = '';
2018
sub f1($s) { $accum ~= $s; 1 }
@@ -305,6 +303,13 @@ ok (0 || 0 || 1), '0 || 0 || 1 is true';
305303

306304
}
307305

306+
# RT #90158
307+
{
308+
my @a = 1;
309+
@a ||= ();
310+
is ~@a, '1', '||= works with array on the LHS';
311+
}
312+
308313
done;
309314

310315
# vim: ft=perl6

S06-signature/optional.t

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use Test;
33

44
# L<S06/Optional parameters/>
55

6-
plan 24;
6+
plan 25;
77

88
sub opt1($p?) { defined($p) ?? $p !! 'undef'; }
99

@@ -105,6 +105,12 @@ eval_dies_ok 'sub opt($a = 1, $b) { }',
105105
%h
106106
}
107107
is opt-hash().keys, 'a', 'can assign to optional parameter';
108+
109+
# RT #79642
110+
sub opt-hash2(%h?) {
111+
%h;
112+
}
113+
ok opt-hash2() eqv ().hash, 'an optional-but-not-filled hash is just an empty Hash';
108114
}
109115

110116
# vim: ft=perl6

S12-methods/accessors.t

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
use v6;
2+
use Test;
3+
4+
plan 8;
5+
6+
class A {
7+
has @.a;
8+
has $.b;
9+
method test-list-a {
10+
my $x = 0;
11+
$x++ for @.a;
12+
$x;
13+
}
14+
method test-scalar-a {
15+
my $x = 0;
16+
$x++ for $.a;
17+
$x;
18+
}
19+
method test-list-b {
20+
my $x = 0;
21+
$x++ for @.b;
22+
$x;
23+
}
24+
method test-scalar-b {
25+
my $x = 0;
26+
$x++ for $.b;
27+
$x;
28+
}
29+
method test-hash-a {
30+
my $x = 0;
31+
$x++ for %.a;
32+
$x;
33+
}
34+
35+
}
36+
37+
my $a = A.new(a => (1, 2, 3, 4), b => [3, 4, 5, 6]);
38+
is $a.test-list-a, 4, '@.a contextualizes as (flat) list (1)';
39+
is $a.test-scalar-a, 1, '$.a contextualizes as item (1)';
40+
is $a.test-list-b, 4, '@.a contextualizes as (flat) list (2)';
41+
is $a.test-scalar-b, 1, '$.a contextualizes as item (2)';
42+
is $a.test-hash-a, 2, '%.a contextualizes as hash';
43+
44+
# RT #78678
45+
{
46+
class Parent {
47+
has $.x is rw;
48+
method parent-x() { $!x };
49+
}
50+
class Child is Parent {
51+
has $.x is rw;
52+
method child-x() { $!x };
53+
}
54+
my $o = Child.new(x => 42);
55+
$o.Parent::x = 5;
56+
is $o.parent-x, 5, 'parent attribute is separate from child attribute of the same name (parent)';
57+
is $o.child-x, 42, 'parent attribute is separate from child attribute of the same name (child)';
58+
is $o.x, 42, '.accessor returns that of the child';
59+
60+
}

S14-roles/mixin.t

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use v6;
22
use Test;
3-
plan 29;
3+
plan 30;
44

55
# L<S14/Run-time Mixins/>
66

@@ -135,4 +135,7 @@ is $y.test, 42, 'method from other role was OK too';
135135
is (class { } but role { method answer() { 42 } }).answer, 42,
136136
'can mix a role into a type object';
137137

138+
# RT #101022
139+
lives_ok {(True but role {}).gist}, 'can mix into True';
140+
138141
# vim: syn=perl6

0 commit comments

Comments
 (0)