exercism / pharo-smalltalk

Exercism exercises in Pharo.
https://exercism.org/tracks/pharo-smalltalk
MIT License
34 stars 28 forks source link

Fix TonelParser to return correct error when parsing empty file #614

Closed Bajger closed 8 months ago

Bajger commented 8 months ago

This issue occur on Test runner, but is caused by core Pharo image behavior of TonelParser (consequently read stream positioning set to 0). Problem described here: https://github.com/pharo-project/pharo/issues/16267

Solution Until behavior on Pharo project is fixed, will overload TonelParser method by guard clause: Current:

TonelParser>>try: aBlock onSuccess: successBlock onFailure: failureBlock
    | pos |

    pos := stream position.
    [ ^ successBlock value: aBlock value ]
    on: TonelParseError
    do: [ :e |
        stream position: pos.
        ^ failureBlock value ].

New:

TonelParser>>try: aBlock onSuccess: successBlock onFailure: failureBlock
    | pos |

    pos := stream position.
    [ ^ successBlock value: aBlock value ]
    on: TonelParseError
    do: [ :e |
        stream position > pos ifTrue: [stream position: pos].
        ^ failureBlock value ].