### ----------------------------------------------------
### -- UML::Translators
### -- Licenses: Artistic-2.0
### -- Authors: Anton Antonov
### -- File: t/01-over-classes.rakutest
### ----------------------------------------------------
use v6.d;
use Test;

use UML::Translators;

module MyPackageClass {
    role A { method a1 {} }
    role B { method b1 {} }
    class C does A { has $!c-var; method c1 {} }
    class D does B is C { has $!d-var; method d1 {} }
}

plan 7;

# 1
isa-ok to-plant-uml-spec('MyPackageClass'), Str, 'to-plant-uml-spec call';;

# 2
isa-ok to-wl-uml-spec('MyPackageClass'), Str, 'to-wl-uml-spec call';;

# 3
isa-ok to-uml-spec('MyPackageClass'), Str, 'to-uml-spec call';

# 4
my $spec4 = to-plant-uml-spec('MyPackageClass').subst(:g, / \h+ /, '');

my @parentRules = (
'MyPackageClass::C --|> MyPackageClass::A',
'MyPackageClass::D --|> MyPackageClass::C',
'MyPackageClass::D --|> MyPackageClass::A',
'MyPackageClass::D --|> MyPackageClass::B'
);

my $res4 = [&&] @parentRules.map({ $spec4.contains($_.subst(:g, / \h+ /, '')) }).List;

is $res4, True, 'Expected relationships';

# 5
isa-ok to-uml-spec('MyPackageClass'):remove-unlinked,
        Str,
        'to-uml-spec call with :remove-unlinked';

# 6
isa-ok to-uml-spec('MyPackageClass', remove=><D>),
        Str,
        'to-uml-spec call with remove=><D>';

# 7
is to-uml-spec('MyPackageClass', remove=><D>).contains('remove D'),
        True,
        'to-uml-spec call with remove=><D> has "remove D"';

done-testing;


