Skip to content

Commit

Permalink
[mm] implement sub classes, start sorting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Sep 28, 2010
1 parent ba6543f commit 88fb2a5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 21 deletions.
5 changes: 5 additions & 0 deletions src/CSharpBackend.pm
Expand Up @@ -404,6 +404,11 @@ sub sub2 {

push @thaw, CgOp::rawsset($si, CgOp::rawnew($si_ty, @{ $node->{sictor} }));

if ($_->class ne 'Sub') {
my $cl = $unit->deref($unit->get_stash(@{ $_->find_lex_pkg($_->class) })->obj);
push @thaw, CgOp::setfield('mo', CgOp::rawsget($si), CgOp::rawsget($cl->{peer}{mo}));
}

my $pp = $node->{pp};
if ($pp) {
push @thaw, CgOp::rawsset($pp, CgOp::rawnew('Frame',
Expand Down
11 changes: 11 additions & 0 deletions src/Metamodel.pm
Expand Up @@ -173,6 +173,17 @@ our $unit;
__PACKAGE__->meta->make_immutable;
}

{
package Metamodel::Grammar;
use Moose;
extends 'Metamodel::Class';

sub _defsuper { 'Grammar' }

no Moose;
__PACKAGE__->meta->make_immutable;
}

{
package Metamodel::Method;
use Moose;
Expand Down
22 changes: 1 addition & 21 deletions test.pl
Expand Up @@ -2,7 +2,7 @@

use Test;

plan 539;
plan 534;

ok 1, "one is true";
ok 2, "two is also true";
Expand Down Expand Up @@ -63,16 +63,6 @@
ok $a == 55, "looping works";
}

{
my $x;
INIT {
$x = 1;
}
ok $x, "changes made in the protolexpad are visible at runtime";
}

ok INIT { 1 }, "init blocks can return values";

{
sub foo() { 42 }
ok (foo) == 42, "can call argless function without parens";
Expand Down Expand Up @@ -228,13 +218,6 @@
ok $g() == 0, "different clones have different state vars";
}

{
my $x;
my $unclonable-sub = INIT { sub () { $x } };
$x = 42;
ok $unclonable-sub() == 42, "mainlines are not cloned";
}

{
my class A { }
my class B is A { }
Expand Down Expand Up @@ -449,9 +432,6 @@
EOC
}
is $?FILE, 'test.pl', '$?FILE works';
is $?ORIG.substr(0,5), '# vim', '$?ORIG works';
{
my @x;
Expand Down
20 changes: 20 additions & 0 deletions test2.pl
@@ -1,5 +1,25 @@
# vim: ft=perl6
use Test;

{
my $x;
INIT {
$x = 1;
}
ok $x, "changes made in the protolexpad are visible at runtime";
}

ok INIT { 1 }, "init blocks can return values";

{
my $x;
my $unclonable-sub = INIT { sub () { $x } };
$x = 42;
ok $unclonable-sub() == 42, "mainlines are not cloned";
}

is $?FILE, 'test.pl', '$?FILE works';
is $?ORIG.substr(0,5), '# vim', '$?ORIG works';


done-testing;

0 comments on commit 88fb2a5

Please sign in to comment.