Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 58 lines (47 sloc) 1.985 kb
193c892 [t/spec] Rename S14-traits/basic.t to variables.t to better indicate tha...
jnthn authored
1 use v6;
2 use Test;
3
60cabaf @jnthn Correct routine trait test (which didn't even parse!) and todo one test ...
jnthn authored
4 plan(10);
193c892 [t/spec] Rename S14-traits/basic.t to variables.t to better indicate tha...
jnthn authored
5
6 # L<S14/Traits/>
3f79756 @moritz port a few trait tests to the new spec
moritz authored
7 {
8 role description {
9 has $.description is rw;
10 }
193c892 [t/spec] Rename S14-traits/basic.t to variables.t to better indicate tha...
jnthn authored
11
60cabaf @jnthn Correct routine trait test (which didn't even parse!) and todo one test ...
jnthn authored
12 multi trait_mod:<is>(Routine $code, description, $arg) {
3f79756 @moritz port a few trait tests to the new spec
moritz authored
13 $code does description($arg);
14 }
60cabaf @jnthn Correct routine trait test (which didn't even parse!) and todo one test ...
jnthn authored
15 multi trait_mod:<is>(Routine $code, description) {
3f79756 @moritz port a few trait tests to the new spec
moritz authored
16 $code does description("missing description!");
17 }
18 multi trait_mod:<is>(Routine $code, $arg, :$described!) {
19 $code does description($arg);
20 }
21 multi trait_mod:<is>(Routine $code, :$described!) {
22 $code does description("missing description!");
23 }
193c892 [t/spec] Rename S14-traits/basic.t to variables.t to better indicate tha...
jnthn authored
24
25
3f79756 @moritz port a few trait tests to the new spec
moritz authored
26 sub answer() is description('computes the answer') { 42 }
27 sub faildoc() is description { "fail" }
28 is answer(), 42, 'can call sub that has had a trait applied to it by role name with arg';
29 is &answer.description, 'computes the answer', 'description role applied and set with argument';
30 is faildoc(), "fail", 'can call sub that has had a trait applied to it by role name without arg';
31 is &faildoc.description, 'missing description!', 'description role applied without argument';
193c892 [t/spec] Rename S14-traits/basic.t to variables.t to better indicate tha...
jnthn authored
32
3f79756 @moritz port a few trait tests to the new spec
moritz authored
33 sub cheezburger is described("tasty") { "nom" }
34 sub lolcat is described { "undescribable" }
193c892 [t/spec] Rename S14-traits/basic.t to variables.t to better indicate tha...
jnthn authored
35
3f79756 @moritz port a few trait tests to the new spec
moritz authored
36 is cheezburger(), "nom", 'can call sub that has had a trait applied to it by named param with arg';
37 is &cheezburger.description, 'tasty', 'named trait handler applied other role set with argument';
38 is lolcat(), "undescribable", 'can call sub that has had a trait applied to it by named param without arg';
39 is &lolcat.description, 'missing description!', 'named trait handler applied other role without argument';
40 }
193c892 [t/spec] Rename S14-traits/basic.t to variables.t to better indicate tha...
jnthn authored
41
65aa5bd [t/spec] Tests for RT #69893, wrapping subroutines in traits
moritz authored
42 {
43 my $recorder = '';
3f79756 @moritz port a few trait tests to the new spec
moritz authored
44 multi trait_mod:<is>(Routine $c, :$woowoo!) {
65aa5bd [t/spec] Tests for RT #69893, wrapping subroutines in traits
moritz authored
45 $c.wrap: sub {
46 $recorder ~= 'wrap';
47 }
48 }
49 sub foo is woowoo { };
50 lives_ok &foo, 'Can call subroutine that was wrapped by a trait';
60cabaf @jnthn Correct routine trait test (which didn't even parse!) and todo one test ...
jnthn authored
51 #?rakudo todo 'trait mod / .wrap interaction'
65aa5bd [t/spec] Tests for RT #69893, wrapping subroutines in traits
moritz authored
52 is $recorder, 'wrap', 'and the wrapper has been called once';
53 }
54
e76dd4c @moritz s/done_testing/done/ as per recent S24 changes
moritz authored
55 done();
65aa5bd [t/spec] Tests for RT #69893, wrapping subroutines in traits
moritz authored
56
193c892 [t/spec] Rename S14-traits/basic.t to variables.t to better indicate tha...
jnthn authored
57 # vim: ft=perl6
Something went wrong with that request. Please try again.