<commit_before>#!perl
# Copyright (C) 2007, The Perl Foundation.
# $Id$

use strict;
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
use Parrot::Test tests => 4;

=head1 NAME

t/oo/isa.t - Test OO inheritance

=head1 SYNOPSIS

    % prove t/oo/isa.t

=head1 DESCRIPTION

Tests OO features related to the isa opcode, comparing for inheritance and
composition.

=cut

pir_output_is( <<'CODE', <<'OUT', 'isa by string name' );
.sub main :main
    $P1 = newclass "Foo"
    $S1 = typeof $P1
    say $S1

    $I3 = isa $P1, "Class"
    print $I3
    print "\n"

    $P2 = new $P1

    $S1 = typeof $P2
    say $S1

    $I3 = isa $P2, "Foo"
    print $I3
    print "\n"

    $I3 = isa $P2, "Object"
    print $I3
    print "\n"
.end
CODE
Class
1
Foo
1
1
OUT

pir_output_is( <<'CODE', <<'OUT', 'isa by class object' );
.sub main :main
    .local pmc foo_class
    foo_class = newclass "Foo"
    $S1 = typeof foo_class
    say $S1

    .local pmc class_class
    class_class = get_class "Class"
    $I3 = isa foo_class, class_class
    print $I3
    print "\n"

    $P2 = new foo_class 

    $S1 = typeof $P2
    say $S1

    $I3 = isa $P2, foo_class
    print $I3
    print "\n"

    .local pmc object_class
    object_class = get_class "Object"
    $I3 = isa $P2, object_class
    print $I3
    print "\n"
.end
CODE
Class
1
Foo
1
1
OUT

pir_output_is( <<'CODE', <<'OUT', 'subclass isa by string name' );
.sub main :main
    .local pmc foo_class, bar_class
    foo_class = newclass "Foo"
    bar_class = subclass "Foo", "Bar"

    $I3 = isa bar_class, "Class"
    print $I3
    print "\n"

    $P2 = new bar_class 

    $S1 = typeof $P2
    say $S1

    $I3 = isa $P2, "Bar"
    print $I3
    print "\n"

    $I3 = isa $P2, "Foo"
    print $I3
    print "\n"

    $I3 = isa $P2, "Object"
    print $I3
    print "\n"
.end
CODE
1
Bar
1
1
1
OUT

pir_output_is( <<'CODE', <<'OUT', 'subclass isa by class object' );
.sub main :main
    .local pmc foo_class, bar_class
    foo_class = newclass "Foo"
    bar_class = subclass "Foo", "Bar"

    .local pmc class_class
    class_class = get_class "Class"
    $I3 = isa bar_class, class_class
    print $I3
    print "\n"

    $P2 = new bar_class 

    $S1 = typeof $P2
    say $S1

    $I3 = isa $P2, bar_class
    print $I3
    print "\n"

    $I3 = isa $P2, foo_class
    print $I3
    print "\n"

    .local pmc object_class
    object_class = get_class "Object"
    $I3 = isa $P2, object_class
    print $I3
    print "\n"
.end
CODE
1
Bar
1
1
1
OUT

# Local Variables:
#   mode: cperl
#   cperl-indent-level: 4
#   fill-column: 100
# End:
# vim: expandtab shiftwidth=4:<commit_msg>[oo] Add regression test for RT#42776, string and PMC arguments to 'isa' have the same result..<commit_after>#!perl
# Copyright (C) 2007, The Perl Foundation.
# $Id$

use strict;
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
use Parrot::Test tests => 5;

=head1 NAME

t/oo/isa.t - Test OO inheritance

=head1 SYNOPSIS

    % prove t/oo/isa.t

=head1 DESCRIPTION

Tests OO features related to the isa opcode, comparing for inheritance and
composition.

=cut

pir_output_is( <<'CODE', <<'OUT', 'isa by string name' );
.sub main :main
    $P1 = newclass "Foo"
    $S1 = typeof $P1
    say $S1

    $I3 = isa $P1, "Class"
    print $I3
    print "\n"

    $P2 = new $P1

    $S1 = typeof $P2
    say $S1

    $I3 = isa $P2, "Foo"
    print $I3
    print "\n"

    $I3 = isa $P2, "Object"
    print $I3
    print "\n"
.end
CODE
Class
1
Foo
1
1
OUT

pir_output_is( <<'CODE', <<'OUT', 'isa by class object' );
.sub main :main
    .local pmc foo_class
    foo_class = newclass "Foo"
    $S1 = typeof foo_class
    say $S1

    .local pmc class_class
    class_class = get_class "Class"
    $I3 = isa foo_class, class_class
    print $I3
    print "\n"

    $P2 = new foo_class 

    $S1 = typeof $P2
    say $S1

    $I3 = isa $P2, foo_class
    print $I3
    print "\n"

    .local pmc object_class
    object_class = get_class "Object"
    $I3 = isa $P2, object_class
    print $I3
    print "\n"
.end
CODE
Class
1
Foo
1
1
OUT

pir_output_is( <<'CODE', <<'OUT', 'subclass isa by string name' );
.sub main :main
    .local pmc foo_class, bar_class
    foo_class = newclass "Foo"
    bar_class = subclass "Foo", "Bar"

    $I3 = isa bar_class, "Class"
    print $I3
    print "\n"

    $P2 = new bar_class 

    $S1 = typeof $P2
    say $S1

    $I3 = isa $P2, "Bar"
    print $I3
    print "\n"

    $I3 = isa $P2, "Foo"
    print $I3
    print "\n"

    $I3 = isa $P2, "Object"
    print $I3
    print "\n"
.end
CODE
1
Bar
1
1
1
OUT

pir_output_is( <<'CODE', <<'OUT', 'subclass isa by class object' );
.sub main :main
    .local pmc foo_class, bar_class
    foo_class = newclass "Foo"
    bar_class = subclass "Foo", "Bar"

    .local pmc class_class
    class_class = get_class "Class"
    $I3 = isa bar_class, class_class
    print $I3
    print "\n"

    $P2 = new bar_class 

    $S1 = typeof $P2
    say $S1

    $I3 = isa $P2, bar_class
    print $I3
    print "\n"

    $I3 = isa $P2, foo_class
    print $I3
    print "\n"

    .local pmc object_class
    object_class = get_class "Object"
    $I3 = isa $P2, object_class
    print $I3
    print "\n"
.end
CODE
1
Bar
1
1
1
OUT

pir_output_is( <<'CODE', <<'OUT', 'string isa and pmc isa have same result' );
.sub main
    .local pmc class, obj
    class = new 'Class'
    obj = class.'new'()
    $I0 = isa obj, 'Object'
    print $I0
    print "\n"
    .local pmc cl
    cl = new 'String'
    cl = 'Object'
    $I1 = isa obj, cl
    print $I1
    print "\n"
.end
CODE
1
1
OUT
# Local Variables:
#   mode: cperl
#   cperl-indent-level: 4
#   fill-column: 100
# End:
# vim: expandtab shiftwidth=4:
{'fraction_non_alphanumeric': 0.1294900998773436, 'fraction_numerical': 0.03311722446118801, 'mean_word_length': 2.3205351948807444, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3977936', 'n_tokens_mistral': 2457, 'n_tokens_neox': 2322, 'n_words': 755}