root/t/oo/meta_class.t

Revision 24120, 1.4 kB (checked in by moritz, 6 weeks ago)

[t] some test and smartlink fixes

  • Property svn:mime-type set to text/plain; charset=UTF-8
  • Property svn:eol-style set to native
Line 
1use v6;
2
3use Test;
4
5plan 11;
6
7=begin pod
8
9Very basic meta-class tests from L<S12/Introspection>
10
11=end pod
12
13class 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
17ok(eval("Foo.HOW.can('bar')"), '... Foo can bar', :todo<feature>);
18ok(eval("Foo.^can('bar')"), '... Foo can bar (as class method)', :todo<feature>);
19ok(eval("Foo.HOW.isa(Foo)"), '... Foo is-a Foo (of course)', :todo<bug>);
20ok(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
24ok(eval("Foo.HOW.name() eq 'Foo'"), '... the name() property is Foo');
25ok(eval("Foo.HOW.version() == 0.0.1"), '... the version() property is 0.0.1', :todo<feature>);
26ok(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
32my @methods = eval 'Foo.HOW.methods()';
33is(eval("@methods[0].name eq 'bar'"), '... our first method is foo()', :todo<feature>);
34is(eval("@methods[0].signature eq '\$param'"), '... our first methods signature is $param', :todo<feature>);
35is(eval("@methods[0].returns ~~ Str"), '... our first method returns a Str', :todo<feature>);
36ok(eval("!@methods[0].multi"), '... our first method is not a multimethod', :todo<feature>);
Note: See TracBrowser for help on using the browser.