Skip to content

Commit

Permalink
Adapt whenNumberChangedDo: to use two argument block
Browse files Browse the repository at this point in the history
Add test
  • Loading branch information
hernanmd committed Nov 18, 2024
1 parent 1d71813 commit 20ba299
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Spec2-Core/SpNumberInputFieldPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ SpNumberInputFieldPresenter >> whenNumberChangedDo: aBlock [
- old value
- the announcement triggering this action"

self whenTextChangedDo: [ :txt | aBlock value: self number ]
self whenTextChangedDo: [ :newValue :oldValue | aBlock cull: self number cull: newValue ]
]

{ #category : 'api - events' }
Expand Down
10 changes: 10 additions & 0 deletions src/Spec2-Tests/SpNumberInputFieldPresenterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ SpNumberInputFieldPresenterTest >> testWhenNumberChangedDo [
self assert: result equals: 10
]

{ #category : 'tests' }
SpNumberInputFieldPresenterTest >> testWhenNumberChangedDo2Arguments [

presenter
number: 10;
whenNumberChangedDo: [ :newValue :oldValue | self deny: newValue equals: oldValue ].
presenter number: 32.

]

{ #category : 'tests' }
SpNumberInputFieldPresenterTest >> testWhenNumberTypeChangedDo [
| count result |
Expand Down

0 comments on commit 20ba299

Please sign in to comment.