Skip to content

Commit

Permalink
Can bind to native type attributes in build methods
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed Dec 12, 2017
1 parent c9d4633 commit a894326
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion S12-construction/named-params-in-BUILD.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 3;
plan 4;
# L<S12/Semantics of C<bless>/The default BUILD and BUILDALL>

class Foo {
Expand All @@ -20,4 +20,24 @@ is( $obj.v, 'bar',
isa-ok($obj.v, Str, 'same arg should be of declared type' );
isa-ok($obj, Foo, 'The object was constructed of the right type');

subtest 'can bind to native type attributes in build methods' => {
plan 4;

my class RT127845 {
has num32 $.a;
has num $.b;
has uint8 $.x;
has int $.y;
submethod BUILD(uint8 :$!x, :$!b) { }
submethod TWEAK(num32 :$!a, :$!y) { }
}

my $o := RT127845.new: :a(2e0), :b(3e-1), :5x, :6y;

is-deeply $o.x, 5, 'can bind to native type attributes in signature of BUILD (1)';
is-deeply $o.b, 3e-1, 'can bind to native type attributes in signature of BUILD (2)';
is-deeply $o.y, 6, 'can bind to native type attributes in signature of TWEAK (1)';
is-deeply $o.a, 2e0, 'can bind to native type attributes in signature of TWEAK (2)';
}

# vim: ft=perl6

0 comments on commit a894326

Please sign in to comment.