Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 67 lines (51 sloc) 1.734 kB
2e38e94 [gsoc_spectest] tests for is also/instead/open. (added 16 tests)
Auzon authored
1 use v6;
2
db4bde7 [t/spec] add 'use MONKEY_TYPING' where appropriate
lwall authored
3 use MONKEY_TYPING;
4
2e38e94 [gsoc_spectest] tests for is also/instead/open. (added 16 tests)
Auzon authored
5 use Test;
6
16a04d4 [t/spec] s/is also/augment/ in open_closed.t
moritz authored
7 plan 9;
2e38e94 [gsoc_spectest] tests for is also/instead/open. (added 16 tests)
Auzon authored
8
9 # syn r14552
10
11 # L<S12/"Open vs Closed Classes"/"a pragma for selecting global semantics of the underlying object-oriented engine">
12
13 use oo :closed :final;
14
15 class Foo {
16 method a {'called Foo.a'}
17 }
18
16a04d4 [t/spec] s/is also/augment/ in open_closed.t
moritz authored
19 eval_dies_ok('augment class Foo {method b {"called Foo.b"}}}', 'adding to closed class dies');
2e38e94 [gsoc_spectest] tests for is also/instead/open. (added 16 tests)
Auzon authored
20
21 class Bar is open {
22 method c {'called Bar.c'}
23 }
16a04d4 [t/spec] s/is also/augment/ in open_closed.t
moritz authored
24 augment class Bar {
25 method d {'called Bar.d'}
26 }
68cb939 [t/spec] open_closed.t missing {
lwall authored
27
28 {
2e38e94 [gsoc_spectest] tests for is also/instead/open. (added 16 tests)
Auzon authored
29 my $o = Bar.new;
30 is($o.c, 'called Bar.c', 'old method is still present');
31 is($o.d, 'called Bar.d', 'new method is also present');
32 }
33
34 {
35 # S12 gives the example of 'use class :open' as well as 'use oo :closed'
36 # this seems weird to me.
37 use class :open;
38 class Baz {method e {'called Baz.e'}}
16a04d4 [t/spec] s/is also/augment/ in open_closed.t
moritz authored
39 augment class Baz {
40 method f {'called Baz.f'}
41 }
2e38e94 [gsoc_spectest] tests for is also/instead/open. (added 16 tests)
Auzon authored
42
43 my $o = Baz.new;
44 is($o.e, 'called Baz.e', 'old method is still present');
45 is($o.f, 'called Baz.f', 'new method is present as well');
46 }
47
48 # L<S12/"Open vs Closed Classes"/"or by lexically scoped pragma around the class definition">
49 # and just when you thought I ran out of generic identifiers
50 use class :open<Qux>;
51 class Qux {method g {'called Qux.g'}}
52 {
16a04d4 [t/spec] s/is also/augment/ in open_closed.t
moritz authored
53 augment class Qux {
54 method h {'called Qux.i'}
55 }
2e38e94 [gsoc_spectest] tests for is also/instead/open. (added 16 tests)
Auzon authored
56 my $o = Qux.new;
57 is($o.g, 'called Qux.g', 'old is still present');
58 is($o.h, 'called Qux.h', 'new method is present as well');
59 }
60
61 # L<S12/"Open vs Closed Classes"/"declaring individual classes closed or final">
62 # try a few things that come to mind to make sure it's not lurking
63 eval_dies_ok('class ClosedAlpha is closed {}', '"is closed" is not implemented');
64 eval_dies_ok('class ClosedBeta is final {}', '"is final" is not implemented');
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
65
66 # vim: ft=perl6
Something went wrong with that request. Please try again.