New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement [^^] #952
Comments
From @masak<szabgab> rakudo: say 1 ^^ 1 |
From @kylehaThis is an automatically generated mail to inform you that tests are now available in t/spec/S03-operators/reduce-metaop.t commit 4be422c883431ad5a841b0e0d57b7dfbbdb316ba [t/spec] Tests for RT #65164 Inline Patchdiff --git a/t/spec/S03-operators/reduce-metaop.t b/t/spec/S03-operators/reduce-metaop.t
index adae355..b9c3a5a 100644
--- a/t/spec/S03-operators/reduce-metaop.t
+++ b/t/spec/S03-operators/reduce-metaop.t
@@ -1,7 +1,7 @@
use v6;
use Test;
-plan 59;
+plan 71;
=begin pod
@@ -179,4 +179,23 @@ lives_ok({my @foo = [>>+<<] ([1..3],[1..3],[1..3])},'Parse [>>+<<]');
is( ([*]()), 1, "[*]() returns 1");
is( ([+]()), 0, "[+]() returns 0");
+# RT #65164 (TODO: implement [^^])
+#?rakudo skip 'implement [^^]'
+{
+ is [^^](0, 42), 42, '[^^] works (one of two true)';
+ is [^^](42, 0), 42, '[^^] works (one of two true)';
+ ok ! [^^](1, 42), '[^^] works (two true)';
+ ok ! [^^](0, 0), '[^^] works (two false)';
+
+ ok ! [^^](0, 0, 0), '[^^] works (three false)';
+ ok ! [^^](5, 9, 17), '[^^] works (three true)';
+
+ is [^^](5, 9, 0), (5 ^^ 9 ^^ 0), '[^^] mix 1';
+ is [^^](5, 0, 17), (5 ^^ 0 ^^ 17), '[^^] mix 2';
+ is [^^](0, 9, 17), (0 ^^ 9 ^^ 17), '[^^] mix 3';
+ is [^^](5, 0, 0), (5 ^^ 0 ^^ 0), '[^^] mix 4';
+ is [^^](0, 9, 0), (0 ^^ 9 ^^ 0), '[^^] mix 5';
+ is [^^](0, 0, 17), (0 ^^ 0 ^^ 17), '[^^] mix 6';
+}
+
# vim: ft=perl6 |
The RT System itself - Status changed from 'new' to 'open' |
From @bbkrOn * release $ perl6 -e 'say [^^] 1, 1' |
From @masakOn Tue Aug 03 09:05:29 2010, bbkr wrote:
In other words, still not implemented. The error message is better, though. |
From @masak<thundergnat> I was idly looking through RT and came across |
From @thundergnatThe following patch passes all the attached tests (some 285 of them) ################################################################ Inline Patchdiff --git a/src/Perl6/Grammar.pm b/src/Perl6/Grammar.pm
index 93b73c0..8928af1 100644
--- a/src/Perl6/Grammar.pm
+++ b/src/Perl6/Grammar.pm
@@ -1883,7 +1883,7 @@ token dumbsmart {
token infix:sym<&&> { <sym> <O('%tight_and, :pasttype<if>')> }
token infix:sym<||> { <sym> <O('%tight_or, :assoc<left>,
Inline Patchdiff --git a/src/core/operators.pm b/src/core/operators.pm
index 75840d8..8ab2828 100644
--- a/src/core/operators.pm
+++ b/src/core/operators.pm
@@ -512,6 +512,31 @@ our multi sub infix:<or>(Mu $a, Mu $b) { $a or $b }
our multi sub infix:<&&>(Mu $a, Mu $b) { $a && $b }
our multi sub infix:<and>(Mu $a, Mu $b) { $a and $b }
+
+our multi sub infix:<^^>(Mu $a, Mu $b) {
+ return $a ?? $b ?? Bool::False !! $a
+ !! $b ?? $b !! Bool::False;
+}
+
+our multi sub infix:<^^>(Mu @a, Mu @b) {
+ return +@a ?? +@b ?? () !! @b
+ !! +@b ?? @b !! ();
+}
+
+our multi sub infix:<^^>(Mu $a, *@a) {
+ return [^^] $a, @a;
+}
+
+our multi sub prefix:<[^^]>(*@a) {
+ my $a = shift @a;
+ for @a -> $b
+ {
+ return Bool::False if $b && $a;
+ $a ||= $b;
+ };
+ return $a || Bool::False;
+}
+
# Eliminate use of this one, but keep the pir around for
# the moment, as it may come in handy elsewhere.
#
# tests from roast S03-metaops/reduce.t nok [^^] ( 1, 42 ), '[^^] works (two true)'; nok [^^] ( 0, 0, 0 ), '[^^] works (three false)'; ok [^^] ( 5, 9, 0 ) == (5 ^^ 9 ^^ 0), '[^^] mix 1'; # test an empty list { # test False / undefined things for (0, '0', '', Bool::False, Any, Mu, Nil) -> $undef ok [^^] ( $undef, $undef, $undef, 5 ), "|{$undef.perl}| $msg1 { # test numericy true things for (1, -147, pi, Bool::True) -> $def { # test stringy true things for ('no', 'Bob', '10', 'False') -> $def { { is ( 7 ^^ 7 ).WHAT, 'Bool()', 'Bool()'; |
From @thundergnatAttached patch and test files mentioned in previous comment. Doh. |
From @thundergnat# tests from roast S03-metaops/reduce.t nok [^^] ( 1, 42 ), '[^^] works (two true)'; nok [^^] ( 0, 0, 0 ), '[^^] works (three false)'; ok [^^] ( 5, 9, 0 ) == (5 ^^ 9 ^^ 0), '[^^] mix 1'; # test an empty list { # test False / undefined things for (0, '0', '', Bool::False, Any, Mu, Nil) -> $undef ok [^^] ( $undef, $undef, $undef, 5 ), "|{$undef.perl}| $msg1 \#1"; { # test numericy true things for (1, -147, pi, Bool::True) -> $def { # test stringy true things for ('no', 'Bob', '10', 'False') -> $def { { is ( 7 ^^ 7 ).WHAT, 'Bool()', 'Bool()'; |
From @thundergnatdiff --git a/src/Perl6/Grammar.pm b/src/Perl6/Grammar.pm token infix:sym<||> { <sym> <O('%tight_or, :assoc<left>, :pasttype<unless>'> } + |
From @KodiologistI've made other changes to Rakudo (549d2a9) in preference to your patch, |
@Kodiologist - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#65164 (status was 'resolved')
Searchable as RT65164$
The text was updated successfully, but these errors were encountered: