labels.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. labels_1: {
  2. options = { if_return: true, conditionals: true, dead_code: true };
  3. input: {
  4. out: {
  5. if (foo) break out;
  6. console.log("bar");
  7. }
  8. };
  9. expect: {
  10. foo || console.log("bar");
  11. }
  12. }
  13. labels_2: {
  14. options = { if_return: true, conditionals: true, dead_code: true };
  15. input: {
  16. out: {
  17. if (foo) print("stuff");
  18. else break out;
  19. console.log("here");
  20. }
  21. };
  22. expect: {
  23. if (foo) {
  24. print("stuff");
  25. console.log("here");
  26. }
  27. }
  28. }
  29. labels_3: {
  30. options = { if_return: true, conditionals: true, dead_code: true };
  31. input: {
  32. for (var i = 0; i < 5; ++i) {
  33. if (i < 3) continue;
  34. console.log(i);
  35. }
  36. };
  37. expect: {
  38. for (var i = 0; i < 5; ++i)
  39. i < 3 || console.log(i);
  40. }
  41. }
  42. labels_4: {
  43. options = { if_return: true, conditionals: true, dead_code: true };
  44. input: {
  45. out: for (var i = 0; i < 5; ++i) {
  46. if (i < 3) continue out;
  47. console.log(i);
  48. }
  49. };
  50. expect: {
  51. for (var i = 0; i < 5; ++i)
  52. i < 3 || console.log(i);
  53. }
  54. }
  55. labels_5: {
  56. options = { if_return: true, conditionals: true, dead_code: true };
  57. // should keep the break-s in the following
  58. input: {
  59. while (foo) {
  60. if (bar) break;
  61. console.log("foo");
  62. }
  63. out: while (foo) {
  64. if (bar) break out;
  65. console.log("foo");
  66. }
  67. };
  68. expect: {
  69. while (foo) {
  70. if (bar) break;
  71. console.log("foo");
  72. }
  73. out: while (foo) {
  74. if (bar) break out;
  75. console.log("foo");
  76. }
  77. }
  78. }
  79. labels_6: {
  80. input: {
  81. out: break out;
  82. };
  83. expect: {}
  84. }
  85. labels_7: {
  86. options = { if_return: true, conditionals: true, dead_code: true };
  87. input: {
  88. while (foo) {
  89. x();
  90. y();
  91. continue;
  92. }
  93. };
  94. expect: {
  95. while (foo) {
  96. x();
  97. y();
  98. }
  99. }
  100. }
  101. labels_8: {
  102. options = { if_return: true, conditionals: true, dead_code: true };
  103. input: {
  104. while (foo) {
  105. x();
  106. y();
  107. break;
  108. }
  109. };
  110. expect: {
  111. while (foo) {
  112. x();
  113. y();
  114. break;
  115. }
  116. }
  117. }
  118. labels_9: {
  119. options = { if_return: true, conditionals: true, dead_code: true };
  120. input: {
  121. out: while (foo) {
  122. x();
  123. y();
  124. continue out;
  125. z();
  126. k();
  127. }
  128. };
  129. expect: {
  130. while (foo) {
  131. x();
  132. y();
  133. }
  134. }
  135. }
  136. labels_10: {
  137. options = { if_return: true, conditionals: true, dead_code: true };
  138. input: {
  139. out: while (foo) {
  140. x();
  141. y();
  142. break out;
  143. z();
  144. k();
  145. }
  146. };
  147. expect: {
  148. out: while (foo) {
  149. x();
  150. y();
  151. break out;
  152. }
  153. }
  154. }