Ignore:
Timestamp:
Jan 21, 2010, 4:06:00 PM (15 years ago)
Author:
[email protected]
Message:

2010-01-21 Geoffrey Garen <[email protected]>

Reviewed by Oliver Hunt.

Always create a prototype for automatically managed classes.


This fixes some errors where prototype chains were not correctly hooked
up, and also ensures that API classes work correctly with features like
instanceof.

  • API/JSClassRef.cpp: (OpaqueJSClass::create): Cleaned up some of this code. Also changed it to always create a prototype class.
  • API/tests/testapi.c: (Derived2_class): (main): Fixed a null value crash in the exception checking code.
  • API/tests/testapi.js: Added some tests for the case where a prototype chain would not be hooked up correctly.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/tests/testapi.js

    r53638 r53657  
    170170derived = new Derived();
    171171
     172shouldBe("derived instanceof Derived", true);
     173shouldBe("derived instanceof Base", true);
     174
    172175// base properties and functions return 1 when called/gotten; derived, 2
    173176shouldBe("derived.baseProtoDup()", 2);
     
    184187shouldBe("derived.derivedOnly = 0", 2)
    185188shouldBe("derived.protoDup = 0", 2);
     189
     190derived2 = new Derived2();
     191
     192shouldBe("derived2 instanceof Derived2", true);
     193shouldBe("derived2 instanceof Derived", true);
     194shouldBe("derived2 instanceof Base", true);
     195
     196// base properties and functions return 1 when called/gotten; derived, 2
     197shouldBe("derived2.baseProtoDup()", 2);
     198shouldBe("derived2.baseProto()", 1);
     199shouldBe("derived2.baseDup", 2);
     200shouldBe("derived2.baseOnly", 1);
     201shouldBe("derived2.protoOnly()", 2);
     202shouldBe("derived2.protoDup", 2);
     203shouldBe("derived2.derivedOnly", 2)
     204
     205// base properties throw 1 when set; derived, 2
     206shouldBe("derived2.baseDup = 0", 2);
     207shouldBe("derived2.baseOnly = 0", 1);
     208shouldBe("derived2.derivedOnly = 0", 2)
     209shouldBe("derived2.protoDup = 0", 2);
    186210
    187211shouldBe('Object.getOwnPropertyDescriptor(derived, "baseProto")', undefined);
Note: See TracChangeset for help on using the changeset viewer.