@@ -1352,15 +1352,9 @@ func TestBeginRescueReraisePreservesStack(t *testing.T) {
13521352 t .Fatalf ("expected outer frame fourth, got %s" , rtErr .Frames [3 ].Function )
13531353 }
13541354
1355- _ , err = script .Call (context .Background (), "raise_outside" , nil , CallOptions {})
1356- if err == nil || ! strings .Contains (err .Error (), "raise used outside of rescue" ) {
1357- t .Fatalf ("expected raise outside rescue error, got %v" , err )
1358- }
1359-
1360- _ , err = script .Call (context .Background (), "raise_new_message" , nil , CallOptions {})
1361- if err == nil || ! strings .Contains (err .Error (), "custom boom" ) {
1362- t .Fatalf ("expected raise message error, got %v" , err )
1363- }
1355+ requireCallErrorContains (t , script , "raise_outside" , nil , CallOptions {}, "raise used outside of rescue" )
1356+ err = callScriptErr (t , context .Background (), script , "raise_new_message" , nil , CallOptions {})
1357+ requireErrorContains (t , err , "custom boom" )
13641358 var raisedErr * RuntimeError
13651359 if ! errors .As (err , & raisedErr ) {
13661360 t .Fatalf ("expected RuntimeError, got %T" , err )
@@ -1428,15 +1422,8 @@ func TestLoopControlBreakAndNext(t *testing.T) {
14281422 whileBreakNext := callFunc (t , script , "while_break_next" , nil )
14291423 compareArrays (t , whileBreakNext , []Value {NewInt (1 ), NewInt (2 ), NewInt (4 )})
14301424
1431- _ , err := script .Call (context .Background (), "break_outside" , nil , CallOptions {})
1432- if err == nil || ! strings .Contains (err .Error (), "break used outside of loop" ) {
1433- t .Fatalf ("expected outside-loop break error, got %v" , err )
1434- }
1435-
1436- _ , err = script .Call (context .Background (), "next_outside" , nil , CallOptions {})
1437- if err == nil || ! strings .Contains (err .Error (), "next used outside of loop" ) {
1438- t .Fatalf ("expected outside-loop next error, got %v" , err )
1439- }
1425+ requireCallErrorContains (t , script , "break_outside" , nil , CallOptions {}, "break used outside of loop" )
1426+ requireCallErrorContains (t , script , "next_outside" , nil , CallOptions {}, "next used outside of loop" )
14401427}
14411428
14421429func TestLoopControlNestedAndBlockBoundaryBehavior (t * testing.T ) {
@@ -1532,25 +1519,10 @@ func TestLoopControlNestedAndBlockBoundaryBehavior(t *testing.T) {
15321519 nestedNext := callFunc (t , script , "nested_next" , nil )
15331520 compareArrays (t , nestedNext , []Value {NewInt (11 ), NewInt (13 ), NewInt (21 ), NewInt (23 )})
15341521
1535- _ , err := script .Call (context .Background (), "break_from_block_boundary" , nil , CallOptions {})
1536- if err == nil || ! strings .Contains (err .Error (), "break cannot cross call boundary" ) {
1537- t .Fatalf ("expected block-boundary break error, got %v" , err )
1538- }
1539-
1540- _ , err = script .Call (context .Background (), "next_from_block_boundary" , nil , CallOptions {})
1541- if err == nil || ! strings .Contains (err .Error (), "next cannot cross call boundary" ) {
1542- t .Fatalf ("expected block-boundary next error, got %v" , err )
1543- }
1544-
1545- _ , err = script .Call (context .Background (), "break_from_setter_boundary" , nil , CallOptions {})
1546- if err == nil || ! strings .Contains (err .Error (), "break cannot cross call boundary" ) {
1547- t .Fatalf ("expected setter-boundary break error, got %v" , err )
1548- }
1549-
1550- _ , err = script .Call (context .Background (), "next_from_setter_boundary" , nil , CallOptions {})
1551- if err == nil || ! strings .Contains (err .Error (), "next cannot cross call boundary" ) {
1552- t .Fatalf ("expected setter-boundary next error, got %v" , err )
1553- }
1522+ requireCallErrorContains (t , script , "break_from_block_boundary" , nil , CallOptions {}, "break cannot cross call boundary" )
1523+ requireCallErrorContains (t , script , "next_from_block_boundary" , nil , CallOptions {}, "next cannot cross call boundary" )
1524+ requireCallErrorContains (t , script , "break_from_setter_boundary" , nil , CallOptions {}, "break cannot cross call boundary" )
1525+ requireCallErrorContains (t , script , "next_from_setter_boundary" , nil , CallOptions {}, "next cannot cross call boundary" )
15541526}
15551527
15561528func TestLoopControlInsideClassMethods (t * testing.T ) {
0 commit comments