PageRenderTime 28ms CodeModel.GetById 15ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/perl5/virtual_poly_runme.pl

#
Perl | 36 lines | 19 code | 10 blank | 7 comment | 0 complexity | 4e7dbd1c5f8ec5a86440206c9bc1c210 MD5 | raw file
 1#!/usr/bin/perl
 2use strict;
 3use warnings;
 4use Test::More tests => 8;
 5BEGIN { use_ok('virtual_poly') }
 6require_ok('virtual_poly');
 7
 8my $d = virtual_poly::NDouble->new(3.5);
 9my $i = virtual_poly::NInt->new(2);
10
11#
12# the copy methods return the right polymorphic types
13# 
14my $dc = $d->copy();
15my $ic = $i->copy();
16
17is($d->get(), $dc->get());
18
19is($i->get(), $ic->get());
20
21virtual_poly::incr($ic);
22
23is($i->get() + 1, $ic->get());
24
25my $dr = $d->ref_this();
26is($d->get(), $dr->get());
27
28
29#
30# 'narrowing' also works
31#
32my $ddc = virtual_poly::NDouble::narrow($d->nnumber());
33is($d->get, $ddc->get());
34
35my $dic = virtual_poly::NInt::narrow($i->nnumber());
36is($i->get(), $dic->get());