assert:equals: in Object

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

Re: assert:equals: in Object

Christoph Thiede

Well, not sure it makes sense to have an image without SUnit.


IMO, definitively if you have a server image for production purposes only.


Best,

Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von Taeumel, Marcel
Gesendet: Montag, 26. Oktober 2020 07:40:06
An: squeak-dev
Betreff: Re: [squeak-dev] assert:equals: in Object
 
A situation where SUnit and all the tests are not necessarily loaded.

Hmm... maybe we might consider adding an SUnit-Core? Well, not sure it makes sense to have an image without SUnit. But then you might want to also strip, e.g., network support to shrink the image file a little bit more. :-)

Best,
Marcel

Am 24.10.2020 13:01:30 schrieb H. Hirzel <[hidden email]>:

On 10/9/20, Tony Garnock-Jones wrote:
> Hi Christoph,
>
> On 10/9/20 4:53 PM, Thiede, Christoph wrote:
>>> Anyway, having it by default be the case that Workspaces'
>> code environments be TestCases seems very sensible to me.
>>
>> What do you mean by this? Such a TestCase receiver environment should
>> definitively be not the default, this would be very confusing!
>
> Oh interesting! What kind of confusion do you foresee? I had just
> imagined that the only visible-ish change would be availability of
> TestCase instance-side methods on the "self" in the Workspace.
>
>>> "Assertions [...] MUST BE LEFT ACTIVE IN
>>> PRODUCTION CODE


>> Are we on the same page now? :-)
>
> Yes, I think we are! :-) Thanks.
>
> Tony

I consider that assertions are useful to have in the production code
an an argument in favor of having

assert:equals:description:

implemented the class Object. A situation where SUnit and all the
tests are not necessarily loaded.

--Hannes



Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: assert:equals: in Object

marcel.taeumel
IMO, definitively if you have a server image for production purposes only.

Well, only if you really need the resources. Because the need for debugging can arise anytime, anywhere ... ;-)

Best,
Marcel

Am 26.10.2020 14:14:09 schrieb Thiede, Christoph <[hidden email]>:

Well, not sure it makes sense to have an image without SUnit.


IMO, definitively if you have a server image for production purposes only.


Best,

Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von Taeumel, Marcel
Gesendet: Montag, 26. Oktober 2020 07:40:06
An: squeak-dev
Betreff: Re: [squeak-dev] assert:equals: in Object
 
A situation where SUnit and all the tests are not necessarily loaded.

Hmm... maybe we might consider adding an SUnit-Core? Well, not sure it makes sense to have an image without SUnit. But then you might want to also strip, e.g., network support to shrink the image file a little bit more. :-)

Best,
Marcel

Am 24.10.2020 13:01:30 schrieb H. Hirzel <[hidden email]>:

On 10/9/20, Tony Garnock-Jones wrote:
> Hi Christoph,
>
> On 10/9/20 4:53 PM, Thiede, Christoph wrote:
>>> Anyway, having it by default be the case that Workspaces'
>> code environments be TestCases seems very sensible to me.
>>
>> What do you mean by this? Such a TestCase receiver environment should
>> definitively be not the default, this would be very confusing!
>
> Oh interesting! What kind of confusion do you foresee? I had just
> imagined that the only visible-ish change would be availability of
> TestCase instance-side methods on the "self" in the Workspace.
>
>>> "Assertions [...] MUST BE LEFT ACTIVE IN
>>> PRODUCTION CODE


>> Are we on the same page now? :-)
>
> Yes, I think we are! :-) Thanks.
>
> Tony

I consider that assertions are useful to have in the production code
an an argument in favor of having

assert:equals:description:

implemented the class Object. A situation where SUnit and all the
tests are not necessarily loaded.

--Hannes



Reply | Threaded
Open this post in threaded view
|

Re: assert:equals: in Object

timrowledge
In reply to this post by marcel.taeumel


> On 2020-10-25, at 11:40 PM, Marcel Taeumel <[hidden email]> wrote:
>
> > A situation where SUnit and all the tests are not necessarily loaded.
>
> Hmm... maybe we might consider adding an SUnit-Core? Well, not sure it makes sense to have an image without SUnit. But then you might want to also strip, e.g., network support to shrink the image file a little bit more. :-)

