Help language development. Donate to The Perl Foundation

Data::Dump zef:tony-o last updated on 2021-09-03

#!/usr/bin/env perl6

use Test;
use Data::Dump;

plan 3;

class E {
  has $.public;
  has Int $!private = 5;

  method r(Str $a) { };
  method s($b, :$named? = 5) { };
  method e returns Int { say $!private; };
  method !p(Int $x) { };

my $out = Dump(, :color(False));

# Autogenerated method BUILDALL is listed starting with Rakudo 2017.10
my $expected = "E :: (\n  \$!private => 5.Int,\n  \$!public => (Nil),\n\n  method e () returns Int \{...},\n  method public () returns Mu \{...},\n  method r (Str \$a) returns Mu \{...},\n  method s (\$b, :\$named = 5) returns Mu \{...},\n)";

ok $out eq $expected, "got expected data structure" or die $out;

is Dump(Mu), '(Mu)', 'Can dump an undefined Mu type object';
is Dump(Nil), '(Nil)', 'Can dump an undefined Any type object';;

# vi:syntax=perl6