sta.js 763 B

12345678910111213141516171819202122232425262728
  1. // Copyright (c) 2012 Ecma International. All rights reserved.
  2. // This code is governed by the BSD license found in the LICENSE file.
  3. /*---
  4. description: |
  5. Provides both:
  6. - An error class to avoid false positives when testing for thrown exceptions
  7. - A function to explicitly throw an exception using the Test262Error class
  8. defines: [Test262Error, $ERROR, $DONOTEVALUATE]
  9. ---*/
  10. function Test262Error(message) {
  11. this.message = message || "";
  12. }
  13. Test262Error.prototype.toString = function () {
  14. return "Test262Error: " + this.message;
  15. };
  16. Test262Error.thrower = (...args) => {
  17. throw new Test262Error(...args);
  18. };
  19. var $ERROR = Test262Error.thrower;
  20. function $DONOTEVALUATE() {
  21. throw "Test262: This statement should not be evaluated.";
  22. }