Skip to content
Browse files

Merge branch 'master' of git://github.com/perl6/roast

  • Loading branch information...
2 parents d09de35 + 1858f90 commit 2b52ada8ecc440c69e6b170177a40104ff616f9c @pmichaud pmichaud committed Apr 22, 2012
View
5 S02-literals/radix.t
@@ -1,7 +1,7 @@
use v6;
use Test;
-plan 133;
+plan 134;
# L<S02/General radices/":10<42>">
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' );
is(:10('0x20'), 0x20, ":10('0x20') overrides default decimal");
is(:10('0o377'), 0o377, ":10('0o255') overrides default decimal");
is(:10('0d37'), 0d37, ":10('0d37') overrides default decimal");
+
+ # RT #107756
+ dies_ok { :10(42) }, ':10() really wants a string, not a number';
}
View
1 S02-magicals/progname.t
@@ -10,7 +10,6 @@ if $*OS eq "browser" {
exit;
}
-#?rakudo skip 'No PROCESS yet'
ok(PROCESS::<$PROGRAM_NAME> ~~ / t['/'|'\\']spec['/'|'\\']S02'-'magicals['/'|'\\']progname'.'\w+$/, "progname var matches test file path");
ok($*PROGRAM_NAME ~~ / t['/'|'\\']spec['/'|'\\']S02'-'magicals['/'|'\\']progname'.'\w+$/, "progname var accessible as context var");
View
20 S03-operators/context.t
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 29;
+plan 32;
# L<S03/List prefix precedence/The list contextualizer>
@@ -88,4 +88,22 @@ eval_dies_ok('@', 'Anonymous @ variable outside of declaration');
eval_dies_ok('%', 'Anonymous % variable outside of declaration');
eval_dies_ok('&', 'Anonymous & variable outside of declaration');
+# RT #76320
+{
+ my $h = <a b c d>;
+ is ~%$h.keys.sort, 'a c', '%$var coercion';
+
+ my $c = 0;
+ $c++ for @$h;
+ is $c, 4, '@$var coercion';
+}
+
+#?rakudo skip '$@var syntax'
+{
+ my @a = <a b c d>;
+ my $c = 0;
+ $c++ for $@a;
+ is $c, 1, '$@var itemization'
+}
+
# vim: ft=perl6
View
11 S03-operators/short-circuit.t
@@ -12,9 +12,7 @@ it is closely related to || and && and //.
=end description
-# test cases by Andrew Savige
-
-plan 79;
+plan 80;
my $accum = '';
sub f1($s) { $accum ~= $s; 1 }
@@ -305,6 +303,13 @@ ok (0 || 0 || 1), '0 || 0 || 1 is true';
}
+# RT #90158
+{
+ my @a = 1;
+ @a ||= ();
+ is ~@a, '1', '||= works with array on the LHS';
+}
+
done;
# vim: ft=perl6
View
8 S06-signature/optional.t
@@ -3,7 +3,7 @@ use Test;
# L<S06/Optional parameters/>
-plan 24;
+plan 25;
sub opt1($p?) { defined($p) ?? $p !! 'undef'; }
@@ -105,6 +105,12 @@ eval_dies_ok 'sub opt($a = 1, $b) { }',
%h
}
is opt-hash().keys, 'a', 'can assign to optional parameter';
+
+ # RT #79642
+ sub opt-hash2(%h?) {
+ %h;
+ }
+ ok opt-hash2() eqv ().hash, 'an optional-but-not-filled hash is just an empty Hash';
}
# vim: ft=perl6
View
60 S12-methods/accessors.t
@@ -0,0 +1,60 @@
+use v6;
+use Test;
+
+plan 8;
+
+class A {
+ has @.a;
+ has $.b;
+ method test-list-a {
+ my $x = 0;
+ $x++ for @.a;
+ $x;
+ }
+ method test-scalar-a {
+ my $x = 0;
+ $x++ for $.a;
+ $x;
+ }
+ method test-list-b {
+ my $x = 0;
+ $x++ for @.b;
+ $x;
+ }
+ method test-scalar-b {
+ my $x = 0;
+ $x++ for $.b;
+ $x;
+ }
+ method test-hash-a {
+ my $x = 0;
+ $x++ for %.a;
+ $x;
+ }
+
+}
+
+my $a = A.new(a => (1, 2, 3, 4), b => [3, 4, 5, 6]);
+is $a.test-list-a, 4, '@.a contextualizes as (flat) list (1)';
+is $a.test-scalar-a, 1, '$.a contextualizes as item (1)';
+is $a.test-list-b, 4, '@.a contextualizes as (flat) list (2)';
+is $a.test-scalar-b, 1, '$.a contextualizes as item (2)';
+is $a.test-hash-a, 2, '%.a contextualizes as hash';
+
+# RT #78678
+{
+ class Parent {
+ has $.x is rw;
+ method parent-x() { $!x };
+ }
+ class Child is Parent {
+ has $.x is rw;
+ method child-x() { $!x };
+ }
+ my $o = Child.new(x => 42);
+ $o.Parent::x = 5;
+ is $o.parent-x, 5, 'parent attribute is separate from child attribute of the same name (parent)';
+ is $o.child-x, 42, 'parent attribute is separate from child attribute of the same name (child)';
+ is $o.x, 42, '.accessor returns that of the child';
+
+}
View
5 S14-roles/mixin.t
@@ -1,6 +1,6 @@
use v6;
use Test;
-plan 29;
+plan 30;
# L<S14/Run-time Mixins/>
@@ -135,4 +135,7 @@ is $y.test, 42, 'method from other role was OK too';
is (class { } but role { method answer() { 42 } }).answer, 42,
'can mix a role into a type object';
+# RT #101022
+lives_ok {(True but role {}).gist}, 'can mix into True';
+
# vim: syn=perl6

0 comments on commit 2b52ada

Please sign in to comment.
Something went wrong with that request. Please try again.