Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests for sort() method in ResizableFloatArray PMC #947

Merged
merged 3 commits into from Mar 24, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 46 additions & 1 deletion t/pmc/resizablefloatarray.t
Expand Up @@ -16,7 +16,7 @@ out-of-bounds test. Checks INT and PMC keys.


=cut =cut


.const int TESTS = 63 .const int TESTS = 78
.const num PRECISION = 1e-6 .const num PRECISION = 1e-6


.sub 'test' :main .sub 'test' :main
Expand Down Expand Up @@ -49,6 +49,7 @@ out-of-bounds test. Checks INT and PMC keys.
check_interface() check_interface()
get_iter() get_iter()
'clone'() 'clone'()
test_sort()
method_reverse() method_reverse()
.end .end


Expand Down Expand Up @@ -459,6 +460,50 @@ out-of-bounds test. Checks INT and PMC keys.
nok(0, 'clone made an evil clone') nok(0, 'clone made an evil clone')
.end .end


.sub test_sort
.local pmc array
array = new ['ResizableFloatArray'], 4
set array[0], 10.2
set array[1], 3.0
set array[2], 5.85
set array[3], -1.7
array.'sort'()
$N0 = array[0]
is($N0, -1.7, 'sort works - 1st element correct')
$N1 = array[1]
is($N1, 3.0, 'sort works - 2nd element correct')
$N2 = array[2]
is($N2, 5.85, 'sort works - 3rd element correct')
$N3 = array[3]
is($N3, 10.2, 'sort works - 4th element correct')
push array, 3.5
array.'sort'()
$N0 = array[0]
is($N0, -1.7, 'sort works - 1st element correct after push')
$N1 = array[1]
is($N1, 3.0, 'sort works - 2nd element correct after push')
$N2 = array[2]
is($N2, 3.5, 'sort works - 3rd element correct after push')
$N3 = array[3]
is($N3, 5.85, 'sort works - 4th element correct after push')
$N4 = array[4]
is($N4, 10.2, 'sort works - 5th element correct after push')
unshift array, 7.2
array.'sort'()
$N0 = array[0]
is($N0, -1.7, 'sort works - 1st element correct after unshift')
$N1 = array[1]
is($N1, 3.0, 'sort works - 2nd element correct after unshift')
$N2 = array[2]
is($N2, 3.5, 'sort works - 3rd element correct after unshift')
$N3 = array[3]
is($N3, 5.85, 'sort works - 4th element correct after unshift')
$N4 = array[4]
is($N4, 7.2, 'sort works - 5th element correct after unshift')
$N5 = array[5]
is($N5, 10.2, 'sort works - 6th element correct after unshift')
.end

.sub method_reverse .sub method_reverse
.local pmc array .local pmc array
array = new ['ResizableFloatArray'] array = new ['ResizableFloatArray']
Expand Down