In Test.More, why use the isPrototypeOf() method instead of the
instanceof operator? Safari doesn't have isPrototypeOf, so my tests
isaOK tests there fail. However, I can achieve the same end with the
following:
isaOK(customErrorObject, "Error"); // breaks on Safari
ok(customErrorObject instanceof Error, "Yup, it's an Error");
The JavaScript 1.5 documentation indicates that instanceof is
specifically intended for purposes like this.
http://xrl.us/3qyq (Link to developer.mozilla.org)
Patch file at:
http://www.rectangular.com/junk/Test.Simple/isaOK.patch
This passes on IE6, FF2mac FF2win, and Safari2mac:
http://www.rectangular.com/junk/Test.Simple/tests/?
file=more.js;verbose=1
I see reference to the same Safari bug number in other spots when I
ack the source, but this is all I have time for tonight and seems
like a good start.
Marvin Humphrey
Rectangular Research
http://www.rectangular.com/
> In Test.More, why use the isPrototypeOf() method instead of the
> instanceof operator? Safari doesn't have isPrototypeOf, so my tests
> isaOK tests there fail. However, I can achieve the same end with the
> following:
>
> isaOK(customErrorObject, "Error"); // breaks on Safari
> ok(customErrorObject instanceof Error, "Yup, it's an Error");
>
> The JavaScript 1.5 documentation indicates that instanceof is
> specifically intended for purposes like this.
>
> http://xrl.us/3qyq (Link to developer.mozilla.org)
>
> Patch file at:
>
> http://www.rectangular.com/junk/Test.Simple/isaOK.patch
>
> This passes on IE6, FF2mac FF2win, and Safari2mac:
>
> http://www.rectangular.com/junk/Test.Simple/tests/?
> file=more.js;verbose=1
Well, yeah, because you deleted some tests, or so it appears to me.
As I've said, I'm a long way from this code at the moment, but from
your patch it *looks* like inheritance is lost. IIRC, instanceof is
like `ref $obj eq 'Foo'` in Perl, rather than `$obj.isa('Foo')`.
Am I missing something?
Best,
David
> Well, yeah, because you deleted some tests, or so it appears to me.
Take a closer look. :)
-if (safari) skip("http://bugzilla.opendarwin.org/show_bug.cgi?
id=3537", 1);
-else isaOK(Test.Builder.Test, "Test.Builder");
+isaOK(Test.Builder.Test, "Test.Builder");
+isaOK(Test.Builder.Test, "Object")
-if (Object.isPrototypeOf) isaOK(Test.Builder.Test, "Object")
-else skip("Cannot check inheritance without isPrototypeOf()", 1);
-
I didn't delete the tests, I deleted the conditional skipping of tests.
> As I've said, I'm a long way from this code at the moment, but from
> your patch it *looks* like inheritance is lost. IIRC, instanceof is
> like `ref $obj eq 'Foo'` in Perl, rather than `$obj.isa('Foo')`.
>
> Am I missing something?
It really is like $obj->isa('Foo'). Those tests above pass.
I specifically needed this functionality for testing an Error hierarchy:
Error => MyError => MyIdiotUserErrorWithSafeMessage
> I didn't delete the tests, I deleted the conditional skipping of
> tests.
Bah, sorry, my mistake.
> It really is like $obj->isa('Foo'). Those tests above pass.
>
> I specifically needed this functionality for testing an Error
> hierarchy:
>
> Error => MyError => MyIdiotUserErrorWithSafeMessage
Huh. There must have been *some* reason I did it this way. I just
don't now what it was now, of course.
Patch applied (or will be, once I can auth the svn repo again). Thanks!
David
> Patch applied (or will be, once I can auth the svn repo again).
> Thanks!
(*nudge*)
:)
TIA,
>> Patch applied (or will be, once I can auth the svn repo again).
>> Thanks!
>
> (*nudge*)
>
> :)
Bah. Pinging jcap again.
jcap: Can you reset my svn password?
Thanks,
David
>> (*nudge*)
>>
>> :)
>
> Bah. Pinging jcap again.
>
> jcap: Can you reset my svn password?
Got him on IRC; it's committed.
Best,
David