<commit_before>use v6;
use Test;

plan 28;

class Parent {
    has $.x;
}

class Child is Parent {
    has $.y;
}

my $o;
lives-ok { $o =  Child.new(:x(2), :y(3)) }, 
         'can instantiate class with parent attributes';

is $o.y, 3, '... worked for the child';
is $o.x, 2, '... worked for the parent';

# https://github.com/Raku/old-issue-tracker/issues/2236
#?rakudo 3 skip 'parent attributes in initialization
lives-ok { $o = Child.new( :y(4), Parent{ :x<5> }) }, 
         'can instantiate class with explicit specification of parent attrib';

is $o.y, 4, '... worked for the child';
is $o.x, 5, '... worked for the parent';

class GrandChild is Child {
}

# https://github.com/Raku/old-issue-tracker/issues/2236
#?rakudo 6 skip 'parent attributes in initialization
lives-ok { $o = GrandChild.new( Child{ :y(4) }, Parent{ :x<5> }) },
         'can instantiate class with explicit specification of parent attrib (many parents)';
is $o.y, 4, '... worked for the class Child';
is $o.x, 5, '... worked for the class Parent';
lives-ok { $o = GrandChild.new( Parent{ :x<5> }, Child{ :y(4) }) }, 
         'can instantiate class with explicit specification of parent attrib (many parents, other order)';
is $o.y, 4, '... worked for the class Child (other order)';
is $o.x, 5, '... worked for the class Parent (other order)';

# https://github.com/Raku/old-issue-tracker/issues/1030
{
    class RT66204 {}
    ok ! RT66204.defined, 'NewClass is not .defined';
    dies-ok { RT66204 .= new }, 'class asked to build itself refuses';
    ok ! RT66204.defined, 'NewClass is still not .defined';
}

# https://github.com/Raku/old-issue-tracker/issues/1460
{
    class RT71706 {
        class RT71706::Artie {}
    }
    # TODO: check the error message, not just the timing.
    #?rakudo todo "nested package handling does't quite get this one right"
    dies-ok { RT71706::Artie.new }, 'die trying to instantiate missing class';
}

# https://github.com/Raku/old-issue-tracker/issues/1353
{
    class NewFromMu {<commit_msg>Oops, accidentally lost closing quotes in skip<commit_after>use v6;
use Test;

plan 28;

class Parent {
    has $.x;
}

class Child is Parent {
    has $.y;
}

my $o;
lives-ok { $o =  Child.new(:x(2), :y(3)) }, 
         'can instantiate class with parent attributes';

is $o.y, 3, '... worked for the child';
is $o.x, 2, '... worked for the parent';

# https://github.com/Raku/old-issue-tracker/issues/2236
#?rakudo 3 skip 'parent attributes in initialization'
lives-ok { $o = Child.new( :y(4), Parent{ :x<5> }) }, 
         'can instantiate class with explicit specification of parent attrib';

is $o.y, 4, '... worked for the child';
is $o.x, 5, '... worked for the parent';

class GrandChild is Child {
}

# https://github.com/Raku/old-issue-tracker/issues/2236
#?rakudo 6 skip 'parent attributes in initialization'
lives-ok { $o = GrandChild.new( Child{ :y(4) }, Parent{ :x<5> }) },
         'can instantiate class with explicit specification of parent attrib (many parents)';
is $o.y, 4, '... worked for the class Child';
is $o.x, 5, '... worked for the class Parent';
lives-ok { $o = GrandChild.new( Parent{ :x<5> }, Child{ :y(4) }) }, 
         'can instantiate class with explicit specification of parent attrib (many parents, other order)';
is $o.y, 4, '... worked for the class Child (other order)';
is $o.x, 5, '... worked for the class Parent (other order)';

# https://github.com/Raku/old-issue-tracker/issues/1030
{
    class RT66204 {}
    ok ! RT66204.defined, 'NewClass is not .defined';
    dies-ok { RT66204 .= new }, 'class asked to build itself refuses';
    ok ! RT66204.defined, 'NewClass is still not .defined';
}

# https://github.com/Raku/old-issue-tracker/issues/1460
{
    class RT71706 {
        class RT71706::Artie {}
    }
    # TODO: check the error message, not just the timing.
    #?rakudo todo "nested package handling does't quite get this one right"
    dies-ok { RT71706::Artie.new }, 'die trying to instantiate missing class';
}

# https://github.com/Raku/old-issue-tracker/issues/1353
{
    class NewFromMu {
{'fraction_non_alphanumeric': 0.15416769117285467, 'fraction_numerical': 0.03737398573887386, 'mean_word_length': 3.1808838643371016, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 10, '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': '6473538', 'n_tokens_mistral': 1499, 'n_tokens_neox': 1380, 'n_words': 458}