Hi Folks, I seem to recall that we added TestCase>>assert:eauals: to SUnit, but now I cannot find it. It would be really useful to get decent error messages from equality tests (instead of "test failed", we would get "expected X but got Y"). Does anyone know what the story is? If it exists somewhere, I would like to add it to Pharo. If it doesn't exist anywhere, I would like to add it to Pharo. - on _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
please go ahead.
I thought we got assert:equals: Somebody should also have a look at SUnitExtensions one of these days. On Jul 7, 2009, at 3:58 PM, Oscar Nierstrasz wrote: > > Hi Folks, > > I seem to recall that we added TestCase>>assert:eauals: to SUnit, but > now I cannot find it. > > It would be really useful to get decent error messages from equality > tests (instead of "test failed", we would get "expected X but got Y"). > > Does anyone know what the story is? > > If it exists somewhere, I would like to add it to Pharo. > > If it doesn't exist anywhere, I would like to add it to Pharo. > > - on > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
OK, have posted issue 939 and will post the change shortly ... http://code.google.com/p/pharo/issues/detail?id=939 TestCase>>assert: actual equals: expected actual = expected ifFalse: [self signalFailure: 'Assertion failed. Expected: ' , expected printString , '; got: ' , actual printString] Is it better to send asString or printString? - on On 7 Jul 2009, at 17:11, Stéphane Ducasse wrote: > please go ahead. > I thought we got assert:equals: > > > Somebody should also have a look at SUnitExtensions one of these days. > > On Jul 7, 2009, at 3:58 PM, Oscar Nierstrasz wrote: > >> >> Hi Folks, >> >> I seem to recall that we added TestCase>>assert:eauals: to SUnit, but >> now I cannot find it. >> >> It would be really useful to get decent error messages from equality >> tests (instead of "test failed", we would get "expected X but got >> Y"). >> >> Does anyone know what the story is? >> >> If it exists somewhere, I would like to add it to Pharo. >> >> If it doesn't exist anywhere, I would like to add it to Pharo. >> >> - on >> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
> OK, have posted issue 939 and will post the change shortly ...
> > http://code.google.com/p/pharo/issues/detail?id=939 > > TestCase>>assert: actual equals: expected > actual = expected ifFalse: [self signalFailure: 'Assertion failed. > Expected: ' , expected printString > , '; got: ' , actual printString] > > Is it better to send asString or printString? printString I imagine. > > - on > > On 7 Jul 2009, at 17:11, Stéphane Ducasse wrote: > >> please go ahead. >> I thought we got assert:equals: >> >> >> Somebody should also have a look at SUnitExtensions one of these >> days. >> >> On Jul 7, 2009, at 3:58 PM, Oscar Nierstrasz wrote: >> >>> >>> Hi Folks, >>> >>> I seem to recall that we added TestCase>>assert:eauals: to SUnit, >>> but >>> now I cannot find it. >>> >>> It would be really useful to get decent error messages from equality >>> tests (instead of "test failed", we would get "expected X but got >>> Y"). >>> >>> Does anyone know what the story is? >>> >>> If it exists somewhere, I would like to add it to Pharo. >>> >>> If it doesn't exist anywhere, I would like to add it to Pharo. >>> >>> - on >>> >>> >>> _______________________________________________ >>> Pharo-project mailing list >>> [hidden email] >>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Oscar Nierstrasz
Apparently http://squeaksource.com/Testing/ already contains such a method, but sticks to the java convention. Regardless of which is better, it would be a bad idea to introduce an identically named method which reverse the argument order, so I suggest we stick to the implementation in the repository. !TestCase methodsFor: 'accessing' stamp: 'dc 4/2/2007 18:38'! assert: expected equals: actual ^ self assert: (expected = actual) description: (self comparingStringBetween: expected and: actual) ! ! !TestCase methodsFor: 'private' stamp: 'dc 4/2/2007 18:46'! comparingStringBetween: expected and: actual ^ String streamContents: [:stream | stream nextPutAll: 'Expected '; nextPutAll: (expected printStringLimitedTo: 10); nextPutAll: ' but was '; nextPutAll: (actual printStringLimitedTo: 10); nextPutAll: '.' ]! ! I would really like these methods in Pharo. dc is Damien Cassou, so this is license clean, I guess. Shall I publish just these methods to PharoInbox? - on On 7 Jul 2009, at 18:44, Oscar Nierstrasz wrote: > > OK, have posted issue 939 and will post the change shortly ... > > http://code.google.com/p/pharo/issues/detail?id=939 > > TestCase>>assert: actual equals: expected > actual = expected ifFalse: [self signalFailure: 'Assertion failed. > Expected: ' , expected printString > , '; got: ' , actual printString] > > Is it better to send asString or printString? > > - on > > On 7 Jul 2009, at 17:11, Stéphane Ducasse wrote: > >> please go ahead. >> I thought we got assert:equals: >> >> >> Somebody should also have a look at SUnitExtensions one of these >> days. >> >> On Jul 7, 2009, at 3:58 PM, Oscar Nierstrasz wrote: >> >>> >>> Hi Folks, >>> >>> I seem to recall that we added TestCase>>assert:eauals: to SUnit, >>> but >>> now I cannot find it. >>> >>> It would be really useful to get decent error messages from equality >>> tests (instead of "test failed", we would get "expected X but got >>> Y"). >>> >>> Does anyone know what the story is? >>> >>> If it exists somewhere, I would like to add it to Pharo. >>> >>> If it doesn't exist anywhere, I would like to add it to Pharo. >>> >>> - on >>> >>> >>> _______________________________________________ >>> Pharo-project mailing list >>> [hidden email] >>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > > _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Yes!
May be one day we will arrive to use packages published in other places but right now critical elements should be in one project. Oscar if you see other good addition please push them too. Stef PS: I do not why I can open MC repositories but I cannot publish there. On Jul 7, 2009, at 6:56 PM, Oscar Nierstrasz wrote: > > Apparently http://squeaksource.com/Testing/ already contains such a > method, but sticks to the java convention. Regardless of which is > better, it would be a bad idea to introduce an identically named > method which reverse the argument order, so I suggest we stick to the > implementation in the repository. > > !TestCase methodsFor: 'accessing' stamp: 'dc 4/2/2007 18:38'! > assert: expected equals: actual > ^ self > assert: (expected = actual) > description: (self comparingStringBetween: expected and: actual) > ! ! > > > !TestCase methodsFor: 'private' stamp: 'dc 4/2/2007 18:46'! > comparingStringBetween: expected and: actual > ^ String streamContents: [:stream | > stream > nextPutAll: 'Expected '; > nextPutAll: (expected printStringLimitedTo: 10); > nextPutAll: ' but was '; > nextPutAll: (actual printStringLimitedTo: 10); > nextPutAll: '.' > ]! ! > > I would really like these methods in Pharo. dc is Damien Cassou, so > this is license clean, I guess. > > Shall I publish just these methods to PharoInbox? > > - on > > On 7 Jul 2009, at 18:44, Oscar Nierstrasz wrote: > >> >> OK, have posted issue 939 and will post the change shortly ... >> >> http://code.google.com/p/pharo/issues/detail?id=939 >> >> TestCase>>assert: actual equals: expected >> actual = expected ifFalse: [self signalFailure: 'Assertion failed. >> Expected: ' , expected printString >> , '; got: ' , actual printString] >> >> Is it better to send asString or printString? >> >> - on >> >> On 7 Jul 2009, at 17:11, Stéphane Ducasse wrote: >> >>> please go ahead. >>> I thought we got assert:equals: >>> >>> >>> Somebody should also have a look at SUnitExtensions one of these >>> days. >>> >>> On Jul 7, 2009, at 3:58 PM, Oscar Nierstrasz wrote: >>> >>>> >>>> Hi Folks, >>>> >>>> I seem to recall that we added TestCase>>assert:eauals: to SUnit, >>>> but >>>> now I cannot find it. >>>> >>>> It would be really useful to get decent error messages from >>>> equality >>>> tests (instead of "test failed", we would get "expected X but got >>>> Y"). >>>> >>>> Does anyone know what the story is? >>>> >>>> If it exists somewhere, I would like to add it to Pharo. >>>> >>>> If it doesn't exist anywhere, I would like to add it to Pharo. >>>> >>>> - on >>>> >>>> >>>> _______________________________________________ >>>> Pharo-project mailing list >>>> [hidden email] >>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>> >>> >>> _______________________________________________ >>> Pharo-project mailing list >>> [hidden email] >>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> >> > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
If you are adding this it would be good to either add or review
existing implementation that checks the comparison is within a tolerance. This would be for asserting double values are close but not necessarily exact. I would rather we didn't get double comparison going through this method you describe which would be easy to do. Thanks mike On Tuesday, July 7, 2009, Stéphane Ducasse <[hidden email]> wrote: > Yes! > May be one day we will arrive to use packages published in other > places but right now > critical elements should be in one project. > Oscar if you see other good addition please push them too. > > Stef > > PS: I do not why I can open MC repositories but I cannot publish there. > > > On Jul 7, 2009, at 6:56 PM, Oscar Nierstrasz wrote: > >> >> Apparently http://squeaksource.com/Testing/ already contains such a >> method, but sticks to the java convention. Regardless of which is >> better, it would be a bad idea to introduce an identically named >> method which reverse the argument order, so I suggest we stick to the >> implementation in the repository. >> >> !TestCase methodsFor: 'accessing' stamp: 'dc 4/2/2007 18:38'! >> assert: expected equals: actual >> ^ self >> assert: (expected = actual) >> description: (self comparingStringBetween: expected and: actual) >> ! ! >> >> >> !TestCase methodsFor: 'private' stamp: 'dc 4/2/2007 18:46'! >> comparingStringBetween: expected and: actual >> ^ String streamContents: [:stream | >> stream >> nextPutAll: 'Expected '; >> nextPutAll: (expected printStringLimitedTo: 10); >> nextPutAll: ' but was '; >> nextPutAll: (actual printStringLimitedTo: 10); >> nextPutAll: '.' >> ]! ! >> >> I would really like these methods in Pharo. dc is Damien Cassou, so >> this is license clean, I guess. >> >> Shall I publish just these methods to PharoInbox? >> >> - on >> >> On 7 Jul 2009, at 18:44, Oscar Nierstrasz wrote: >> >>> >>> OK, have posted issue 939 and will post the change shortly ... >>> >>> http://code.google.com/p/pharo/issues/detail?id=939 >>> >>> TestCase>>assert: actual equals: expected >>> actual = expected ifFalse: [self signalFailure: 'Assertion failed. >>> Expected: ' , expected printString >>> , '; got: ' , actual printString] >>> >>> Is it better to send asString or printString? >>> >>> - on >>> >>> On 7 Jul 2009, at 17:11, Stéphane Ducasse wrote: >>> >>>> please go ahead. >>>> I thought we got assert:equals: >>>> >>>> >>>> Somebody should also have a look at SUnitExtensions one of these >>>> days. >>>> >>>> On Jul 7, 2009, at 3:58 PM, Oscar Nierstrasz wrote: >>>> >>>>> >>>>> Hi Folks, >>>>> >>>>> I seem to recall that we added TestCase>>assert:eauals: to SUnit, >>>>> but >>>>> now I cannot find it. >>>>> >>>>> It would be really useful to get decent error messages from >>>>> equality >>>>> tests (instead of "test failed", we would get "expected X but got >>>>> Y"). >>>>> >>>>> Does anyone know what the story is? >>>>> >>>>> If it exists somewhere, I would like to add it to Pharo. >>>>> >>>>> If it doesn't exist anywhere, I would like to add it to Pharo. >>>>> >>>>> - on >>>>> >>>>> >>>>> _______________________________________________ >>>>> Pharo-project mailing list >>>>> [hidden email] >>>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>>> >>>> >>>> _______________________________________________ >>>> Pharo-project mailing list >>>> [hidden email] >>>> http://lists.gforge.inria.fr/ <http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project> _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Stéphane Ducasse
OK, done. - on On 7 Jul 2009, at 19:11, Stéphane Ducasse wrote: > Yes! > May be one day we will arrive to use packages published in other > places but right now > critical elements should be in one project. > Oscar if you see other good addition please push them too. > > Stef > > PS: I do not why I can open MC repositories but I cannot publish > there. > > > On Jul 7, 2009, at 6:56 PM, Oscar Nierstrasz wrote: > >> >> Apparently http://squeaksource.com/Testing/ already contains such a >> method, but sticks to the java convention. Regardless of which is >> better, it would be a bad idea to introduce an identically named >> method which reverse the argument order, so I suggest we stick to the >> implementation in the repository. >> >> !TestCase methodsFor: 'accessing' stamp: 'dc 4/2/2007 18:38'! >> assert: expected equals: actual >> ^ self >> assert: (expected = actual) >> description: (self comparingStringBetween: expected and: actual) >> ! ! >> >> >> !TestCase methodsFor: 'private' stamp: 'dc 4/2/2007 18:46'! >> comparingStringBetween: expected and: actual >> ^ String streamContents: [:stream | >> stream >> nextPutAll: 'Expected '; >> nextPutAll: (expected printStringLimitedTo: 10); >> nextPutAll: ' but was '; >> nextPutAll: (actual printStringLimitedTo: 10); >> nextPutAll: '.' >> ]! ! >> >> I would really like these methods in Pharo. dc is Damien Cassou, so >> this is license clean, I guess. >> >> Shall I publish just these methods to PharoInbox? >> >> - on >> >> On 7 Jul 2009, at 18:44, Oscar Nierstrasz wrote: >> >>> >>> OK, have posted issue 939 and will post the change shortly ... >>> >>> http://code.google.com/p/pharo/issues/detail?id=939 >>> >>> TestCase>>assert: actual equals: expected >>> actual = expected ifFalse: [self signalFailure: 'Assertion failed. >>> Expected: ' , expected printString >>> , '; got: ' , actual printString] >>> >>> Is it better to send asString or printString? >>> >>> - on >>> >>> On 7 Jul 2009, at 17:11, Stéphane Ducasse wrote: >>> >>>> please go ahead. >>>> I thought we got assert:equals: >>>> >>>> >>>> Somebody should also have a look at SUnitExtensions one of these >>>> days. >>>> >>>> On Jul 7, 2009, at 3:58 PM, Oscar Nierstrasz wrote: >>>> >>>>> >>>>> Hi Folks, >>>>> >>>>> I seem to recall that we added TestCase>>assert:eauals: to SUnit, >>>>> but >>>>> now I cannot find it. >>>>> >>>>> It would be really useful to get decent error messages from >>>>> equality >>>>> tests (instead of "test failed", we would get "expected X but got >>>>> Y"). >>>>> >>>>> Does anyone know what the story is? >>>>> >>>>> If it exists somewhere, I would like to add it to Pharo. >>>>> >>>>> If it doesn't exist anywhere, I would like to add it to Pharo. >>>>> >>>>> - on >>>>> >>>>> >>>>> _______________________________________________ >>>>> Pharo-project mailing list >>>>> [hidden email] >>>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo- >>>>> project >>>> >>>> >>>> _______________________________________________ >>>> Pharo-project mailing list >>>> [hidden email] >>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>> >>> >> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Michael Roberts-2
Hi Mike, I don't understand. assert:equals: should only be used for exact equality tests, not for comparing doubles. Doubles should never go through this method. Existing tests won't know about assert:equals: Did I misunderstand you? - on On 7 Jul 2009, at 19:24, Michael Roberts wrote: > If you are adding this it would be good to either add or review > existing implementation that checks the comparison is within a > tolerance. This would be for asserting double values are close but not > necessarily exact. I would rather we didn't get double comparison > going through this method you describe which would be easy to do. > > Thanks > mike _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
No you understand certainly, I wasn't clear. If we provide a nice api
for comparing things are equal it would be a shame to not provide the convenience for doubles. Newcomers to the environment would not necessarily understand the pitfalls of testing equality on doubles. Thus providing convenience in one area could look very attractive in the general case if there are no other methods hinting their appropriate use. I'm sure such a method has already been written in a repository somewhere . I just thought it would be good to put them in together. That make sense? Mike On Tuesday, July 7, 2009, Oscar Nierstrasz <[hidden email]> wrote: > > Hi Mike, > > I don't understand. assert:equals: should only be used for exact > equality tests, not for comparing doubles. > > Doubles should never go through this method. > > Existing tests won't know about assert:equals: > > Did I misunderstand you? > > - on > > On 7 Jul 2009, at 19:24, Michael Roberts wrote: > >> If you are adding this it would be good to either add or review >> existing implementation that checks the comparison is within a >> tolerance. This would be for asserting double values are close but not >> necessarily exact. I would rather we didn't get double comparison >> going through this method you describe which would be easy to do. >> >> Thanks >> mike > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
OK, got it. I should have closer look at http://squeaksource.com/Testing/ too. Cheers, - on On 8 Jul 2009, at 00:05, Michael Roberts wrote: > No you understand certainly, I wasn't clear. If we provide a nice api > for comparing things are equal it would be a shame to not provide the > convenience for doubles. Newcomers to the environment would not > necessarily understand the pitfalls of testing equality on doubles. > Thus providing convenience in one area could look very attractive in > the general case if there are no other methods hinting their > appropriate use. I'm sure such a method has already been written in a > repository somewhere . I just thought it would be good to put them in > together. That make sense? > > Mike > > On Tuesday, July 7, 2009, Oscar Nierstrasz <[hidden email]> wrote: >> >> Hi Mike, >> >> I don't understand. assert:equals: should only be used for exact >> equality tests, not for comparing doubles. >> >> Doubles should never go through this method. >> >> Existing tests won't know about assert:equals: >> >> Did I misunderstand you? >> >> - on >> >> On 7 Jul 2009, at 19:24, Michael Roberts wrote: >> >>> If you are adding this it would be good to either add or review >>> existing implementation that checks the comparison is within a >>> tolerance. This would be for asserting double values are close but >>> not >>> necessarily exact. I would rather we didn't get double comparison >>> going through this method you describe which would be easy to do. >>> >>> Thanks >>> mike >> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Free forum by Nabble | Edit this page |