automatic-semicolon-insertion.js 942 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. load("test-common.js");
  2. /**
  3. * This file tests automatic semicolon insertion rules.
  4. * If this file produces syntax errors, something is wrong.
  5. */
  6. function bar() {
  7. // https://github.com/SerenityOS/serenity/issues/1829
  8. if (1)
  9. return 1;
  10. else
  11. return 0;
  12. if (1)
  13. return 1
  14. else
  15. return 0
  16. if (1)
  17. return 1
  18. else
  19. return 0;
  20. }
  21. function foo() {
  22. for (var i = 0; i < 4; i++) {
  23. break // semicolon inserted here
  24. continue // semicolon inserted here
  25. }
  26. var j // semicolon inserted here
  27. do {
  28. } while (1 === 2) // semicolon inserted here
  29. return // semicolon inserted here
  30. 1;
  31. var curly/* semicolon inserted here */}
  32. try {
  33. assert(foo() === undefined);
  34. console.log("PASS");
  35. } catch (e) {
  36. console.log("FAIL: " + e);
  37. }
  38. // This vardecl must appear exactly at the end of the file (no newline or whitespace after it)
  39. var eof