Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Whiteknight committed Feb 13, 2011
1 parent d573e0b commit ec705ce
Show file tree
Hide file tree
Showing 17 changed files with 115 additions and 115 deletions.
2 changes: 1 addition & 1 deletion t/testlib/methods/convert_to_complex_matrix.nqp
Expand Up @@ -2,7 +2,7 @@ class Pla::Methods::ConvertToComplexMatrix is Pla::MatrixTestBase {
method test_convert_to_complex_matrix() {
my $A := self.factory.defaultmatrix2x2();
my $B := $A.convert_to_complex_matrix();
assert_equal(pir::typeof__SP($B), "ComplexMatrix2D", "cannot convert");
Assert::equal(pir::typeof__SP($B), "ComplexMatrix2D", "cannot convert");
self.AssertSize($B, 2, 2);
}

Expand Down
2 changes: 1 addition & 1 deletion t/testlib/methods/convert_to_number_matrix.nqp
Expand Up @@ -2,7 +2,7 @@ class Pla::Methods::ConvertToNumberMatrix is Pla::MatrixTestBase {
method test_convert_to_number_matrix() {
my $A := self.factory.defaultmatrix2x2();
my $B := $A.convert_to_number_matrix();
assert_equal(pir::typeof__SP($B), "NumMatrix2D", "cannot convert");
Assert::equal(pir::typeof__SP($B), "NumMatrix2D", "cannot convert");
self.AssertSize($B, 2, 2);
}

Expand Down
2 changes: 1 addition & 1 deletion t/testlib/methods/convert_to_pmc_matrix.nqp
Expand Up @@ -2,7 +2,7 @@ class Pla::Methods::ConvertToPmcMatrix is Pla::MatrixTestBase {
method test_convert_to_pmc_matrix() {
my $A := self.factory.defaultmatrix2x2();
my $B := $A.convert_to_pmc_matrix();
assert_equal(pir::typeof__SP($B), "PMCMatrix2D", "cannot convert");
Assert::equal(pir::typeof__SP($B), "PMCMatrix2D", "cannot convert");
self.AssertSize($B, 2, 2);
}
}
4 changes: 2 additions & 2 deletions t/testlib/methods/fill.nqp
Expand Up @@ -9,14 +9,14 @@ class Pla::Methods::Fill is Pla::MatrixTestBase {
self.factory.fancyvalue(0)
);
$m.fill(self.factory.fancyvalue(0));
assert_equal($n, $m, "Cannot fill");
Assert::equal($n, $m, "Cannot fill");
}

# test that the fill method can be used to resize the matrix
method test_fill_with_resizing() {
my $m := self.factory.defaultmatrix2x2();
my $n := self.factory.matrix();
$n.fill(self.factory.defaultvalue(), 2, 2);
assert_equal($n, $m, "Cannot fill+Resize");
Assert::equal($n, $m, "Cannot fill+Resize");
}
}
14 changes: 7 additions & 7 deletions t/testlib/methods/gemm.nqp
Expand Up @@ -5,7 +5,7 @@ class Pla::Methods::Gemm is Pla::MatrixTestBase {
method test_METHOD_gemm_aABbC() { self.RequireOverride("test_METHOD_gemm_aABbC"); }

method test_bad_type_A() {
assert_throws(Exception::OutOfBounds, "A is bad type",
Assert::throws(Exception::OutOfBounds, "A is bad type",
{
my $A := "foobar";
my $B := self.factory.defaultmatrix3x3();
Expand All @@ -15,7 +15,7 @@ class Pla::Methods::Gemm is Pla::MatrixTestBase {
}

method test_bad_type_B() {
assert_throws(Exception::OutOfBounds, "B is bad type",
Assert::throws(Exception::OutOfBounds, "B is bad type",
{
my $A := self.factory.defaultmatrix3x3();
my $B := "foobar";
Expand All @@ -25,7 +25,7 @@ class Pla::Methods::Gemm is Pla::MatrixTestBase {
}

method test_bad_type_C() {
assert_throws(Exception::OutOfBounds, "C is bad type",
Assert::throws(Exception::OutOfBounds, "C is bad type",
{
my $A := self.factory.defaultmatrix3x3();
my $B := self.factory.defaultmatrix3x3();
Expand All @@ -35,7 +35,7 @@ class Pla::Methods::Gemm is Pla::MatrixTestBase {
}

method test_bad_size_A() {
assert_throws(Exception::OutOfBounds, "A has incorrect size",
Assert::throws(Exception::OutOfBounds, "A has incorrect size",
{
my $A := self.factory.defaultmatrix2x2();
my $B := self.factory.defaultmatrix3x3();
Expand All @@ -45,7 +45,7 @@ class Pla::Methods::Gemm is Pla::MatrixTestBase {
}

method test_bad_size_B() {
assert_throws(Exception::OutOfBounds, "B has incorrect size",
Assert::throws(Exception::OutOfBounds, "B has incorrect size",
{
my $A := self.factory.defaultmatrix3x3();
my $B := self.factory.defaultmatrix2x2();
Expand All @@ -55,7 +55,7 @@ class Pla::Methods::Gemm is Pla::MatrixTestBase {
}

method test_bad_size_C() {
assert_throws(Exception::OutOfBounds, "C has incorrect size",
Assert::throws(Exception::OutOfBounds, "C has incorrect size",
{
my $A := self.factory.defaultmatrix3x3();
my $B := self.factory.defaultmatrix3x3();
Expand All @@ -76,7 +76,7 @@ class Pla::Methods::Gemm is Pla::MatrixTestBase {
my $D := $m.gemm($alpha, $A, $B, $beta, $C);
my $type_D := pir::typeof__SP($D);
my $type_m := pir::typeof__SP($m);
assert_equal($type_D, $type_m,
Assert::equal($type_D, $type_m,
"not the right type. Found " ~ $type_D ~ " expected " ~ $type_m);
}

Expand Down
28 changes: 14 additions & 14 deletions t/testlib/methods/get_block.nqp
Expand Up @@ -4,17 +4,17 @@ class Pla::Methods::GetBlock is Pla::MatrixTestBase {
my $m := self.factory.fancymatrix2x2();
my $n := $m.get_block(0, 0, 1, 1);
self.AssertSize($n, 1, 1);
assert_equal($n{Key.new(0, 0)}, $m{Key.new(0, 0)}, "Cannot get_block with correct values");
Assert::equal($n{self.factory.key(0, 0)}, $m{Key.new(0, 0)}, "Cannot get_block with correct values");

$n := $m.get_block(0, 0, 1, 2);
self.AssertSize($n, 1, 2);
assert_equal($n{Key.new(0, 0)}, $m{Key.new(0, 0)}, "Cannot get_block with correct values");
assert_equal($n{Key.new(0, 1)}, $m{Key.new(0, 1)}, "Cannot get_block with correct values");
Assert::equal($n{self.factory.key(0, 0)}, $m{Key.new(0, 0)}, "Cannot get_block with correct values");
Assert::equal($n{self.factory.key(0, 1)}, $m{Key.new(0, 1)}, "Cannot get_block with correct values");

$n := $m.get_block(0, 1, 2, 1);
self.AssertSize($n, 2, 1);
assert_equal($n{Key.new(0, 0)}, $m{Key.new(0, 1)}, "Cannot get_block with correct values");
assert_equal($n{Key.new(1, 0)}, $m{Key.new(1, 1)}, "Cannot get_block with correct values");
Assert::equal($n{self.factory.key(0, 0)}, $m{Key.new(0, 1)}, "Cannot get_block with correct values");
Assert::equal($n{self.factory.key(1, 0)}, $m{Key.new(1, 1)}, "Cannot get_block with correct values");
}

# TODO: Other tests for this method with other argument combinations and
Expand All @@ -26,7 +26,7 @@ class Pla::Methods::GetBlock is Pla::MatrixTestBase {
my $n := self.factory.matrix2x2(1.0, 2.0,
4.0, 5.0);
my $o := $m.get_block(0, 0, 2, 2);
assert_equal($n, $o, "cannot get block");
Assert::equal($n, $o, "cannot get block");
}

method test_get_block_2() {
Expand All @@ -36,14 +36,14 @@ class Pla::Methods::GetBlock is Pla::MatrixTestBase {
my $n := self.factory.matrix2x2(5.0, 6.0,
8.0, 9.0);
my $o := $m.get_block(1, 1, 2, 2);
assert_equal($n, $o, "cannot get block");
Assert::equal($n, $o, "cannot get block");
}

# Test that we can use get_block to make a copy
method test_get_block_as_a_copy_routine() {
my $m := self.factory.fancymatrix2x2();
my $n := $m.get_block(0, 0, 2, 2);
assert_equal($m, $n, "We cannot use get_block to create a faithful copy");
Assert::equal($m, $n, "We cannot use get_block to create a faithful copy");
}

# Test that get_block(0,0,0,0) returns a zero-size matrix
Expand All @@ -55,15 +55,15 @@ class Pla::Methods::GetBlock is Pla::MatrixTestBase {

# Test that get_block(-1,-1,0,0) throws the proper exception
method test_negative_index_A() {
assert_throws(Exception::OutOfBounds, "Can get_block with negative indices",
Assert::throws(Exception::OutOfBounds, "Can get_block with negative indices",
{
my $m := self.factory.defaultmatrix2x2();
my $n := $m.get_block(-1, 0, 1, 1);
});
}

method test_negative_index_B() {
assert_throws(Exception::OutOfBounds, "Can get_block with negative indices",
Assert::throws(Exception::OutOfBounds, "Can get_block with negative indices",
{
my $m := self.factory.defaultmatrix2x2();
my $n := $m.get_block(0, -1, 1, 1);
Expand All @@ -72,15 +72,15 @@ class Pla::Methods::GetBlock is Pla::MatrixTestBase {

# Test that get_block(0,0,-1,-1) throws the proper exception
method test_negative_size_A() {
assert_throws(Exception::OutOfBounds, "Can get_block with negative indices",
Assert::throws(Exception::OutOfBounds, "Can get_block with negative indices",
{
my $m := self.factory.defaultmatrix2x2();
my $n := $m.get_block(1, 1, -1, 1);
});
}

method test_negative_size_A() {
assert_throws(Exception::OutOfBounds, "Can get_block with negative indices",
Assert::throws(Exception::OutOfBounds, "Can get_block with negative indices",
{
my $m := self.factory.defaultmatrix2x2();
my $n := $m.get_block(1, 1, 1, -1);
Expand All @@ -90,7 +90,7 @@ class Pla::Methods::GetBlock is Pla::MatrixTestBase {
# Test the behavior of get_block when we request a block crossing or outside
# the boundaries of the matrix
method test_requested_block_crosses_matrix_boundaries() {
assert_throws(Exception::OutOfBounds, "Can get_block crossing boundaries of matrix",
Assert::throws(Exception::OutOfBounds, "Can get_block crossing boundaries of matrix",
{
my $m := self.factory.defaultmatrix2x2();
my $n := $m.get_block(1, 1, 2, 2);
Expand All @@ -100,7 +100,7 @@ class Pla::Methods::GetBlock is Pla::MatrixTestBase {
# Test that calling get_block with coordinates outside the bounds of the
# matrix throws an exception
method test_requested_block_outside_matrix() {
assert_throws(Exception::OutOfBounds, "Can get_block outside boundaries of matrix",
Assert::throws(Exception::OutOfBounds, "Can get_block outside boundaries of matrix",
{
my $m := self.factory.defaultmatrix2x2();
my $n := $m.get_block(9, 9, 2, 2);
Expand Down
8 changes: 4 additions & 4 deletions t/testlib/methods/initialize_from_args.nqp
Expand Up @@ -6,7 +6,7 @@ class Pla::Methods::InitializeFromArgs is Pla::MatrixTestBase {
my $n := self.factory.matrix();
$n.initialize_from_args(2, 2, self.factory.fancyvalue(0), self.factory.fancyvalue(1),
self.factory.fancyvalue(2), self.factory.fancyvalue(3));
assert_equal($n, $m, "cannot initialize_from_args");
Assert::equal($n, $m, "cannot initialize_from_args");
}

# Test that we can initialize from an arg list with zero padding
Expand All @@ -17,18 +17,18 @@ class Pla::Methods::InitializeFromArgs is Pla::MatrixTestBase {
my $n := self.factory.matrix();
$n.initialize_from_args(3, 3, self.factory.fancyvalue(0), self.factory.fancyvalue(1),
self.factory.fancyvalue(2), self.factory.fancyvalue(3));
assert_equal($n, $m, "cannot initalize from args with zero padding");
Assert::equal($n, $m, "cannot initalize from args with zero padding");
}

# Test that we can initialize from an arg list, ignoring values that we
# don't need
method test_ignore_extra_values() {
my $m := self.factory.matrix();
$m{Key.new(0,0)} := self.factory.fancyvalue(0);
$m{self.factory.key(0,0)} := self.factory.fancyvalue(0);
my $n := self.factory.matrix();
$n.initialize_from_args(1, 1, self.factory.fancyvalue(0), self.factory.fancyvalue(1),
self.factory.fancyvalue(2), self.factory.fancyvalue(3));
assert_equal($n, $m, "cannot initialize from args undersized");
Assert::equal($n, $m, "cannot initialize from args undersized");
}


Expand Down
8 changes: 4 additions & 4 deletions t/testlib/methods/initialize_from_array.nqp
Expand Up @@ -7,7 +7,7 @@ class Pla::Methods::InitializeFromArray is Pla::MatrixTestBase {
self.factory.fancyvalue(2), self.factory.fancyvalue(3));
my $n := self.factory.matrix();
$n.initialize_from_array(2, 2, $a);
assert_equal($n, $m, "cannot initialize_from_array");
Assert::equal($n, $m, "cannot initialize_from_array");
}

# Test that we can initialize from array, including zero padding
Expand All @@ -19,7 +19,7 @@ class Pla::Methods::InitializeFromArray is Pla::MatrixTestBase {
self.factory.nullvalue, self.factory.nullvalue, self.factory.nullvalue);
my $n := self.factory.matrix();
$n.initialize_from_array(3, 3, $a);
assert_equal($n, $m, "cannot initalize from array with zero padding");
Assert::equal($n, $m, "cannot initalize from array with zero padding");
}

# Test that when we initialize from an array, that we only use as many
Expand All @@ -28,10 +28,10 @@ class Pla::Methods::InitializeFromArray is Pla::MatrixTestBase {
my $a := [self.factory.fancyvalue(0), self.factory.fancyvalue(1),
self.factory.fancyvalue(2), self.factory.fancyvalue(3)];
my $m := self.factory.matrix();
$m{Key.new(0,0)} := self.factory.fancyvalue(0);
$m{self.factory.key(0,0)} := self.factory.fancyvalue(0);
my $n := self.factory.matrix();
$n.initialize_from_array(1, 1, $a);
assert_equal($n, $m, "cannot initialize from array undersized");
Assert::equal($n, $m, "cannot initialize from array undersized");
}

}
32 changes: 16 additions & 16 deletions t/testlib/methods/item_at.nqp
@@ -1,47 +1,47 @@
class Pla::Methods::ItemAt is Pla::MatrixTestBase {
method test_item_at() {
my $m := self.factory.fancymatrix2x2();
assert_equal(self.factory.fancyvalue(0), $m.item_at(0, 0), "cannot get item 0,0");
assert_equal(self.factory.fancyvalue(1), $m.item_at(0, 1), "cannot get item 0,1");
assert_equal(self.factory.fancyvalue(2), $m.item_at(1, 0), "cannot get item 1,0");
assert_equal(self.factory.fancyvalue(3), $m.item_at(1, 1), "cannot get item 1,1");
Assert::equal(self.factory.fancyvalue(0), $m.item_at(0, 0), "cannot get item 0,0");
Assert::equal(self.factory.fancyvalue(1), $m.item_at(0, 1), "cannot get item 0,1");
Assert::equal(self.factory.fancyvalue(2), $m.item_at(1, 0), "cannot get item 1,0");
Assert::equal(self.factory.fancyvalue(3), $m.item_at(1, 1), "cannot get item 1,1");
}

method test_out_of_bounds_index_A() {
my $m := self.factory.defaultmatrix2x2();
assert_throws(Exception::OutOfBounds, "can item_at out of bounds",
Assert::throws(Exception::OutOfBounds, "can item_at out of bounds",
{
$m.item_at(1, 4);
});
}

method test_out_of_bounds_index_B() {
my $m := self.factory.defaultmatrix2x2();
assert_throws(Exception::OutOfBounds, "can item_at out of bounds",
Assert::throws(Exception::OutOfBounds, "can item_at out of bounds",
{
$m.item_at(4, 1);
});
}

method test_negative_index_A() {
my $m := self.factory.defaultmatrix2x2();
assert_throws(Exception::OutOfBounds, "can item_at out of bounds",
Assert::throws(Exception::OutOfBounds, "can item_at out of bounds",
{
$m.item_at(-1, 0);
});
}

method test_negative_index_B() {
my $m := self.factory.defaultmatrix2x2();
assert_throws(Exception::OutOfBounds, "can item_at out of bounds",
Assert::throws(Exception::OutOfBounds, "can item_at out of bounds",
{
$m.item_at(0, -1);
});
}

method test_item_from_empty_matrix() {
my $m := self.factory.matrix();
assert_throws(Exception::OutOfBounds, "can item_at out of bounds",
Assert::throws(Exception::OutOfBounds, "can item_at out of bounds",
{
$m.item_at(0, 0);
});
Expand All @@ -50,46 +50,46 @@ class Pla::Methods::ItemAt is Pla::MatrixTestBase {
method test_set_optional_third_parameter() {
my $m := self.factory.fancymatrix2x2();
my $n := self.factory.fancymatrix2x2();
$n{Key.new(1, 1)} := self.factory.fancyvalue(0);
$n{self.factory.key(1, 1)} := self.factory.fancyvalue(0);
$m.item_at(1, 1, self.factory.fancyvalue(0));
assert_equal($m, $n, "item_at(VALUE) does not work like keyed access");
Assert::equal($m, $n, "item_at(VALUE) does not work like keyed access");
}

method test_set_out_of_bounds_index_A() {
my $m := self.factory.defaultmatrix2x2();
assert_throws(Exception::OutOfBounds, "can item_at out of bounds",
Assert::throws(Exception::OutOfBounds, "can item_at out of bounds",
{
$m.item_at(4, 1, self.factory.fancyvalue(0));
});
}

method test_set_out_of_bounds_index_B() {
my $m := self.factory.defaultmatrix2x2();
assert_throws(Exception::OutOfBounds, "can item_at out of bounds",
Assert::throws(Exception::OutOfBounds, "can item_at out of bounds",
{
$m.item_at(1, 4, self.factory.fancyvalue(0));
});
}

method test_set_at_negative_index_A() {
my $m := self.factory.defaultmatrix2x2();
assert_throws(Exception::OutOfBounds, "can item_at out of bounds",
Assert::throws(Exception::OutOfBounds, "can item_at out of bounds",
{
$m.item_at(-1, -1, self.factory.fancyvalue(0));
});
}

method test_set_at_negative_index_B() {
my $m := self.factory.defaultmatrix2x2();
assert_throws(Exception::OutOfBounds, "can item_at out of bounds",
Assert::throws(Exception::OutOfBounds, "can item_at out of bounds",
{
$m.item_at(-1, -1, self.factory.fancyvalue(0));
});
}

method test_set_empty_matrix_does_not_grow() {
my $m := self.factory.matrix();
assert_throws(Exception::OutOfBounds, "can item_at out of bounds",
Assert::throws(Exception::OutOfBounds, "can item_at out of bounds",
{
$m.item_at(0, 0, self.factory.fancyvalue(0));
});
Expand Down

0 comments on commit ec705ce

Please sign in to comment.