validate_line_column.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. // Validating that error thrown has right line and column number
  6. function foo(validate) {
  7. try {
  8. validate();
  9. } catch (e) {
  10. print(e.stack);
  11. }
  12. }
  13. foo(function() {
  14. ([z1]); // Error thrown here.
  15. });
  16. foo(function() {
  17. ({a:z1}); // Error thrown here.
  18. });
  19. foo(function() {
  20. var a;
  21. a;class b extends ([]){}; // Error thrown here.
  22. });
  23. foo(function() {
  24. (typeof a.b); // Error thrown here.
  25. });
  26. foo(function() {
  27. var k = 1;
  28. !a.b; // Error thrown here.
  29. });
  30. foo(function() {
  31. var k = 1;
  32. ~a.b; // Error thrown here.
  33. });
  34. foo(function() {
  35. var k = 1;
  36. (a.b && a.b); // Error thrown here.
  37. });
  38. foo(function() {
  39. var k = 1;
  40. (a.b || a.b); // Error thrown here.
  41. });
  42. foo(function() {
  43. var k = 1;
  44. (a.b * a.b); // Error thrown here.
  45. });
  46. foo(function() {
  47. var k = 1;
  48. `${a.b}`; // Error thrown here.
  49. });
  50. foo(function() {
  51. var k = 1;
  52. while(unresolved[0]) { // Error thrown here.
  53. break;
  54. }
  55. });
  56. foo(function() {
  57. var k = 1;
  58. while(typeof unresolved[0]) { // Error thrown here.
  59. break;
  60. }
  61. });
  62. foo(function() {
  63. var k = 1;
  64. while(unresolved instanceof blah) { // Error thrown here.
  65. break;
  66. }
  67. });