Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 105 lines (87 sloc) 3.026 kb
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
1 use v6;
2
3 use Test;
4
caf2d4b [t/spec] Another Null PMC test inspired by IRC
kyle authored
5 plan 69;
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
6
7 =begin description
8
9 Enum tests from L<S12/Enums>
10
11 =end description
12
13 #?pugs 999 skip
14 # L<S12/Enums/values are specified as a list>
15 enum day <Sun Mon Tue Wed Thu Fri Sat>;
16
d2c9e73 [t/spec] Add test for RT#63878.
jnthn authored
17 ok day ne "", 'enum itself stringififes';
a8b77bc [spec] test .WHAT and .perl on actual enums, masak++
moritz authored
18 ok day.WHAT, 'enum.WHAT returned a value';
19 ok day.perl, 'enum.perl returned a value';
20
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
21 sub test_stuff($x) {
43b5fc8 [t/spec] .does(Enum::Value) is on shakey ground, since the values are no...
jnthn authored
22 #?rakudo 1 skip '.does for enum value - XXX is this really valid test? asked TimToady...'
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
23 ok $x.does(day::Tue), "basic enum mixing worked ($x-2)";
24 is $x.day, 2, "automatically created accessor worked ($x)";
25 is day::Tue, 2, "enum provided a correct mapping ($x)";
26 ok $x ~~ day, "smartmatch worked correctly ($x-1)";
27 ok $x ~~ Tue, "smartmatch worked correctly ($x-2)";
28 ok $x ~~ day::Tue, "smartmatch worked correctly ($x-3)";
29 ok $x !~~ Wed, "smartmatch worked correctly ($x-4)";
43b5fc8 [t/spec] .does(Enum::Value) is on shakey ground, since the values are no...
jnthn authored
30 #?rakudo 1 skip '.does for enum value - XXX is this really valid test? asked TimToady...'
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
31 ok $x.does(Tue), ".does worked correctly ($x-1)";
32 ok $x.does(day), ".does worked correctly ($x-2)";
33 #?rakudo skip 'EnumValue($x)'
34 ok Tue($x), "Tue() worked correctly ($x)";
35 ok $x.Tue, ".Tue() worked correctly ($x)";
36 #?rakudo skip 'unknown bug'
37 ok $x.Tue.WHAT, '$obj.Tue.WHAT returns a true valuee';
38 ok $x.Tue.perl, '$obj.Tue.perl returns a true valuee';
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
39 }
40
41 {
42 my $x = 1;
43 is $x, 1, "basic sanity (1)";
44 # L<S12/Enums/has the right semantics mixed in:>
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
45 ok $x does day(Tue), "basic enum mixing worked (1-1)";
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
46 test_stuff($x);
47 }
48
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
49 #?DOES 15
50 #?rakudo skip 'does day<tue> - but is this even valid?'
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
51 {
52 my $x = 2;
53 is $x, 2, "basic sanity (2)";
54 # L<S12/Enums/or pseudo-hash form:>
55 ok $x does day<Tue>, "basic enum mixing worked (2-1)";
56 test_stuff($x);
57 }
58
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
59 #?rakudo skip 'does day::Tue'
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
60 {
61 my $x = 3;
62 is $x, 3, "basic sanity (3)";
63 # L<S12/Enums/is the same as>
64 ok $x does day::Tue, "basic enum mixing worked (3-1)";
65 test_stuff($x);
66 }
67
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
68 #?DOES 16
69 #?rakudo skip 'does &day::("Tue")'
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
70 {
71 my $x = 4;
72 is $x, 4, "basic sanity (4)";
73 # L<S12/Enums/which is short for something like:>
74 ok $x does day, "basic enum mixing worked (4-0)";
75 ok $x.day = &day::("Tue"), "basic enum mixing worked (4-1)";
76 test_stuff($x);
77 }
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
78
79 # used to be Rakudo regression, RT #64098
df3f661 [t/spec] fudge an "augment" test for rakudo; try to test the same with e...
moritz authored
80 #?rakudo skip 'augment'
81 #?DOES 2
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
82 {
4b71fc9 [t/spec] fix an "is also" that is giving STD fits
lwall authored
83 augment class Object {
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
84 method f { 'inObject' };
85 }
86
4b71fc9 [t/spec] fix an "is also" that is giving STD fits
lwall authored
87 augment class Bool {
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
88 method f { 'inBool' };
89 }
90 is True.f, 'inBool', 'method on short name pick up the one from the enum';
91 is Bool::True.f, 'inBool', 'method on long name pick up the one from the enum';
92 }
93
df3f661 [t/spec] fudge an "augment" test for rakudo; try to test the same with e...
moritz authored
94 ok True.perl ~~/^ 'Bool::True'/, 'True.perl';
95 ok Bool::True.perl ~~/^ 'Bool::True'/, 'Bool::True.perl';
96
caf2d4b [t/spec] Another Null PMC test inspired by IRC
kyle authored
97 {
98 enum Negation << :isnt<isnt> :arent<arent> :amnot<amnot> :aint<aint> >>;
99 my Negation $foo;
100 #?rakudo todo 'Null PMC Access in invoke()'
101 lives_ok { $foo = Negation::isnt }, 'simple assignment from enum';
102 }
103
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
104 # vim: ft=perl6
Something went wrong with that request. Please try again.