Skip to content

Commit

Permalink
Add a test file for NumMatrix2D. Tests basic creating, modifying, and…
Browse files Browse the repository at this point in the history
… reading matrices
  • Loading branch information
Whiteknight committed Oct 27, 2009
1 parent 61d29a5 commit ba1ba44
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions t/10-nummatrix.t
@@ -0,0 +1,85 @@
#! parrot_nqp
our @ARGS;
MAIN();

sub MAIN () {
my $num_tests := 18;
Q:PIR {
.local pmc c
load_language 'parrot'
c = compreg 'parrot'
c.'import'('Test::More')

.local pmc pla
pla = loadlib 'linalg_group'
if pla goto pla_library_loaded
say "Cannot load linalg_group"
exit 1
pla_library_loaded:
};
plan(11);
create_nummatrix2d();
set_number_nummatrix2d();
get_number_nummatrix2d();
}

sub create_nummatrix2d() {
Q:PIR {
$P0 = new 'NumMatrix2D'
$I0 = isnull $P0
$I0 = not $I0
'ok'($I0, "Can create a new NumMatrix2D")
}
}
sub set_number_nummatrix2d() {
Q:PIR {
push_eh can_not_set
$P0 = new 'NumMatrix2D'
$P0[2;2] = 3.0
$P0[0;0] = 1.0
$P0[1;1] = 2.0
ok(1, "can set values")
goto test_passed
can_not_set:
ok(0, "Cannot set values")
test_passed:
}
}

sub get_number_nummatrix2d() {
Q:PIR {
$P0 = new 'NumMatrix2D'
$P0[2;2] = 3.0
$P0[0;0] = 1.0
$P0[1;1] = 2.0
$N0 = $P0[0;0]
is($N0, 1.0, "Got 1,1")
$N0 = $P0[0;1]
is($N0, 0.0, "Got 1,1")
$N0 = $P0[0;2]
is($N0, 0.0, "Got 1,1")
$N0 = $P0[1;0]
is($N0, 0.0, "Got 1,1")
$N0 = $P0[1;1]
is($N0, 2.0, "Got 1,1")
$N0 = $P0[1;2]
is($N0, 0.0, "Got 1,1")
$N0 = $P0[2;0]
is($N0, 0.0, "Got 1,1")
$N0 = $P0[2;1]
is($N0, 0.0, "Got 1,1")
$N0 = $P0[2;2]
is($N0, 3.0, "Got 1,1")
}
}

0 comments on commit ba1ba44

Please sign in to comment.