Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fudge for niecza.
  • Loading branch information
colomon committed Dec 21, 2011
1 parent 024f20c commit 4bc3e06
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion S12-attributes/instance.t
Expand Up @@ -38,6 +38,7 @@ class Foo1 { has $.bar; };
ok($foo.can("bar"), '.. checking autogenerated accessor existence');
is($foo.bar(), "baz", '.. autogenerated accessor works');
is($foo.bar, "baz", '.. autogenerated accessor works w/out parens');
#?niecza todo
dies_ok { $foo.bar = 'blubb' }, 'attributes are ro by default';
}

Expand Down Expand Up @@ -107,6 +108,7 @@ class Foo1 { has $.bar; };
is($foo.legs.[1], 2, "getting a public ro attribute (1)");

#?rakudo 2 todo 'ro on list attributes'
#?niecza 2 todo 'ro on list attributes'
dies_ok {
$foo.legs = (4,5,6);
}, "setting a public ro attribute (2)";
Expand All @@ -122,7 +124,7 @@ class Foo1 { has $.bar; };

# L<S12/Semantics of C<bless>/If you name an attribute as a parameter, that attribute is initialized directly, so>


#?niecza skip "Unhandled parameter twigil !"
{
class Foo6 {
has $.bar is rw;
Expand All @@ -143,6 +145,7 @@ class Foo1 { has $.bar; };

# check that doing something in submethod BUILD works

#?niecza skip "Unhandled parameter twigil !"
{
class Foo6a {
has $.bar is rw;
Expand All @@ -164,6 +167,7 @@ class Foo1 { has $.bar; };
}

# check that assignment in submethod BUILD works with a bare return, too
#?niecza skip "Unhandled parameter twigil !"
{
class Foo6b {
has $.bar is rw;
Expand Down Expand Up @@ -197,6 +201,7 @@ is Foo7e.new.attr, 42, "default attribute value (1)";
}

# check that doing something in submethod BUILD works
#?niecza skip "Unhandled parameter twigil !"
{
class Foo7 {
has $.bar is rw;
Expand Down Expand Up @@ -241,6 +246,7 @@ is Foo7e.new.attr, 42, "default attribute value (1)";

# check mixture of positional/named args to BUILD

#?niecza skip 'Virtual call $.a may not be used on partially constructed object'
{
class Foo9 {
has $.a;
Expand Down Expand Up @@ -295,6 +301,7 @@ is Foo7e.new.attr, 42, "default attribute value (1)";
}

#?rakudo skip 'self closure'
#?niecza skip 'self closure'
{
class ClosureWithself {
has $.cl = { self.foo }
Expand All @@ -305,6 +312,7 @@ is Foo7e.new.attr, 42, "default attribute value (1)";


# Tests for clone.
#?niecza skip "Unable to resolve method clone in class CloneTest"
{
class CloneTest { has $.x is rw; has $.y is rw; }
my $a = CloneTest.new(x => 1, y => 2);
Expand Down Expand Up @@ -367,6 +375,7 @@ is Foo7e.new.attr, 42, "default attribute value (1)";
# http://groups.google.com/group/perl.perl6.language/browse_thread/thread/2bc6dfd8492b87a4/9189d19e30198ebe?pli=1
# on why these should fail.
#?rakudo 2 todo 'ro array/hash with accessor'
#?niecza 2 todo 'ro array/hash with accessor'
dies_ok { $x.set_array1 }, 'can not assign to @.array attribute';
dies_ok { $x.set_hash1 }, 'can not assign to %.hash attribute';
lives_ok { $x.set_array2 }, 'can assign to @!array attribute';
Expand All @@ -375,6 +384,7 @@ is Foo7e.new.attr, 42, "default attribute value (1)";

# test that whitespaces after 'has (' are allowed.
# This used to be a Rakudo bug (RT #61914)
#?niecza skip 'Unhandled parameter twigil .'
{
class AttribWsTest {
has ( $.this,
Expand Down Expand Up @@ -453,6 +463,7 @@ is Foo7e.new.attr, 42, "default attribute value (1)";
is $o.phc, 0, 'typed private hash attribute is empty';

#?rakudo todo 'typed arrays'
#?niecza skip "Unable to resolve method of in class Array"
ok $o.a.of === Int, 'array attribute is typed';
lives_ok { $o.a = (2, 3) }, 'Can assign to typed drw-array-attrib';
lives_ok { $o.a[2] = 4 }, 'Can insert into typed rw-array-attrib';
Expand All @@ -461,19 +472,23 @@ is Foo7e.new.attr, 42, "default attribute value (1)";
'... all of the above actually worked (not only lived)';

#?rakudo 4 todo 'typed arrays'
#?niecza 4 todo 'typed arrays'
dies_ok { $o.a = <foo bar> }, 'type enforced on array attrib (assignment)';
dies_ok { $o.a[2] = $*IN }, 'type enforced on array attrib (item assignment)';
dies_ok { $o.a.push: [2, 3]}, 'type enforced on array attrib (push)';
dies_ok { $o.a[42]<foo> = 3}, 'no autovivification (typed array)';

#?rakudo todo 'over-eager auto-vivification bugs'
#?niecza todo
is $o.a.join('|'), '2|3|4|5',
'... all of the above actually did nothing (not just died)';

#?rakudo todo 'typed hash'
#?niecza skip "Unable to resolve method of in class Hash"
ok $o.h.of === Int, 'hash attribute is typed';
lives_ok {$o.h = { a => 1, b => 2 } }, 'assign to typed hash attrib';
lives_ok {$o.h<c> = 3}, 'insertion into typed hash attrib';
#?niecza 4 todo
lives_ok {$o.h.push: (d => 4) }, 'pushing onto typed hash attrib';

is_deeply $o.h<a b c d>, (1, 2, 3, 4), '... all of them worked';
Expand All @@ -482,11 +497,13 @@ is Foo7e.new.attr, 42, "default attribute value (1)";
dies_ok {$o.h = { :a<b> } }, 'Type enforced (hash, assignment)';
dies_ok {$o.h<a> = 'b' }, 'Type enforced (hash, insertion)';
dies_ok {$o.h.push: (g => 'f') }, 'Type enforced (hash, push)';
#?niecza 2 todo
dies_ok {$o.h<blubb><bla> = 3 }, 'No autovivification (typed hash)';
is_deeply $o.h<a b c d>, (1, 2, 3, 4), 'hash still unchanged';
}

# attribute initialization based upon other attributes
#?niecza skip 'Variable $.a used where no self is available'
{
class AttrInitTest {
has $.a = 1;
Expand All @@ -511,6 +528,7 @@ is Foo7e.new.attr, 42, "default attribute value (1)";
is CodeAttr3.new.f, 'OH HAI', '&!m = method { ... } and self.&!m() work';
}

#?niecza skip "Action method trait_mod:does not yet implemented"
{
# from t/oo/class_inclusion_with_inherited_class.t
# used to be a pugs regression
Expand Down Expand Up @@ -547,6 +565,7 @@ is Foo7e.new.attr, 42, "default attribute value (1)";
}

# Binding an attribute (was RT #64850)
#?niecza skip 'Cannot use bind operator with this LHS'
{
class RT64850 {
has $.x;
Expand Down

0 comments on commit 4bc3e06

Please sign in to comment.