Reflect.getPrototypeOf.js 756 B

1234567891011121314151617181920212223242526
  1. load("test-common.js");
  2. try {
  3. assert(Reflect.getPrototypeOf.length === 1);
  4. [null, undefined, "foo", 123, NaN, Infinity].forEach(value => {
  5. assertThrowsError(() => {
  6. Reflect.getPrototypeOf(value);
  7. }, {
  8. error: TypeError,
  9. message: "First argument of Reflect.getPrototypeOf() must be an object"
  10. });
  11. });
  12. assert(Reflect.getPrototypeOf({}) === Object.prototype);
  13. assert(Reflect.getPrototypeOf([]) === Array.prototype);
  14. assert(Reflect.getPrototypeOf(new String()) === String.prototype);
  15. var o = {};
  16. Reflect.setPrototypeOf(o, { foo: "bar" });
  17. assert(Reflect.getPrototypeOf(o).foo === "bar");
  18. console.log("PASS");
  19. } catch (e) {
  20. console.log("FAIL: " + e);
  21. }