Skip to content

Commit

Permalink
Fix error result not returned correctly (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
smarr authored Jan 26, 2024
2 parents 0aaad53 + 42c7d15 commit 4bbe094
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Smalltalk/Vector.som
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Vector = (
"Removing"
remove = (
| value |
self isEmpty ifTrue: [ self error: 'Vector: Attempting to remove the last element from an empty Vector' ].
self isEmpty ifTrue: [ ^ self error: 'Vector: Attempting to remove the last element from an empty Vector' ].
last := last - 1.
value := storage at: last.
storage at: last put: nil.
Expand Down Expand Up @@ -158,7 +158,7 @@ Vector = (
"DeltaBlue"
removeFirst = (
| value |
self isEmpty ifTrue: [ self error: 'Vector: Attempting to remove the first element from an empty Vector' ].
self isEmpty ifTrue: [ ^ self error: 'Vector: Attempting to remove the first element from an empty Vector' ].
value := storage at: first.
storage at: first put: nil.
first := first + 1.
Expand Down
5 changes: 5 additions & 0 deletions TestSuite/VectorSubclass.som
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
VectorSubclass = Vector (
error: string = (
^ #error
)
)
12 changes: 12 additions & 0 deletions TestSuite/VectorTest.som
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ VectorTest = TestCase (
v remove ]
)

testRemoveOnEmptyWithSubclass = (
| v |
v := VectorSubclass new.
self assert: #error is: v remove.
)

testRemoveFirstOnEmptyWithSubclass = (
| v |
v := VectorSubclass new.
self assert: #error is: v removeFirst.
)

testContains = (
self assert: (a contains: 'hello').
self assert: (a contains: #world).
Expand Down

0 comments on commit 4bbe094

Please sign in to comment.