throw-basic.js 376 B

12345678910111213141516171819202122232425262728
  1. try {
  2. throw 1;
  3. assertNotReached();
  4. } catch (e) {
  5. assert(e === 1);
  6. }
  7. try {
  8. throw [99];
  9. assertNotReached();
  10. } catch (e) {
  11. assert(typeof e === "object");
  12. assert(e.length === 1);
  13. }
  14. function foo() {
  15. throw "hello";
  16. assertNotReached();
  17. }
  18. try {
  19. foo();
  20. assertNotReached();
  21. } catch (e) {
  22. assert(e === "hello");
  23. }
  24. console.log("PASS");