Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /usr/share/doc/perl-Algorithm-C3/t/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/doc/perl-Algorithm-C3/t/004_merge.t
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 2;

BEGIN {
    use_ok('Algorithm::C3');
}

=pod

example taken from: L<http://gauss.gwydiondylan.org/books/drm/drm_50.html>

         Object
           ^
           |
        LifeForm 
         ^    ^
        /      \
   Sentient    BiPedal
      ^          ^
      |          |
 Intelligent  Humanoid
       ^        ^
        \      /
         Vulcan

 define class <sentient> (<life-form>) end class;
 define class <bipedal> (<life-form>) end class;
 define class <intelligent> (<sentient>) end class;
 define class <humanoid> (<bipedal>) end class;
 define class <vulcan> (<intelligent>, <humanoid>) end class;

=cut

{
    package Object;    
    
    sub my_ISA {
        no strict 'refs';
        @{$_[0] . '::ISA'};
    }    
    
    package LifeForm;
    use base 'Object';
    
    package Sentient;
    use base 'LifeForm';
    
    package BiPedal;
    use base 'LifeForm';
    
    package Intelligent;
    use base 'Sentient';
    
    package Humanoid;
    use base 'BiPedal';
    
    package Vulcan;
    use base ('Intelligent', 'Humanoid');
}

is_deeply(
    [ Algorithm::C3::merge('Vulcan', 'my_ISA') ],
    [ qw(Vulcan Intelligent Sentient Humanoid BiPedal LifeForm Object) ],
    '... got the right C3 merge order for the Vulcan Dylan Example');

Hry