Grease testSeconds is failing in Squeak 4.3 and Pharo 1.4

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

Grease testSeconds is failing in Squeak 4.3 and Pharo 1.4

Nicolas Cellier
In all Smalltalk, (2/1) is automatically reduced to a canonical Integer
representation.
Nonetheless it is also a fraction.

1) Since all Integer are special kind of fraction and are polymorphic to
fraction in Squeak and Pharo (responds to numerator, denominator, fractionPart
etc...)
2) and since doing so both simplify and speed up some arithmetic code,

Squeak and Pharo (2 isFraction) now answer true.

One consequence is a failing Grease test (GRPlatformTest>>testSeconds)

    self deny: Time now seconds isFraction.

The purpose is to test that no fractional seconds get returned.
I suggest rewriting:

    self deny: (Time now seconds isKindOf: Fraction).

which should be fairly portable

Nicolas

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Grease testSeconds is failing in Squeak 4.3 and Pharo 1.4

Philippe Marschall
2012/2/20 nicolas cellier <[hidden email]>:

> In all Smalltalk, (2/1) is automatically reduced to a canonical Integer
> representation.
> Nonetheless it is also a fraction.
>
> 1) Since all Integer are special kind of fraction and are polymorphic to
> fraction in Squeak and Pharo (responds to numerator, denominator, fractionPart
> etc...)
> 2) and since doing so both simplify and speed up some arithmetic code,
>
> Squeak and Pharo (2 isFraction) now answer true.
>
> One consequence is a failing Grease test (GRPlatformTest>>testSeconds)
>
>    self deny: Time now seconds isFraction.
>
> The purpose is to test that no fractional seconds get returned.
> I suggest rewriting:
>
>    self deny: (Time now seconds isKindOf: Fraction).
>
> which should be fairly portable

2 isFraction. -> true
(2 / 1) isFraction. -> true
2s0 isFraction. -> false
2s0 = 2. -> true
2s0 = (2 / 1). -> true

makes total sense

Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Grease testSeconds is failing in Squeak 4.3 and Pharo 1.4

David T. Lewis
On Mon, Feb 20, 2012 at 06:51:24AM +0100, Philippe Marschall wrote:

> 2012/2/20 nicolas cellier <[hidden email]>:
> > In all Smalltalk, (2/1) is automatically reduced to a canonical Integer
> > representation.
> > Nonetheless it is also a fraction.
> >
> > 1) Since all Integer are special kind of fraction and are polymorphic to
> > fraction in Squeak and Pharo (responds to numerator, denominator, fractionPart
> > etc...)
> > 2) and since doing so both simplify and speed up some arithmetic code,
> >
> > Squeak and Pharo (2 isFraction) now answer true.
> >
> > One consequence is a failing Grease test (GRPlatformTest>>testSeconds)
> >
> > ?? ??self deny: Time now seconds isFraction.
> >
> > The purpose is to test that no fractional seconds get returned.
> > I suggest rewriting:
> >
> > ?? ??self deny: (Time now seconds isKindOf: Fraction).
> >
> > which should be fairly portable
>
> 2 isFraction. -> true
> (2 / 1) isFraction. -> true
> 2s0 isFraction. -> false
> 2s0 = 2. -> true
> 2s0 = (2 / 1). -> true
>
> makes total sense
>

But 2s0 is a whole number, so perhaps it should be treated like an
integer in this context? If so, then:

2 denominator = 1. ==> true
(2 / 1) denominator = 1. ==> true
2s0 denominator = 1. ==> true
2s0 = 2. ==> true
2s0 = (2 / 1). ==> true

Dave
 
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Grease testSeconds is failing in Squeak 4.3 and Pharo 1.4

Philippe Marschall
2012/2/20 David T. Lewis <[hidden email]>:

> On Mon, Feb 20, 2012 at 06:51:24AM +0100, Philippe Marschall wrote:
>> 2012/2/20 nicolas cellier <[hidden email]>:
>> > In all Smalltalk, (2/1) is automatically reduced to a canonical Integer
>> > representation.
>> > Nonetheless it is also a fraction.
>> >
>> > 1) Since all Integer are special kind of fraction and are polymorphic to
>> > fraction in Squeak and Pharo (responds to numerator, denominator, fractionPart
>> > etc...)
>> > 2) and since doing so both simplify and speed up some arithmetic code,
>> >
>> > Squeak and Pharo (2 isFraction) now answer true.
>> >
>> > One consequence is a failing Grease test (GRPlatformTest>>testSeconds)
>> >
>> > ?? ??self deny: Time now seconds isFraction.
>> >
>> > The purpose is to test that no fractional seconds get returned.
>> > I suggest rewriting:
>> >
>> > ?? ??self deny: (Time now seconds isKindOf: Fraction).
>> >
>> > which should be fairly portable
>>
>> 2 isFraction. -> true
>> (2 / 1) isFraction. -> true
>> 2s0 isFraction. -> false
>> 2s0 = 2. -> true
>> 2s0 = (2 / 1). -> true
>>
>> makes total sense
>>
>
> But 2s0 is a whole number, so perhaps it should be treated like an
> integer in this context? If so, then:
>
> 2 denominator = 1. ==> true
> (2 / 1) denominator = 1. ==> true
> 2s0 denominator = 1. ==> true
> 2s0 = 2. ==> true
> 2s0 = (2 / 1). ==> true

If denominator = 1 is portable I would prefer this to isKindOf: Fraction.

Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Grease testSeconds is failing in Squeak 4.3 and Pharo 1.4

Philippe Marschall
In reply to this post by Nicolas Cellier
2012/2/20 nicolas cellier <[hidden email]>:

> In all Smalltalk, (2/1) is automatically reduced to a canonical Integer
> representation.
> Nonetheless it is also a fraction.
>
> 1) Since all Integer are special kind of fraction and are polymorphic to
> fraction in Squeak and Pharo (responds to numerator, denominator, fractionPart
> etc...)
> 2) and since doing so both simplify and speed up some arithmetic code,
>
> Squeak and Pharo (2 isFraction) now answer true.
>
> One consequence is a failing Grease test (GRPlatformTest>>testSeconds)
>
>    self deny: Time now seconds isFraction.
>
> The purpose is to test that no fractional seconds get returned.
> I suggest rewriting:
>
>    self deny: (Time now seconds isKindOf: Fraction).
>
> which should be fairly portable

We decided to kick the test for #isFraction entirely.

Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside