Re: Magritte-Seaside and validation errors

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Magritte-Seaside and validation errors

Paolo Bonzini-2
I think this is because Magritte makes very demanding use of exceptions.
 It might be that Squeak and GNU Smalltalk behave in a different way.

Can you try filing in the attached class and then evaluating:

{TestError new resumableTest: #halt outerHandler: #yourself.
TestError new resumableTest: #halt outerHandler: #resume.
TestError new beResumable; resumableTest: #pass outerHandler: #yourself.
TestError new beResumable; resumableTest: #pass outerHandler: #resume.
TestError new beResumable; resumableTest: #outer outerHandler: #yourself.
TestError new beResumable; resumableTest: #outer outerHandler: #resume.
TestError new beResumable; resumableTest: #resumeOuter outerHandler:
#yourself.
TestError new beResumable; resumableTest: #resumeOuter outerHandler:
#resume}

under Squeak?

Thanks,

Paolo



Error subclass: #TestError
        instanceVariableNames: 'resumable'
        classVariableNames: ''
        poolDictionaries: ''
        category: ''!

!TestError methodsFor: 'testing'!

isResumable
        ^resumable ifNil: [ false ]
!

beResumable
        resumable := true
!

description
        ^'test'
!

resumeOuter
        self resume: self outer
!

resumableTest: ifResumableSymbol outerHandler: outerHandlerSymbol
        [[ self signal. ^true ]
                on: TestError
                do: [ :err |
                        err isResumable
                                ifTrue: [err perform: ifResumableSymbol]
                                ifFalse: [err beResumable; signal]]]
                on: TestError
                do: [ :err | err perform: outerHandlerSymbol ].
        ^false
! !



_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Re: Magritte-Seaside and validation errors

Paolo Bonzini-2
Nicolas Petton wrote:

> Le lundi 04 mai 2009 à 12:50 +0200, Paolo Bonzini a écrit :
>> I think this is because Magritte makes very demanding use of exceptions.
>>  It might be that Squeak and GNU Smalltalk behave in a different way.
>>
>> Can you try filing in the attached class and then evaluating:
>>
>> {TestError new resumableTest: #halt outerHandler: #yourself.
>> TestError new resumableTest: #halt outerHandler: #resume.
>> TestError new beResumable; resumableTest: #pass outerHandler: #yourself.
>> TestError new beResumable; resumableTest: #pass outerHandler: #resume.
>> TestError new beResumable; resumableTest: #outer outerHandler: #yourself.
>> TestError new beResumable; resumableTest: #outer outerHandler: #resume.
>> TestError new beResumable; resumableTest: #resumeOuter outerHandler:
>> #yourself.
>> TestError new beResumable; resumableTest: #resumeOuter outerHandler:
>> #resume}
>>
>> under Squeak?
>
> Sure, but what differences between gst and Squeak should I be looking
> for?

The output for GNU Smalltalk is

(false false false false false false true true )

Magritte uses something that resembles the third or fourth element of
the array, but any difference is sign of a different implementation
and/or a bug in GNU Smalltalk.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Re: Magritte-Seaside and validation errors

Lukas Renggli
Cool test ;-)

I get  #(false false false true false false false true) in Pharo
#10126 (that's an old version).

The validation code is really ugly. It started out simple, but then
got incredibly complicated and fragile over time. I already fixed many
bugs that appeared in edge cases. Maybe we should instead just try to
fix Magritte instead?

Lukas

On Mon, May 4, 2009 at 3:09 PM, Paolo Bonzini <[hidden email]> wrote:

> Nicolas Petton wrote:
>> Le lundi 04 mai 2009 à 12:50 +0200, Paolo Bonzini a écrit :
>>> I think this is because Magritte makes very demanding use of exceptions.
>>>  It might be that Squeak and GNU Smalltalk behave in a different way.
>>>
>>> Can you try filing in the attached class and then evaluating:
>>>
>>> {TestError new resumableTest: #halt outerHandler: #yourself.
>>> TestError new resumableTest: #halt outerHandler: #resume.
>>> TestError new beResumable; resumableTest: #pass outerHandler: #yourself.
>>> TestError new beResumable; resumableTest: #pass outerHandler: #resume.
>>> TestError new beResumable; resumableTest: #outer outerHandler: #yourself.
>>> TestError new beResumable; resumableTest: #outer outerHandler: #resume.
>>> TestError new beResumable; resumableTest: #resumeOuter outerHandler:
>>> #yourself.
>>> TestError new beResumable; resumableTest: #resumeOuter outerHandler:
>>> #resume}
>>>
>>> under Squeak?
>>
>> Sure, but what differences between gst and Squeak should I be looking
>> for?
>
> The output for GNU Smalltalk is
>
> (false false false false false false true true )
>
> Magritte uses something that resembles the third or fourth element of
> the array, but any difference is sign of a different implementation
> and/or a bug in GNU Smalltalk.
>
> Paolo
>
>
> _______________________________________________
> help-smalltalk mailing list
> [hidden email]
> http://lists.gnu.org/mailman/listinfo/help-smalltalk
>



--
Lukas Renggli
http://www.lukas-renggli.ch


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Re: Magritte-Seaside and validation errors

Paolo Bonzini-2
> I get  #(false false false true false false false true) in Pharo
> #10126 (that's an old version).

Interesting.  I'll dig the standard to understand who's right and then
maybe post on the squeak ML.

> The validation code is really ugly. It started out simple, but then
> got incredibly complicated and fragile over time. I already fixed many
> bugs that appeared in edge cases. Maybe we should instead just try to
> fix Magritte instead?

Yes, I'll try to make a patch to Magritte to use the last case, that
is using "ex resume: ex outer" instead of "ex pass", and see if it
fixes Magritte-Seaside.

In the meanwhile can you add a testcase to Magritte exercising this
problem somehow (i.e. emulating what Magritte-Seaside does)?

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Magritte-Seaside and validation errors

Paolo Bonzini-2
In reply to this post by Lukas Renggli
Lukas Renggli wrote:
> Cool test ;-)
>
> I get  #(false false false true false false false true) in Pharo
> #10126 (that's an old version).
>
> The validation code is really ugly. It started out simple, but then
> got incredibly complicated and fragile over time. I already fixed many
> bugs that appeared in edge cases. Maybe we should instead just try to
> fix Magritte instead?

Cool test, but I was off track. :-)  The case that is hit by Magritte is
the #ifFalse: one: the exception is created non-resumable, and made
resumable and resignaled within the handler.  Now, if I understand
correctly the ugliness is there to allow restarting to the test for
another field, but at the same time avoiding an MARequiredError and an
MAKindError for the same field.

