[Swift-devel] assertEqual

Tim Armstrong tim.g.armstrong at gmail.com
Wed Apr 8 13:58:14 CDT 2015


That might not actually work in Swift/T since we don't support overloading
in combination with optional args.


- Tim

On 8 April 2015 at 13:57, Tim Armstrong <tim.g.armstrong at gmail.com> wrote:

> So assertEqual(float, float, string, float tolerance=0.0) ?
>
> On 8 April 2015 at 13:08, Mihael Hategan <hategan at mcs.anl.gov> wrote:
>
>> I went with an optional. It keeps backwards compatibility and makes it
>> clear what that number is.
>>
>> Mihael
>>
>> On Wed, 2015-04-08 at 11:48 -0500, Tim Armstrong wrote:
>> > Reviving this thread...  Probably the options are to either add an
>> overload:
>> >
>> > assertEqual(float v1, float v2, float tolerance, string msg)
>> >
>> > or something like
>> >
>> > assertAlmostEqual(float v1, float v2, float tolerance, string msg)
>> > assertApproxEqual(float v1, float v2, float tolerance, string msg)
>> > assertApprox(float v1, float v2, float tolerance, string msg)
>> >
>> > I don't think there's much of a reason to break compatibility in Swift/T
>> > with the (float, float, string) form, so I think we should keep that in.
>> >
>> > - Tim
>> >
>> > On 6 April 2015 at 12:14, Mihael Hategan <hategan at mcs.anl.gov> wrote:
>> >
>> > > On Mon, 2015-04-06 at 09:38 -0500, Tim Armstrong wrote:
>> > > > Right, the tests for those things in the Swift test suite are like:
>> > > >
>> > > > assert(abs(sin(PI/2) - 1.0) < 1e-15, "sin");
>> > > >
>> > > > Which is a little less convenient.
>> > > >
>> > > > I think if we want almost equal semantics we could have
>> assertAlmostEqual
>> > > > with a tolerance parameter
>> > >
>> > > That's a choice.
>> > >
>> > > I personally think that approximate equality in numerics is such a
>> > > widespread issue, that there wouldn't be much confusion.
>> > >
>> > > Mihael
>> > >
>> > > >
>> > > > -Tim
>> > > >
>> > > > On 5 April 2015 at 21:17, Mihael Hategan <hategan at mcs.anl.gov>
>> wrote:
>> > > >
>> > > > > Hi,
>> > > > >
>> > > > > I found it useful to have a tolerance parameter for
>> assertEqual(float,
>> > > > > float).
>> > > > >
>> > > > > Checks like assertEqual(tan(x), sin(x) / cos(x)) are otherwise not
>> > > going
>> > > > > to work very well.
>> > > > >
>> > > > > Mihael
>> > > > >
>> > > > > _______________________________________________
>> > > > > Swift-devel mailing list
>> > > > > Swift-devel at ci.uchicago.edu
>> > > > >
>> https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel
>> > > > >
>> > >
>> > >
>> > >
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/swift-devel/attachments/20150408/db1c3ffe/attachment.html>


More information about the Swift-devel mailing list