Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 40 lines (27 sloc) 0.963 kb
ce6a843 [spec] add a simple test that an Enum can act like a role
moritz authored
1 use v6;
2 use Test;
3
bd78d81 [spec] fixed role tests, jonathan++
moritz authored
4 plan 9;
ce6a843 [spec] add a simple test that an Enum can act like a role
moritz authored
5
6 #L<S12/Enums/"An enum is a low-level class that can function as a role
7 # or property">
8
bd78d81 [spec] fixed role tests, jonathan++
moritz authored
9 enum Maybe <No Yes Dunno>;
10 class Bar { }
ce6a843 [spec] add a simple test that an Enum can act like a role
moritz authored
11
bd78d81 [spec] fixed role tests, jonathan++
moritz authored
12 {
13 class Foo does Maybe { }
ce6a843 [spec] add a simple test that an Enum can act like a role
moritz authored
14
b6696c3 [t/spec] Reviewed an enums test; don't see anywhere in the spec that say...
jnthn authored
15 my $x = Foo.new(Maybe => No);
ce6a843 [spec] add a simple test that an Enum can act like a role
moritz authored
16
bd78d81 [spec] fixed role tests, jonathan++
moritz authored
17 ok($x.No, 'Can test for enum members set by .new()');
18 ok(!$x.Yes, 'Can test for enum members set by .new()');
19 ok(!$x.Dunno, 'Can test for enum members set by .new()');
20 }
21
22 {
b6696c3 [t/spec] Reviewed an enums test; don't see anywhere in the spec that say...
jnthn authored
23 my $y = Bar.new() does Maybe(Yes);
bd78d81 [spec] fixed role tests, jonathan++
moritz authored
24
b6696c3 [t/spec] Reviewed an enums test; don't see anywhere in the spec that say...
jnthn authored
25 ok(!$y.No, 'Can test for enum members set by does Maybe(Yes)');
26 ok($y.Yes, 'Can test for enum members set by does Maybe(Yes)');
27 ok(!$y.Dunno, 'Can test for enum members set by does Maybe(Yes)');
bd78d81 [spec] fixed role tests, jonathan++
moritz authored
28 }
29
30 {
b6696c3 [t/spec] Reviewed an enums test; don't see anywhere in the spec that say...
jnthn authored
31 my $z = Bar.new() but Maybe(Dunno);
bd78d81 [spec] fixed role tests, jonathan++
moritz authored
32
b6696c3 [t/spec] Reviewed an enums test; don't see anywhere in the spec that say...
jnthn authored
33 ok(!$z.No, 'Can test for enum members set by but Maybe(Dunno)');
34 ok(!$z.Yes, 'Can test for enum members set by but Maybe(Dunno)');
35 ok($z.Dunno, 'Can test for enum members set by but Maybe(Dunno)');
bd78d81 [spec] fixed role tests, jonathan++
moritz authored
36 }
ce6a843 [spec] add a simple test that an Enum can act like a role
moritz authored
37
38
39 # vim: ft=perl6
Something went wrong with that request. Please try again.