Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Merged
merged 3 commits into from

2 participants

@paultcochrane

Comments welcome.

paultcochrane added some commits
@paultcochrane paultcochrane [GH #927] Added tests for sort() method of ResizableFloatArray PMC 7c0d17e
@paultcochrane paultcochrane [GH# 927] Test output more specific wrt how float array was resized 76e83f7
@paultcochrane paultcochrane [GH #927] Test sort() after unshift in ResizableFloatArray
It's probably a good idea to check if sorting after an unshift works as well
as the currently available tests for simply sorting and for sorting after a
push.  This way we test the interaction between resizing and sorting.
fee04de
@leto
Owner

Looks great! Thanks @paultcochrane

@leto leto merged commit 829fa8f into parrot:master
@paultcochrane paultcochrane deleted the paultcochrane:ptc/resizable_float_array_sort_test branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 24, 2013
  1. @paultcochrane
  2. @paultcochrane
  3. @paultcochrane

    [GH #927] Test sort() after unshift in ResizableFloatArray

    paultcochrane authored
    It's probably a good idea to check if sorting after an unshift works as well
    as the currently available tests for simply sorting and for sorting after a
    push.  This way we test the interaction between resizing and sorting.
This page is out of date. Refresh to see the latest.
Showing with 46 additions and 1 deletion.
  1. +46 −1 t/pmc/resizablefloatarray.t
View
47 t/pmc/resizablefloatarray.t
@@ -16,7 +16,7 @@ out-of-bounds test. Checks INT and PMC keys.
=cut
-.const int TESTS = 63
+.const int TESTS = 78
.const num PRECISION = 1e-6
.sub 'test' :main
@@ -49,6 +49,7 @@ out-of-bounds test. Checks INT and PMC keys.
check_interface()
get_iter()
'clone'()
+ test_sort()
method_reverse()
.end
@@ -459,6 +460,50 @@ out-of-bounds test. Checks INT and PMC keys.
nok(0, 'clone made an evil clone')
.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
.local pmc array
array = new ['ResizableFloatArray']
Something went wrong with that request. Please try again.