my first v6.pm program to use a module in v6.pm!

fglock on 2006-06-30T19:09:04

I added the first OO test to v6.pm This is also the first v6.pm program to use a module written with v6.pm:

# file: t/10-moose1.t use v6-pugs;

use lib './t', '.'; use moose1;

say '1..1'; say '1 ok # use Moose';

and the module:

# file: t/moose1.pm use v6-pugs; class Point;

has $.x is rw; # instance attributes has $.y; # default "is readonly"
 method clear () { $.x = 0; # accessible within the class $.y = 0; }

Very simple, isn't it? The second file was copied from audreyt's slides in YAPC::NA.

The files compile to:

# generated file: t/10-moose1.tc use Pugs::Runtime::Perl6; use strict; no warnings 'void'; use lib( './t', '.' ); use moose1(); print '', '1..1'; print "\n"; print '', '1 ok # use Moose'; print "\n"; 1;

and:

# generated file: t/moose1.pmc # # [... checksum header removed ...] # use Pugs::Runtime::Perl6; use strict; no warnings 'void';

package Point; use Moose; use Exporter 'import'; our @EXPORT; has 'x' => ( 'is' => 'rw' ); has 'y' => ();

sub clear { my $self = shift; { $self->{'x'} = 0; $self->y(0) }

} 1;

This is in the development version of v6.pm - not in CPAN yet.