summaryrefslogtreecommitdiff
path: root/t/class/phasers.t
blob: 59ebbeee38e1445cb7346c5c2e84863de6538c51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!./perl

BEGIN {
    chdir 't' if -d 't';
    require './test.pl';
    set_up_inc('../lib');
    require Config;
}

use v5.36;
use feature 'class';
no warnings 'experimental::class';

# ADJUST
{
    my $adjusted;

    class Test1 {
        ADJUST { $adjusted .= "a" }
        ADJUST { $adjusted .= "b" }
    }

    Test1->new;
    is($adjusted, "ab", 'both ADJUST blocks run in order');
}

# $self in ADJUST
{
    my $self_in_ADJUST;

    class Test2 {
        ADJUST { $self_in_ADJUST = $self; }
    }

    my $obj = Test2->new;
    is($self_in_ADJUST, $obj, '$self is set correctly inside ADJUST blocks');
}

done_testing;