several testcases for perl
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10403 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ef7c0cbbd2
commit
8b713d759d
53 changed files with 2037 additions and 486 deletions
36
Examples/test-suite/perl5/virtual_poly_runme.pl
Normal file
36
Examples/test-suite/perl5/virtual_poly_runme.pl
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 8;
|
||||
BEGIN { use_ok('virtual_poly') }
|
||||
require_ok('virtual_poly');
|
||||
|
||||
my $d = virtual_poly::NDouble->new(3.5);
|
||||
my $i = virtual_poly::NInt->new(2);
|
||||
|
||||
#
|
||||
# the copy methods return the right polymorphic types
|
||||
#
|
||||
my $dc = $d->copy();
|
||||
my $ic = $i->copy();
|
||||
|
||||
is($d->get(), $dc->get());
|
||||
|
||||
is($i->get(), $ic->get());
|
||||
|
||||
virtual_poly::incr($ic);
|
||||
|
||||
is($i->get() + 1, $ic->get());
|
||||
|
||||
my $dr = $d->ref_this();
|
||||
is($d->get(), $dr->get());
|
||||
|
||||
|
||||
#
|
||||
# 'narrowing' also works
|
||||
#
|
||||
my $ddc = virtual_poly::NDouble::narrow($d->nnumber());
|
||||
is($d->get, $ddc->get());
|
||||
|
||||
my $dic = virtual_poly::NInt::narrow($i->nnumber());
|
||||
is($i->get(), $dic->get());
|
||||
Loading…
Add table
Add a link
Reference in a new issue