File tree 3 files changed +57
-0
lines changed
3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 22
22
##### [ Line ending] ( /v510/line-ending.pl )
23
23
##### [ Delete hash] ( /v510/delete-hash.pl )
24
24
##### [ Defined-or] ( /v510/defined-or.pl )
25
+ ##### [ Method Resolution Order (dfs)] ( /v510/mro-dfs.pl )
26
+ ##### [ Method Resolution Order (c3)] ( /v510/mro-c3.pl )
25
27
26
28
## Perl v5.12
27
29
##### [ Each array] ( /v512/each-array.pl )
Original file line number Diff line number Diff line change
1
+ # !/usr/bin/perl
2
+
3
+ package ROOT { sub new {} }
4
+ package P12 { use base qw( ROOT) }
5
+ package P11 { use base qw( P12) }
6
+ package P22 { use base qw( ROOT) }
7
+ package P21 { use base qw( P22) }
8
+ package P1 { use base qw( P11 P21) }
9
+ package P2 { use base qw( P21 P11) }
10
+
11
+ package main {
12
+ use strict; use warnings;
13
+
14
+ use mro;
15
+ use v5.10;
16
+ use Test::More;;
17
+
18
+ # method resolution order (dfs)
19
+ is_deeply mro::get_linear_isa(' P1' ),
20
+ [qw( P1 P11 P12 ROOT P21 P22) ];
21
+
22
+ is_deeply mro::get_linear_isa(' P2' ),
23
+ [qw( P2 P21 P22 ROOT P11 P12) ];
24
+
25
+ # method resolution order (c3)
26
+ is_deeply mro::get_linear_isa(' P1' , ' c3' ),
27
+ [qw( P1 P11 P12 P21 P22 ROOT) ];
28
+
29
+ is_deeply mro::get_linear_isa(' P2' , ' c3' ),
30
+ [qw( P2 P21 P22 P11 P12 ROOT) ];
31
+
32
+ done_testing;
33
+ }
Original file line number Diff line number Diff line change
1
+ # !/usr/bin/perl
2
+
3
+ package P12 { sub new {} }
4
+ package P11 { use base qw( P12) }
5
+ package P22 { sub new {} }
6
+ package P21 { use base qw( P22) }
7
+ package P1 { use base qw( P11 P21) }
8
+ package P2 { use base qw( P21 P11) }
9
+
10
+ package main {
11
+ use strict; use warnings;
12
+
13
+ use mro;
14
+ use v5.10;
15
+ use Test::More;;
16
+
17
+ # method resolution order (dfs)
18
+ is_deeply mro::get_linear_isa(' P1' ), [qw( P1 P11 P12 P21 P22) ];
19
+ is_deeply mro::get_linear_isa(' P2' ), [qw( P2 P21 P22 P11 P12) ];
20
+
21
+ done_testing;
22
+ }
You can’t perform that action at this time.
0 commit comments