@@ -145,6 +145,18 @@ SindarinDebuggerTest >> methodWithSeveralInstructionsInBlock [
145
145
^ 42
146
146
]
147
147
148
+ { #category : #helpers }
149
+ SindarinDebuggerTest >> methodWithSeveralReturns [
150
+ " There is only one explicit return but there is also an implicit return after `a := 3`. In that sense, there are several returns in this method"
151
+
152
+ | a |
153
+ a := true .
154
+ a
155
+ ifFalse: [ ^ a := 1 ]
156
+ ifTrue: [ a := 2 ].
157
+ a := 3
158
+ ]
159
+
148
160
{ #category : #helpers }
149
161
SindarinDebuggerTest >> methodWithTwoAssignments [
150
162
@@ -1311,6 +1323,52 @@ SindarinDebuggerTest >> testSkipBlockNode [
1311
1323
self assert: scdbg topStack equals: 43
1312
1324
]
1313
1325
1326
+ { #category : #tests }
1327
+ SindarinDebuggerTest >> testSkipCanSkipReturnIfItIsNotTheLastReturn [
1328
+
1329
+ | scdbg |
1330
+ scdbg := SindarinDebugger debug: [ self methodWithSeveralReturns ].
1331
+
1332
+ " we step until we arrive on the node `^ a := 1` in `SindarinDebuggerTest>>#methodWithSeveralReturns`."
1333
+ scdbg
1334
+ step;
1335
+ skip;
1336
+ skip;
1337
+ step.
1338
+
1339
+ self assert: scdbg node isReturn.
1340
+ self assert: scdbg topStack equals: 1 .
1341
+
1342
+ " We skip the return node"
1343
+ self shouldnt: [ scdbg skip ] raise: SindarinSkippingReturnWarning .
1344
+
1345
+ " We should be on the `a := 2` node"
1346
+ self assert: scdbg node isAssignment.
1347
+ self assert: scdbg node value value equals: 2
1348
+ ]
1349
+
1350
+ { #category : #tests }
1351
+ SindarinDebuggerTest >> testSkipCannotSkipReturnIfItIsTheLastReturn [
1352
+
1353
+ | scdbg nodeWithImplicitReturn |
1354
+ scdbg := SindarinDebugger debug: [ self methodWithSeveralReturns ].
1355
+
1356
+ " we step until we arrive on the method node in `SindarinDebuggerTest>>#methodWithSeveralReturns`, which is mapped to the implicit return bycode."
1357
+ scdbg step.
1358
+ nodeWithImplicitReturn := scdbg methodNode.
1359
+ 3 timesRepeat: [ scdbg step ].
1360
+
1361
+ self assert: scdbg node identicalTo: nodeWithImplicitReturn.
1362
+ self assert: scdbg instructionStream willReturn.
1363
+
1364
+ " We skip the return node"
1365
+ self should: [ scdbg skip ] raise: SindarinSkippingReturnWarning .
1366
+
1367
+ " We should still be on the method node"
1368
+ self assert: scdbg node identicalTo: nodeWithImplicitReturn.
1369
+ self assert: scdbg instructionStream willReturn
1370
+ ]
1371
+
1314
1372
{ #category : #tests }
1315
1373
SindarinDebuggerTest >> testSkipDoesNotSkipReturn [
1316
1374
0 commit comments