Help language development. Donate to The Perl Foundation

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

t/07-obj-no-postfix.t
#!/usr/bin/env perl6

use Test;
use Data::Dump;

plan 3;

class E {
  has $.public;
  has Int $!private = 5;
  has Str $!private2 = 'hello';

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

my $out = Dump(E.new, :color(False), :no-postfix);

# Autogenerated method BUILDALL is listed starting with Rakudo 2017.10
my $expected = "E :: (\n  \$!private => 5,\n  \$!private2 => \"hello\",\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)";

Dump(E.new).say;

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