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
Function form of enum constructor #825
Comments
From @moritzFrom S12: There's also a pseudo-functional form: $x = "Today" but day(Tue); which lets you cheat: $x = "Today" but day(3); Rakudo doesn't do that yet: $ perl6 -e 'enum A <B C D>; say A(1).perl' |
From @masak<masak> rakudo: enum Month <Jan Feb Mar Apr May Jun Jul Aug Sep Oct |
From @kylehaThis is an automatically generated mail to inform you that tests are now available in t/spec/S12-enums/pseudo-functional.t commit 82d963e5541998a12262bd5f66541a84ef6f0374 [t/spec] Tests for RT #64102 (enum functional form) Inline Patchdiff --git a/t/spec/S12-enums/pseudo-functional.t b/t/spec/S12-enums/pseudo-functional.t
new file mode 100644
index 0000000..bbdf121
--- /dev/null
+++ b/t/spec/S12-enums/pseudo-functional.t
@@ -0,0 +1,33 @@
+use v6;
+use Test;
+
+plan 13;
+
+# L<12/Enums/There's also a pseudo-functional form>
+
+enum day <<:Sun(1) Mon Tue Wed Thu Fri Sat>>;
+
+is day(Tue), day(3), 'day(Tue) same as day(3)';
+
+{
+ my $today_tue = 'Today' but day(Tue);
+ my $today_3 = 'Today' but day(3);
+
+ is $today_tue, $today_3, 'day(Tue) same as day(3) in variables';
+}
+
+my $x = 'Today' but day(Tue);
+
+ok $x ~~ day, 'day(Tue) is a day';
+ok $x ~~ Tue, 'day(Tue) is Tue';
+ok $x.does(Tue), 'day(Tue).does(Tue)';
+ok $x.day == Tue, 'day(Tue) == Tue';
+ok day($x) == Tue, 'day(day(Tue)) == Tue';
+ok $x.Tue, 'day(Tue).Tue';
+
+ok $x.day != Wed, 'day(Tue) != Wed';
+
+nok $x.does(Wed), '! day(Tue).does(Wed)';
+nok $x.Wed, '! day(Tue).does(Wed)';
+nok 8.does(day), '8 is not a day';
+nok 8 ~~ day, '8 does not match day'; |
The RT System itself - Status changed from 'new' to 'open' |
From @kylehaThis is an automatically generated mail to inform you that tests are now available in t/spec/S12-enums/thorough.t commit 8785f522e418108dbccd2e289ed6829b6f1ecf83 [t/spec] Test for RT 65658 Inline Patchdiff --git a/t/spec/S12-enums/thorough.t b/t/spec/S12-enums/thorough.t
index 66598c6..d6fad0c 100644
--- a/t/spec/S12-enums/thorough.t
+++ b/t/spec/S12-enums/thorough.t
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 71;
+plan *;
=begin description
@@ -110,4 +110,14 @@ ok Bool::True.perl ~~/^ 'Bool::True'/, 'Bool::True.perl';
eval_dies_ok 'RT66886::c', 'accessing non-value of enum dies proper-like';
}
+# RT #65658
+{
+ enum RT65658 <Todo Bug Feature Ticket>;
+ #?rakudo 2 skip 'RT 65658'
+ is RT65658(2), RT65658::Feature, 'can index enum by number';
+ is RT65658((Todo + 3.2).Int), RT65658::Ticket, 'enum and math and index';
+}
+
+done_testing;
+
# vim: ft=perl6 |
The RT System itself - Status changed from 'new' to 'open' |
From @moritzWorks now, tests pass. |
@moritz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#64102 (status was 'resolved')
Searchable as RT64102$
The text was updated successfully, but these errors were encountered: