Skip to content

Commit

Permalink
remove the weird test prefixes (METHOD, etc) from some tests. We don'…
Browse files Browse the repository at this point in the history
…t need those now since the tests are broken down into files and I'm not using the fancy loader
  • Loading branch information
Whiteknight committed Aug 21, 2010
1 parent c843c5e commit 89381bf
Show file tree
Hide file tree
Showing 20 changed files with 154 additions and 82 deletions.
24 changes: 24 additions & 0 deletions t/methods/complexmatrix2d/conjugate.t
@@ -0,0 +1,24 @@
my $tests := Test::ComplexMatrix2D::Conjugate.new();
$tests.suite.run;

class Test::ComplexMatrix2D::Conjugate is Pla::MatrixTestBase {
INIT {
use('UnitTest::Testcase');
use('UnitTest::Assertions');
}

has $!factory;
method factory() {
unless pir::defined__IP($!factory) {
$!factory := Pla::MatrixFactory::ComplexMatrix2D.new();
}
return $!factory;
}

method test_METHOD_conjugate() {
my $m := self.factory.matrix2x2("1+1i", "2+2i", "3+3i", "4+4i");
my $n := self.factory.matrix2x2("1-1i", "2-2i", "3-3i", "4-4i");
$m.conjugate();
assert_equal($m, $n, "conjugate does not work");
}
}
2 changes: 0 additions & 2 deletions t/testlib/matrixtestbase.nqp
Expand Up @@ -16,8 +16,6 @@ class Pla::MatrixTestBase is UnitTest::Testcase {
self.RequireOverride("factory");
}

method default_loader() { Pla::Matrix::Loader.new; }