Once upon a time that was a big deal because memory was short. Given that I have been sent almost content-free Word documents that take up more space than a well loaded Squeak image, I suggest we probably don't need to care so much these days.

It offends my CDO (OCD but the letters in *the right order*), but that's the reality.


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
It said, "Insert disk #3," but only two will fit!



Reply | Threaded
Open this post in threaded view
|

Re: assert:equals: in Object

Hannes Hirzel
Hi Tim

Not fully sure what you mean, probably not
     cod (a type of fish)
     cod (cash on delivery)
     doc (the extension of an MS Word file which these days might
often be larger than a Squeak image)

:-)


a) As for the original proposal from Eliot which started this thread,
what is your conclusion?
and / or related to this


My impression is that Eliot's main concern is a smooth workflow in
moving code back and forth from an SUnit test to a workspace. As this
discussion shows this may also be adressed on the workspace level.


But for the moment he says that adding one method to class Object would help him

--Hannes


Details:
----------

A Squeak 5.3 release image has out of the box

Object subclass: #TestCase
        instanceVariableNames: 'testSelector timeout'
        classVariableNames: ''
        poolDictionaries: ''
        category: 'SUnit-Kernel'



assert: aBooleanOrBlock

        aBooleanOrBlock value ifFalse: [self signalFailure: 'Assertion failed']
       

       
assert: aBooleanOrBlock description: aStringOrBlock

        aBooleanOrBlock value ifFalse: [
                | description |
                description := aStringOrBlock value.
                self logFailure: description.
                TestResult failure signal: description ]
       
       

assert: expected equals: actual

        ^self
                assert: expected = actual
                description: [ self comparingStringBetween: expected and: actual ]


assert: expected equals: actual description: aString

        ^self
                assert: expected = actual
                description: [ aString , ': ', (self comparingStringBetween:
expected and: actual) ]
       

               
Meanwhile class Object has

assert: aBlock
        "Throw an assertion error if aBlock does not evaluates to true."

        aBlock value ifFalse: [AssertionFailure signal: 'Assertion failed']


assert: aBlock description: aStringOrBlock
        "Throw an assertion error if aBlock does not evaluates to true."

        aBlock value ifFalse: [ AssertionFailure signal: aStringOrBlock value ]


assert: aBlock descriptionBlock: descriptionBlock
        "Throw an assertion error if aBlock does not evaluate to true."

        aBlock value ifFalse: [AssertionFailure signal: descriptionBlock
value asString ]
       
       
but no
               

assert: expected equals: actual


And this is the main request by Eliot: to have this method

assert: expected equals: actual


also in class object as I understand it.

As for me -- no objection to that.


On 10/26/20, tim Rowledge <[hidden email]> wrote:

>
>
>> On 2020-10-25, at 11:40 PM, Marcel Taeumel <[hidden email]> wrote:
>>
>> > A situation where SUnit and all the tests are not necessarily loaded.
>>
>> Hmm... maybe we might consider adding an SUnit-Core? Well, not sure it
>> makes sense to have an image without SUnit. But then you might want to
>> also strip, e.g., network support to shrink the image file a little bit
>> more. :-)
>
> Once upon a time that was a big deal because memory was short. Given that I
> have been sent almost content-free Word documents that take up more space
> than a well loaded Squeak image, I suggest we probably don't need to care so
> much these days.
>
> It offends my CDO (OCD but the letters in *the right order*), but that's the
> reality.
>
>
> tim
> --
> tim Rowledge; [hidden email]; http://www.rowledge.org/tim
> It said, "Insert disk #3," but only two will fit!
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: assert:equals: in Object

Eliot Miranda-2
Hi Hannes,

