|
Revision 24093, 1.1 kB
(checked in by moritz, 6 weeks ago)
|
|
[t] split oo/meths/multi.t into t/spec/S12-methods/multi2.t and
t/unspecced/yaml-eval.t
|
-
Property svn:mime-type set to
text/plain
|
| Line | |
|---|
| 1 | use Test; |
|---|
| 2 | |
|---|
| 3 | plan 5; |
|---|
| 4 | |
|---|
| 5 | my $yaml_tests = eval(q{ |
|---|
| 6 | - |
|---|
| 7 | m2: %h |
|---|
| 8 | call: "{a => 'b'}" |
|---|
| 9 | expect: 2 |
|---|
| 10 | - |
|---|
| 11 | m1: %h |
|---|
| 12 | m2: @a? |
|---|
| 13 | call: "[1,2,3]" |
|---|
| 14 | expect: 2 |
|---|
| 15 | - |
|---|
| 16 | m1: @a? |
|---|
| 17 | expect: 2 |
|---|
| 18 | - |
|---|
| 19 | m1: %h |
|---|
| 20 | m2: @a |
|---|
| 21 | call: "[1,2,3]" |
|---|
| 22 | expect: 2 |
|---|
| 23 | - |
|---|
| 24 | m1: |
|---|
| 25 | m2: @a? |
|---|
| 26 | call: "[1,2,3]" |
|---|
| 27 | expect: 2 |
|---|
| 28 | |
|---|
| 29 | }, :lang<yaml>); |
|---|
| 30 | |
|---|
| 31 | for each($yaml_tests) -> %h { |
|---|
| 32 | # I think Perl6 is supposed to offer us a way to just |
|---|
| 33 | # pass %h on through... |
|---|
| 34 | test_dispatch( |
|---|
| 35 | m1 => %h<m1>, |
|---|
| 36 | m2 => %h<m2>, |
|---|
| 37 | call => %h<call>, |
|---|
| 38 | expect => %h<expect>, |
|---|
| 39 | ); |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | sub test_dispatch ( |
|---|
| 43 | Str $m1, |
|---|
| 44 | Str $m2, |
|---|
| 45 | Str $call, |
|---|
| 46 | Int $expect, |
|---|
| 47 | ) { |
|---|
| 48 | |
|---|
| 49 | state $cls = 'Foo000'; |
|---|
| 50 | $cls++; |
|---|
| 51 | |
|---|
| 52 | my $got = eval qq/ |
|---|
| 53 | class $cls \{ |
|---|
| 54 | multi method a ($m1) \{1\} |
|---|
| 55 | multi method a ($m2) \{2\} |
|---|
| 56 | \}; |
|---|
| 57 | {$cls}.a($call); |
|---|
| 58 | /; |
|---|
| 59 | |
|---|
| 60 | if defined $got { |
|---|
| 61 | is($got , $expect, "Arguments ($call) to signatures 1. ($m1) and 2. ($m2) calls $expect"); |
|---|
| 62 | } |
|---|
| 63 | else { |
|---|
| 64 | ok(0, "Failed to compile test! error was was: $!" ) |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | } |
|---|