I had not considered the case of other classes and their toString() method. And indeed I think it might also be good to output the class and hashId in addition to toString in such cases. Like this:
assert new Foo() == "aa" | | | false {aa} com.package.foo.Foo@1sd2d23sc In that case I would also not escape the output of toString(). I will try out several variants, I am not yet sure about the best way to print Objects. On Tue, Aug 25, 2015 at 8:58 PM, Jamie Echlin <jamie.ech...@gmail.com> wrote: > Fair enough. Maybe I have a better real-world example that seems to trip up > people that I "know": > > class Foo { String toString() {"aa"} } > assert new Foo() == "aa" > > assert new Foo() == "aa" > | | > aa false > > Taking your proposal, '"aa" as Foo' is not valid, so I'd rather see output > like '"aa" (Foo)'. But that would be noisy, so ideally I'd like to see that > only if the output is counter-intuitive, although clearly I have no idea if > that's feasible. > > I think I disagree that the format for the entire results need be the same > as that for partial results. > > In the example above, better formatting for strings would possibly make it > even less intuitive. > > >