constructor.js 749 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright (C) 2021 Chengzhong Wu. All rights reserved.
  2. // This code is governed by the BSD license found in the LICENSE file.
  3. /*---
  4. description: Error constructor creates own properties in sequence
  5. info: |
  6. Error ( message [ , options ] )
  7. ...
  8. 4. Perform ? InstallErrorCause(O, options).
  9. ...
  10. esid: sec-error-message
  11. features: [error-cause]
  12. includes: [deepEqual.js]
  13. ---*/
  14. var message = "my-message";
  15. var cause = { message: "my-cause" };
  16. var sequence = [];
  17. new Error(
  18. {
  19. toString() {
  20. sequence.push("toString");
  21. return message;
  22. },
  23. },
  24. {
  25. get cause() {
  26. sequence.push("cause");
  27. return cause;
  28. },
  29. },
  30. );
  31. assert.deepEqual(sequence, [ "toString", "cause" ], "accessing own properties on sequence");