I agree this exception should be more specific.

By the way one needs to update all the primitive mutating objects, such as
at:put:, so that when it fails because it attempts to mutate a read-only
object a proper error is raised instead of SubscriptOutOfBounds with an
in-bound index.

Maybe an intern can create a specific error for your case, add an error for
read-only object and write / update tests for everything.

On Sun, Jan 22, 2017 at 6:28 PM, stepharong <[email protected]> wrote:

> When I read that, I thought that errorNotIndexable would raise an
> Exception different from Error.
> But this is not the case and it means that people should write not so good
> tests by checking Error
> instead of a concrete Exception.
>
> [[[
> MyExampleSetTest >> testIllegal
>         self should: [ empty at: 5 ] raise: Error.
>         self should: [ empty at: 5 put: #zork ] raise: Error
> ]]]
> We even have a rule that states that we should not catch on Error
>
>
> at: index
>         "Primitive. Assumes receiver is indexable. Answer the value of an
>         indexable element in the receiver. Fail if the argument index is
> not an
>         Integer or is out of bounds. Essential. See Object documentation
>         whatIsAPrimitive. Read the class comment for a discussion about
> that the fact
>         that the index can be a float."
>
>         <primitive: 60>
>         index isInteger ifTrue:
>                 [self class isVariable
>                         ifTrue: [self errorSubscriptBounds: index]
>                         ifFalse: [self errorNotIndexable]].
>         index isNumber
>                 ifTrue: [^self at: index asInteger]
>                 ifFalse: [self errorNonIntegerIndex]
>
> thoughts comments?
>
>

Reply via email to