X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fsort.t;h=8828083066c5b9110f683d2aa147fb7c6d809621;hb=ac49b0251b62a2ed1e5f0e17d1c256ce3f88d6dd;hp=52d1d8be0e96357b2f4db186f4aef75f467a90b6;hpb=004283b80f6094bb85aba6f48a74e3c5c34ea24f;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/sort.t b/lib/sort.t index 52d1d8b..8828083 100644 --- a/lib/sort.t +++ b/lib/sort.t @@ -28,7 +28,8 @@ use warnings; use Test::More tests => @TestSizes * 2 # sort() tests * 4 # number of pragmas to test + 1 # extra test for qsort instability - + 3; # tests for sort::current + + 3 # tests for sort::current + + 3; # tests for "defaults" and "no sort" # Generate array of specified size for testing sort. # @@ -124,11 +125,8 @@ sub main { $status = checkequal(\@sorted, $unsorted); is($status, '', "contents ok for size $ts"); } - # P5P: The following test (#58) has been observed failing on - # a solaris 2.8 platform. Failure doesn't mean that sort is - # misbehaving, it is just exhibiting an exceedingly unlikely - # pattern of breaking ties. If you see no other failures, - # it should be perfectly safe to install. + # If the following test (#58) fails, see the comments in pp_sort.c + # for Perl_sortsv(). if ($expect_unstable) { ok($unstable_num > 0, 'Instability ok'); } @@ -139,9 +137,8 @@ main(0); # XXX We're using this eval "..." trick to force recompilation, # to ensure that the correct pragma is enabled when main() is run. -# Currently 'use sort' modifies $^H{SORT} at compile-time, but -# pp_sort() fetches its value at run-time : thus the lexical scoping -# of %^H is of no utility. +# Currently 'use sort' modifies $sort::hints at compile-time, but +# pp_sort() fetches its value at run-time. # The order of those evals is important. eval q{ @@ -164,3 +161,23 @@ eval q{ main(0); }; die $@ if $@; + +# Tests added to check "defaults" subpragma, and "no sort" + +eval q{ + no sort qw(_qsort); + is(sort::current(), 'stable', 'sort::current after no _qsort'); +}; +die $@ if $@; + +eval q{ + use sort qw(defaults _qsort); + is(sort::current(), 'quicksort', 'sort::current after defaults _qsort'); +}; +die $@ if $@; + +eval q{ + use sort qw(defaults stable); + is(sort::current(), 'stable', 'sort::current after defaults stable'); +}; +die $@ if $@;