Thus, I took Nico's description and modified to use, instead of required
MAStringDescriptions, a pair of required integer MANumberDescription.
Then, just using this simpler code seems to work as I cannot get it to
emit more than two errors:

diff --git a/packages/magritte/magritte-model.st
b/packages/magritte/magritte-model.st
index 0f05d99..0c93469 100644
--- a/packages/magritte/magritte-model.st
+++ b/packages/magritte/magritte-model.st
@@ -5507,13 +5507,9 @@ MAValidatorVisitor>>#visitDescription:
        <category: 'visiting-descriptions'>
        [self validate: self object using: aDescription] on:
MAValidationError
            do:
-               [:err |
-               err isResumable
-                   ifTrue: [err pass]
-                   ifFalse:
-                       [err
-                           beResumable;
-                           signal]]
+               [:err |
+               err isResumable ifFalse: [err beResumable].
+               err pass]
     ]

     visitTableDescription: aDescription [

and all the unit tests still pass.  I'm a bit puzzled, maybe you were
working around some issue in Squeak or maybe GNU Smalltalk has a bug?

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Magritte-Seaside and validation errors

Lukas Renggli
I applied the patch to Squeak and it seems to work correctly. Also the
Pier tests pass, they further exercise the validation stuff.

I committed your changes as Magritte-Model-lr.345.

Cheers,
Lukas

On Tue, May 5, 2009 at 11:54 AM, Paolo Bonzini <[hidden email]> wrote:

> Lukas Renggli wrote:
>> Cool test ;-)
>>
>> I get  #(false false false true false false false true) in Pharo
>> #10126 (that's an old version).
>>
>> The validation code is really ugly. It started out simple, but then
>> got incredibly complicated and fragile over time. I already fixed many
>> bugs that appeared in edge cases. Maybe we should instead just try to
>> fix Magritte instead?
>
> Cool test, but I was off track. :-)  The case that is hit by Magritte is
> the #ifFalse: one: the exception is created non-resumable, and made
> resumable and resignaled within the handler.  Now, if I understand
> correctly the ugliness is there to allow restarting to the test for
> another field, but at the same time avoiding an MARequiredError and an
> MAKindError for the same field.
>
> Thus, I took Nico's description and modified to use, instead of required
> MAStringDescriptions, a pair of required integer MANumberDescription.
> Then, just using this simpler code seems to work as I cannot get it to
> emit more than two errors:
>
> diff --git a/packages/magritte/magritte-model.st
> b/packages/magritte/magritte-model.st
> index 0f05d99..0c93469 100644
> --- a/packages/magritte/magritte-model.st
> +++ b/packages/magritte/magritte-model.st
> @@ -5507,13 +5507,9 @@ MAValidatorVisitor>>#visitDescription:
>        <category: 'visiting-descriptions'>
>        [self validate: self object using: aDescription] on:
> MAValidationError
>            do:
> -               [:err |
> -               err isResumable
> -                   ifTrue: [err pass]
> -                   ifFalse:
> -                       [err
> -                           beResumable;
> -                           signal]]
> +               [:err |
> +               err isResumable ifFalse: [err beResumable].
> +               err pass]
>     ]
>
>     visitTableDescription: aDescription [
>
> and all the unit tests still pass.  I'm a bit puzzled, maybe you were
> working around some issue in Squeak or maybe GNU Smalltalk has a bug?
>
> Paolo
>



--
Lukas Renggli
http://www.lukas-renggli.ch


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk