### ----------------------------------------------------
### -- PrettyDump
### -- Licenses: Artistic-2.0
### -- Authors: brian d foy, Raku Community
### -- File: t/03.ChildTypes.rakutest
### ----------------------------------------------------
use Test;
use PrettyDump;

plan 6;

my $p = PrettyDump.new;

class TinyClass is Hash {}

my $tiny-class-str = 'TinyClass';
my $tiny-class = ::($tiny-class-str);

my $parent-class-str = 'Hash';
my $parent-class = ::($parent-class-str);

is PrettyDump.can( $tiny-class-str ).elems, 0, "PrettyDump does not handle $tiny-class-str";
isa-ok $tiny-class, $parent-class-str;
is PrettyDump.can( $parent-class-str ).Bool, True, "PrettyDump handles $parent-class-str";

can-ok $tiny-class, 'can';
is $tiny-class.can( 'PrettyDump' ).elems, 0, "$tiny-class-str does not do .PrettyDump";

subtest 'Object that inherits from Hash' => {
	my $object = $tiny-class.new:  'abc', '123', 'xyz', 'def';
	isa-ok $object, $tiny-class;
	isa-ok $object, $parent-class;

	my $string = $p.dump: $object;
	isa-ok $string, Str, 'Got Str back';
	my $expected = qq/{$tiny-class-str}=(\n\t:abc("123"),\n\t:xyz("def")\n)/;

	is $string, $expected, 'Dumping $object returns expected string';
}

# vim: expandtab shiftwidth=4