method RequireOverride($m) {
Exception::MethodNotFound.new(
:message("Must subclass " ~ $m ~ " in your test class")
Expand Down
2 changes: 1 addition & 1 deletion t/testlib/methods/convert_to_complex_matrix.nqp
Expand Up @@ -5,7 +5,7 @@ class Pla::Methods::ConvertToComplexMatrix is Pla::MatrixTestBase {
use('UnitTest::Assertions');
}

method test_METHOD_convert_to_complex_matrix() {
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");
Expand Down
2 changes: 1 addition & 1 deletion t/testlib/methods/convert_to_number_matrix.nqp
Expand Up @@ -5,7 +5,7 @@ class Pla::Methods::ConvertToNumberMatrix is Pla::MatrixTestBase {
use('UnitTest::Assertions');
}

method test_METHOD_convert_to_number_matrix() {
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");
Expand Down
2 changes: 1 addition & 1 deletion t/testlib/methods/convert_to_pmc_matrix.nqp
Expand Up @@ -5,7 +5,7 @@ class Pla::Methods::ConvertToPmcMatrix is Pla::MatrixTestBase {
use('UnitTest::Assertions');
}

method test_METHOD_convert_to_pmc_matrix() {
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");
Expand Down
4 changes: 2 additions & 2 deletions t/testlib/methods/fill.nqp
Expand Up @@ -6,7 +6,7 @@ class Pla::Methods::Fill is Pla::MatrixTestBase {
}

# Test that we can fill a matrix
method test_METHOD_fill() {
method test_fill() {
my $m := self.factory.defaultmatrix2x2();
my $n := self.factory.matrix2x2(
self.factory.fancyvalue(0),
Expand All @@ -19,7 +19,7 @@ class Pla::Methods::Fill is Pla::MatrixTestBase {
}

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

method test_METHOD_gemm_BADTYPE_A() {
method test_bad_type_A() {
assert_throws(Exception::OutOfBounds, "A is bad type",
{
my $A := "foobar";
Expand All @@ -20,7 +20,7 @@ class Pla::Methods::Gemm is Pla::MatrixTestBase {
});
}

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

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

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

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

method test_METHOD_gemm_BADSIZE_C() {
method test_bad_size_C() {
assert_throws(Exception::OutOfBounds, "C has incorrect size",
{
my $A := self.factory.defaultmatrix3x3();
Expand All @@ -82,4 +82,4 @@ class Pla::Methods::Gemm is Pla::MatrixTestBase {
method test_METHOD_gemm_AUTOCONVERT_B_PMCMatrix2D() { todo("Write this!"); }
method test_METHOD_gemm_AUTOCONVERT_C_PMCMatrix2D() { todo("Write this!"); }

}
}
38 changes: 27 additions & 11 deletions t/testlib/methods/get_block.nqp
Expand Up @@ -6,7 +6,7 @@ class Pla::Methods::GetBlock is Pla::MatrixTestBase {
}

# Test that we can get a block from the matrix
method test_METHOD_get_block() {
method test_get_block() {
my $m := self.factory.fancymatrix2x2();
my $n := $m.get_block(0, 0, 1, 1);
self.AssertSize($n, 1, 1);
Expand All @@ -25,7 +25,7 @@ class Pla::Methods::GetBlock is Pla::MatrixTestBase {

# TODO: Other tests for this method with other argument combinations and
# boundary checks.
method test_METHOD_get_block_1() {
method test_get_block_1() {
my $m := self.factory.matrix3x3(1.0, 2.0, 3.0,
4.0, 5.0, 6.0,
7.0, 8.0, 9.0);
Expand All @@ -35,7 +35,7 @@ class Pla::Methods::GetBlock is Pla::MatrixTestBase {
assert_equal($n, $o, "cannot get block");
}

method test_METHOD_get_block_2() {
method test_get_block_2() {
my $m := self.factory.matrix3x3(1.0, 2.0, 3.0,
4.0, 5.0, 6.0,
7.0, 8.0, 9.0);
Expand All @@ -46,40 +46,56 @@ class Pla::Methods::GetBlock is Pla::MatrixTestBase {
}

# Test that we can use get_block to make a copy
method test_METHOD_get_block_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");
}

# Test that get_block(0,0,0,0) returns a zero-size matrix
method test_METHOD_get_block_ZEROSIZE() {
method test_request_zero_size_gets_zero_size() {
my $m := self.factory.defaultmatrix2x2();
my $n := $m.get_block(0, 0, 0, 0);
self.AssertSize($n, 0, 0);
}

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

method test_negative_index_B() {
assert_throws(Exception::OutOfBounds, "Can get_block with negative indices",
{
my $m := self.factory.defaultmatrix2x2();
my $n := $m.get_block(0, -1, 1, 1);
});
}

# Test that get_block(0,0,-1,-1) throws the proper exception
method test_METHOD_get_block_NEGSIZES() {
method test_negative_size_A() {
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",
{
my $m := self.factory.defaultmatrix2x2();
my $n := $m.get_block(1, 1, -1, -1);
my $n := $m.get_block(1, 1, 1, -1);
});
}

# Test the behavior of get_block when we request a block crossing or outside
# the boundaries of the matrix
method test_METHOD_get_block_BOUNDS_CROSSED() {
method test_requested_block_crosses_matrix_boundaries() {
assert_throws(Exception::OutOfBounds, "Can get_block crossing boundaries of matrix",
{
my $m := self.factory.defaultmatrix2x2();
Expand All @@ -89,7 +105,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_METHOD_get_block_OUTSIDE() {
method test_requested_block_outside_matrix() {
assert_throws(Exception::OutOfBounds, "Can get_block outside boundaries of matrix",
{
my $m := self.factory.defaultmatrix2x2();
Expand Down
6 changes: 3 additions & 3 deletions t/testlib/methods/initialize_from_args.nqp
Expand Up @@ -6,7 +6,7 @@ class Pla::Methods::InitializeFromArgs is Pla::MatrixTestBase {
}

# Test that we can initialize from a list of arguments
method test_METHOD_initialize_from_args() {
method test_initialize_from_args() {
my $m := self.factory.matrix2x2(self.factory.fancyvalue(0), self.factory.fancyvalue(1),
self.factory.fancyvalue(2), self.factory.fancyvalue(3));
my $n := self.factory.matrix();
Expand All @@ -16,7 +16,7 @@ class Pla::Methods::InitializeFromArgs is Pla::MatrixTestBase {
}

# Test that we can initialize from an arg list with zero padding
method test_METHOD_initialize_from_args_ZEROPAD() {
method test_null_pad_extra_spaces() {
my $m := self.factory.matrix3x3(self.factory.fancyvalue(0), self.factory.fancyvalue(1), self.factory.fancyvalue(2),
self.factory.fancyvalue(3), self.factory.nullvalue, self.factory.nullvalue,
self.factory.nullvalue, self.factory.nullvalue, self.factory.nullvalue);
Expand All @@ -28,7 +28,7 @@ class Pla::Methods::InitializeFromArgs is Pla::MatrixTestBase {

# Test that we can initialize from an arg list, ignoring values that we
# don't need
method test_METHOD_initialize_from_args_UNDERSIZE() {
method test_ignore_extra_values() {
my $m := self.factory.matrix();
$m{Key.new(0,0)} := self.factory.fancyvalue(0);
my $n := self.factory.matrix();
Expand Down
6 changes: 3 additions & 3 deletions t/testlib/methods/initialize_from_array.nqp
Expand Up @@ -6,7 +6,7 @@ class Pla::Methods::InitializeFromArray is Pla::MatrixTestBase {
}

# Test that we can initialize from an array
method test_METHOD_initialize_from_array() {
method test_initialize_from_array() {
my $a := [self.factory.fancyvalue(0), self.factory.fancyvalue(1),
self.factory.fancyvalue(2), self.factory.fancyvalue(3)];
my $m := self.factory.matrix2x2(self.factory.fancyvalue(0), self.factory.fancyvalue(1),
Expand All @@ -17,7 +17,7 @@ class Pla::Methods::InitializeFromArray is Pla::MatrixTestBase {
}

# Test that we can initialize from array, including zero padding
method test_METHOD_initialize_from_array_ZEROPAD() {
method test_null_pad_extra_items() {
my $a := [self.factory.fancyvalue(0), self.factory.fancyvalue(1),
self.factory.fancyvalue(2), self.factory.fancyvalue(3)];
my $m := self.factory.matrix3x3(self.factory.fancyvalue(0), self.factory.fancyvalue(1), self.factory.fancyvalue(2),
Expand All @@ -30,7 +30,7 @@ class Pla::Methods::InitializeFromArray is Pla::MatrixTestBase {

# Test that when we initialize from an array, that we only use as many
# values as required
method test_METHOD_initialize_from_array_UNDERSIZE() {
method test_ignore_extra_values() {
my $a := [self.factory.fancyvalue(0), self.factory.fancyvalue(1),
self.factory.fancyvalue(2), self.factory.fancyvalue(3)];
my $m := self.factory.matrix();
Expand Down

0 comments on commit 89381bf

Please sign in to comment.