> On Oct 26, 2020, at 2:46 PM, H. Hirzel <[hidden email]> wrote:
>
> Hi Tim
>
> Not fully sure what you mean, probably not
>     cod (a type of fish)
>     cod (cash on delivery)
>     doc (the extension of an MS Word file which these days might
> often be larger than a Squeak image)
>
> :-)
>
>
> a) As for the original proposal from Eliot which started this thread,
> what is your conclusion?
> and / or related to this
>
>
> My impression is that Eliot's main concern is a smooth workflow in
> moving code back and forth from an SUnit test to a workspace. As this
> discussion shows this may also be adressed on the workspace level.
>
>
> But for the moment he says that adding one method to class Object would help him

My response earlier in got lost.  I realized that the issue is my own incompetence.  Instead if using a regular workspace one can use an inspector on the test case itself.  

I suppose the nice extension would be to allow one to define a default receiver for a Workspace other than nil.  This is simply a UI convenience; there is less visual noise in using a workspace than an inspector.  Conceptually alongside the allow automatic variable declaration/reset workspace variables menu items one could have a “specify default receiver via doit...” entry and store the default receiver in the variables dictionary.  Resetting variables would have the side effect of resetting the default receiver back to nil.

But it isn’t a big deal.  What I should do is try and get it into my head that I can always run doits in an inspector if I want to get at a specific class’s protocol.

_,,,^..^,,,_ (phone)

>
> --Hannes
>
>
> Details:
> ----------
>
> A Squeak 5.3 release image has out of the box
>
> Object subclass: #TestCase
>    instanceVariableNames: 'testSelector timeout'
>    classVariableNames: ''
>    poolDictionaries: ''
>    category: 'SUnit-Kernel'
>
>
>
> assert: aBooleanOrBlock
>
>    aBooleanOrBlock value ifFalse: [self signalFailure: 'Assertion failed']    
>    
>
>    
> assert: aBooleanOrBlock description: aStringOrBlock
>
>    aBooleanOrBlock value ifFalse: [
>        | description |
>        description := aStringOrBlock value.
>        self logFailure: description.
>        TestResult failure signal: description ]
>    
>    
>
> assert: expected equals: actual
>
>    ^self
>        assert: expected = actual
>        description: [ self comparingStringBetween: expected and: actual ]    
>
>
> assert: expected equals: actual description: aString
>
>    ^self
>        assert: expected = actual
>        description: [ aString , ': ', (self comparingStringBetween:
> expected and: actual) ]
>    
>
>        
> Meanwhile class Object has
>
> assert: aBlock
>    "Throw an assertion error if aBlock does not evaluates to true."
>
>    aBlock value ifFalse: [AssertionFailure signal: 'Assertion failed']
>
>
> assert: aBlock description: aStringOrBlock
>    "Throw an assertion error if aBlock does not evaluates to true."
>
>    aBlock value ifFalse: [ AssertionFailure signal: aStringOrBlock value ]
>
>
> assert: aBlock descriptionBlock: descriptionBlock
>    "Throw an assertion error if aBlock does not evaluate to true."
>
>    aBlock value ifFalse: [AssertionFailure signal: descriptionBlock
> value asString ]
>    
>    
> but no
>        
>
> assert: expected equals: actual
>
>
> And this is the main request by Eliot: to have this method
>
> assert: expected equals: actual
>
>
> also in class object as I understand it.
>
> As for me -- no objection to that.
>
>
>> On 10/26/20, tim Rowledge <[hidden email]> wrote:
>>
>>
>>>> On 2020-10-25, at 11:40 PM, Marcel Taeumel <[hidden email]> wrote:
>>>
>>>> A situation where SUnit and all the tests are not necessarily loaded.
>>>
>>> Hmm... maybe we might consider adding an SUnit-Core? Well, not sure it
>>> makes sense to have an image without SUnit. But then you might want to
>>> also strip, e.g., network support to shrink the image file a little bit
>>> more. :-)
>>
>> Once upon a time that was a big deal because memory was short. Given that I
>> have been sent almost content-free Word documents that take up more space
>> than a well loaded Squeak image, I suggest we probably don't need to care so
>> much these days.
>>
>> It offends my CDO (OCD but the letters in *the right order*), but that's the
>> reality.
>>
>>
>> tim
>> --
>> tim Rowledge; [hidden email]; http://www.rowledge.org/tim
>> It said, "Insert disk #3," but only two will fit!
>>
>>
>>
>>
>

12