| 1 | use v6; |
|---|
| 2 | |
|---|
| 3 | use Test; |
|---|
| 4 | |
|---|
| 5 | plan 11; |
|---|
| 6 | |
|---|
| 7 | =begin pod |
|---|
| 8 | |
|---|
| 9 | Very basic meta-class tests from L<S12/Introspection> |
|---|
| 10 | |
|---|
| 11 | =end pod |
|---|
| 12 | |
|---|
| 13 | class Foo:ver<0.0.1> { method bar ($param) returns Str { return "baz" ~ $param } }; |
|---|
| 14 | |
|---|
| 15 | # L<S12/Introspection/should be called through the meta object> |
|---|
| 16 | |
|---|
| 17 | ok(eval("Foo.HOW.can('bar')"), '... Foo can bar', :todo<feature>); |
|---|
| 18 | ok(eval("Foo.^can('bar')"), '... Foo can bar (as class method)', :todo<feature>); |
|---|
| 19 | ok(eval("Foo.HOW.isa(Foo)"), '... Foo is-a Foo (of course)', :todo<bug>); |
|---|
| 20 | ok(eval("Foo.^isa(Foo)"), '... Foo is-a Foo (of course) (as class method)', :todo<bug>); |
|---|
| 21 | |
|---|
| 22 | # L<S12/Introspection/Class traits may include:> |
|---|
| 23 | |
|---|
| 24 | ok(eval("Foo.HOW.name() eq 'Foo'"), '... the name() property is Foo'); |
|---|
| 25 | ok(eval("Foo.HOW.version() == 0.0.1"), '... the version() property is 0.0.1', :todo<feature>); |
|---|
| 26 | ok(eval("(Foo.HOW.isa())[0] ~~ Foo"), '... the isa() property returns Foo as the first parent class', :todo<feature>); |
|---|
| 27 | |
|---|
| 28 | # L<S12/Introspection/"get the method list of MyClass"> |
|---|
| 29 | |
|---|
| 30 | # NOTE: I am guessing on some of this here, but it's a start for now |
|---|
| 31 | |
|---|
| 32 | my @methods = eval 'Foo.HOW.methods()'; |
|---|
| 33 | is(eval("@methods[0].name eq 'bar'"), '... our first method is foo()', :todo<feature>); |
|---|
| 34 | is(eval("@methods[0].signature eq '\$param'"), '... our first methods signature is $param', :todo<feature>); |
|---|
| 35 | is(eval("@methods[0].returns ~~ Str"), '... our first method returns a Str', :todo<feature>); |
|---|
| 36 | ok(eval("!@methods[0].multi"), '... our first method is not a multimethod', :todo<feature>); |
|---|