Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add in a test class for subclassing behavior in ComplexMatrix2D. Also…
…, I made a change to the init_from_pmc_array function, which I thought was necessary but turns out to not be (though I do prefer a solution of this form, for future reference). This is causing some test failures, so I need to debug that later
- Loading branch information
1 parent
ac8772b
commit 73ed80c
Showing
3 changed files
with
97 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!parrot | ||
|
||
|
||
.HLL 'ComplexMatrix2D_SUBCLASS_TEST' | ||
|
||
.sub test | ||
$P0 = get_class 'Complex' | ||
$P1 = subclass $P0, 'TestComplex' | ||
$P2 = getinterp | ||
$P2.'hll_map'($P0, $P1) | ||
|
||
$P0 = get_class 'Integer' | ||
$P1 = subclass $P0, 'TestInteger' | ||
$P2.'hll_map'($P0, $P1) | ||
|
||
$P3 = box 0 | ||
set_hll_global ['Test'], '_count', $P3 | ||
|
||
say "1..5" | ||
test_get_pmc_keyed() | ||
#test_get_pmc_keyed_int() | ||
test_get_attr_str() | ||
.end | ||
|
||
.sub is_TestComplex | ||
.param pmc arg | ||
|
||
$S0 = typeof arg | ||
if $S0 == 'TestComplex' goto are_equal | ||
print "not " | ||
are_equal: | ||
print "ok " | ||
$P0 = get_hll_global ['Test'], '_count' | ||
inc $P0 | ||
say $P0 | ||
.end | ||
|
||
.sub is_TestInteger | ||
.param pmc arg | ||
|
||
$S0 = typeof arg | ||
if $S0 == 'TestInteger' goto are_equal | ||
print "not " | ||
are_equal: | ||
print "ok " | ||
$P0 = get_hll_global ['Test'], '_count' | ||
inc $P0 | ||
say $P0 | ||
.end | ||
|
||
.sub test_get_pmc_keyed | ||
$P0 = new ['ComplexMatrix2D'] | ||
$P0.'initialize_from_args'(2, 2, 1, 2, 3, 4) | ||
$P1 = $P0[0;0] | ||
is_TestComplex($P1) | ||
.end | ||
|
||
.sub test_get_pmc_keyed_int | ||
$P0 = new ['ComplexMatrix2D'] | ||
$P0.'initialize_from_args'(2, 2, 1, 2, 3, 4) | ||
$P1 = $P0[0] | ||
is_TestComplex($P1) | ||
.end | ||
|
||
.sub test_get_attr_str | ||
$P0 = new ['NumMatrix2D'] | ||
$P0.'initialize_from_args'(2, 2, 1, 2, 3, 4) | ||
|
||
$P1 = getattribute $P0, 'rows' | ||
is_TestInteger($P1) | ||
|
||
$P1 = getattribute $P0, 'cols' | ||
is_TestInteger($P1) | ||
|
||
$P1 = getattribute $P0, 'size' | ||
is_TestInteger($P1) | ||
.end | ||
|