### ----------------------------------------------------
### -- Pod::TreeWalker
### -- Licenses: Artistic-2.0
### -- Authors: Dave Rolsky
### -- File: t/declarators.rakutest
### ----------------------------------------------------
use Test;
use Pod::TreeWalker;
use lib $*PROGRAM.sibling('lib');
use TestListener;

plan 1;

my $pod_i = 0;

#| before class
class Foo {
    has $.foo; #= a foo!
}

subtest {
    my $l = TestListener.new;
    Pod::TreeWalker.new(:listener($l)).walk-pod($=pod[$pod_i++]);

    my @expect = (
         { :start, :type('declarator'), :wherefore(Foo) },
         { :text('before class') },
         { :end, :type('declarator'), :wherefore(Foo) },
    );

    is-deeply $l.events, @expect, 'got expected events for class declarator';

    $l = TestListener.new;
    Pod::TreeWalker.new(:listener($l)).walk-pod($=pod[$pod_i++]);

    # XXX - This WHEREFORE doesn't seem right
    @expect = (
         { :start, :type('declarator'), :wherefore(Any) },
         { :text('a foo!') },
         { :end, :type('declarator'), :wherefore(Any) },
    );

    is-deeply $l.events, @expect, 'got expected events for attribute declarator';
}, 'declarators';

# vim: expandtab shiftwidth=4


