<commit_before>use v6;

use Test;

=begin pod

    access or assign on undeclared attribute will raise an error.

=end pod

plan 12;


dies_ok { class A { method set_a { $.a = 1 }}; A.new.set_a; },
    "Test Undeclared public attribute assignment from a class";
dies_ok { role B { method set_b { $.b = 1 }};class C does B{ }; C.new.set_b; },
    "Test Undeclared public attribute assignment from a role";

#?pugs 2 todo 'bug'
dies_ok { class D { method d { $!d = 1 }}; D.new.d; },
    "Test Undeclared private attribute assignment from a class";
dies_ok { role E { method e { $!e = 1 }};class F does E{ }; F.new.e; },
    "Test Undeclared private attribute assignment from a role";

##### access the undeclared attribute
dies_ok { class H { method set_h { $.h }}; H.new.set_h; },
    "Test Undeclared public attribute access from a class";
dies_ok { role I { method set_i { $.i }};class J does I{ }; J.new.set_i; },
    "Test Undeclared public attribute access from a role";

#?pugs 2 todo 'bug'
dies_ok { class K { method k { $!k }}; K.new.k; },
    "Test Undeclared private attribute access from a class";
dies_ok { role L { method l { $!l }};class M does L{ }; M.new.l; },
    "Test Undeclared private attribute access from a role";


dies_ok { class N { method set_n { $.n := 1 }}; N.new.set_n; },
    "Test Undeclared public attribute binding from a class";
dies_ok { role O { method set_o { $.o := 1 }}; class P does O{ }; P.new.set_o },
    "Test Undeclared public attribute binding from a role";

## skip class 'Q' here to avoid quote operator conflict.

dies_ok { role R { method r { $!r := 1 }};class S does R{ }; S.new.r; },
    "Test Undeclared private attribute binding from a role";
dies_ok { class T { method t { $!t := 1 }}; ::T.new.t; },
    "Test Undeclared private attribute binding from a class";


# vim: ft=perl6<commit_msg>Update S12-attributes/undeclared.t to handle compilers that can detect undeclared attributes at compile time; remove two tests that are invalid.<commit_after>use v6;

use Test;

=begin pod

    access or assign on undeclared attribute will raise an error.

=end pod

plan 10;


dies_ok { class A { method set_a { $.a = 1 }}; A.new.set_a; },
    "Test Undeclared public attribute assignment from a class";
dies_ok { role B { method set_b { $.b = 1 }};class C does B{ }; C.new.set_b; },
    "Test Undeclared public attribute assignment from a role";

#?pugs 2 todo 'bug'
eval_dies_ok ' class D { method d { $!d = 1 }}; D.new.d; ',
    "Test Undeclared private attribute assignment from a class";
eval_dies_ok ' role E { method e { $!e = 1 }};class F does E{ }; F.new.e; ',
    "Test Undeclared private attribute assignment from a role";

##### access the undeclared attribute
dies_ok { class H { method set_h { $.h }}; H.new.set_h; },
    "Test Undeclared public attribute access from a class";
dies_ok { role I { method set_i { $.i }};class J does I{ }; J.new.set_i; },
    "Test Undeclared public attribute access from a role";

#?pugs 2 todo 'bug'
eval_dies_ok ' class K { method k { $!k }}; K.new.k; ',
    "Test Undeclared private attribute access from a class";
eval_dies_ok ' role L { method l { $!l }};class M does L{ }; M.new.l; ',
    "Test Undeclared private attribute access from a role";

## skip class 'Q' here to avoid quote operator conflict.

eval_dies_ok ' role R { method r { $!r := 1 }};class S does R{ }; S.new.r; ',
    "Test Undeclared private attribute binding from a role";
eval_dies_ok ' class T { method t { $!t := 1 }}; ::T.new.t; ',
    "Test Undeclared private attribute binding from a class";

# vim: ft=perl6
{'fraction_non_alphanumeric': 0.13197544642857142, 'fraction_numerical': 0.0078125, 'mean_word_length': 3.431396786155748, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2731307', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1193, 'n_words': 491}