[svn:parrot] r48527 - trunk/t/op
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Mon Aug 16 18:37:12 UTC 2010
Author: NotFound
Date: Mon Aug 16 18:37:12 2010
New Revision: 48527
URL: https://trac.parrot.org/parrot/changeset/48527
Log:
fix and improve substr oob tests
Modified:
trunk/t/op/string.t
Modified: trunk/t/op/string.t
==============================================================================
--- trunk/t/op/string.t Mon Aug 16 17:34:55 2010 (r48526)
+++ trunk/t/op/string.t Mon Aug 16 18:37:12 2010 (r48527)
@@ -16,6 +16,8 @@
=cut
+.include 'except_types.pasm'
+
.sub main :main
.include 'test_more.pir'
@@ -31,7 +33,7 @@
substr_tests()
neg_substr_offset()
exception_substr_oob()
- exception_substr_oob()
+ exception_substr_oob_neg()
len_greater_than_strlen()
len_greater_than_strlen_neg_offset()
replace_w_rep_eq_length()
@@ -310,24 +312,42 @@
# This asks for substring that shouldn't be allowed...
.sub exception_substr_oob
+ .local pmc eh
+ .local int r
set $S0, "A string of length 21"
- set $I0, -99
+ set $I0, 99
set $I1, 6
- push_eh handler
- substr $S1, $S0, $I0, $I1
-handler:
- .exception_is( "Cannot take substr outside string" )
+ eh = new ['ExceptionHandler']
+ eh.'handle_types'(.EXCEPTION_SUBSTR_OUT_OF_STRING)
+ set_addr eh, handler
+ push_eh eh
+ r = 1
+
+ substr $S1, $S0, $I0, $I1
+ r = 0
+ handler:
+ pop_eh
+ is(r, 1, "substr outside string throws" )
.end
# This asks for substring that shouldn't be allowed...
-.sub exception_substr_oob
+.sub exception_substr_oob_neg
+ .local pmc eh
+ .local int r
set $S0, "A string of length 21"
- set $I0, 99
+ set $I0, -99
set $I1, 6
- push_eh handler
- substr $S1, $S0, $I0, $I1
-handler:
- .exception_is( "Cannot take substr outside string" )
+ eh = new ['ExceptionHandler']
+ eh.'handle_types'(.EXCEPTION_SUBSTR_OUT_OF_STRING)
+ set_addr eh, handler
+ push_eh eh
+ r = 1
+
+ substr $S1, $S0, $I0, $I1
+ r = 0
+ handler:
+ pop_eh
+ is(r, 1, "substr outside string throws - negative" )
.end
# This asks for substring much greater than length of original string
More information about the parrot-commits
mailing list