Bug 1524965 - Part 4: Add testcase for break/continue outside the loop. r=Yoric
authorTooru Fujisawa <arai_a@mac.com>
Tue, 05 Feb 2019 00:40:42 +0900
changeset 516096 21aedfe62db37db8ee18416c62863b4df28c8327
parent 516095 1143fee910c70ae6ea25e325b7908f38c8cfeba6
child 516097 57b1f35d3f9c57f372c54a0f26c3f8c57a781b96
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersYoric
bugs1524965
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1524965 - Part 4: Add testcase for break/continue outside the loop. r=Yoric Differential Revision: https://phabricator.services.mozilla.com/D18561
js/src/jit-test/tests/binast/invalid/break-outside-while.binjs
js/src/jit-test/tests/binast/invalid/break-outside-while.dir
js/src/jit-test/tests/binast/invalid/continue-outside-while.binjs
js/src/jit-test/tests/binast/invalid/continue-outside-while.dir
js/src/jit-test/tests/binast/invalid/labelled-break-outside-while.binjs
js/src/jit-test/tests/binast/invalid/labelled-break-outside-while.dir
js/src/jit-test/tests/binast/invalid/labelled-continue-outside-while.binjs
js/src/jit-test/tests/binast/invalid/labelled-continue-outside-while.dir
js/src/jsapi-tests/binast/invalid/tests/break-outside-while.js
js/src/jsapi-tests/binast/invalid/tests/break-outside-while.py
js/src/jsapi-tests/binast/invalid/tests/continue-outside-while.js
js/src/jsapi-tests/binast/invalid/tests/continue-outside-while.py
js/src/jsapi-tests/binast/invalid/tests/labelled-break-outside-while.js
js/src/jsapi-tests/binast/invalid/tests/labelled-break-outside-while.py
js/src/jsapi-tests/binast/invalid/tests/labelled-continue-outside-while.js
js/src/jsapi-tests/binast/invalid/tests/labelled-continue-outside-while.py
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..4e2739246311dad7a2bf5a8954ba2f8d605e84fd
GIT binary patch
literal 194
zc${<c^z#a4igpij^!0TNip@+(%`3?)skDB=r{Y*#oLW?pn&Om`pPU_>oL`V?1QQBQ
zF3Kz@anH$5O3VSvaDf%cI2ENPW(SufmZata%`x!FEJ-a&%yG)k&q+<pbFC;SN-ZwV
z%+KS2=$8r4$jnKFD~}Ei3G(!F4@NkGgNfxoLv%=xt1CiGfs2WOfq{jGgOLSDGq5oL
E0Pz+<lK=n!
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/binast/invalid/break-outside-while.dir
@@ -0,0 +1,1 @@
+// |jit-test| error: unlabeled break must be inside loop or switch
\ No newline at end of file
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..093c05a6684b5beb2ef82cb901ca40d8ff8fc44b
GIT binary patch
literal 197
zc${<c^z#a4igpij^!0TNip@+(%`3?)skDB@r{Y*#oLW?pn&Om`pPU_>oL`V?1QQBQ
zF3Kz@anH$5O3VSvaDf#mIp+g)=ar@gmn4>?<^qi}@X0JmElSLB%FoY9P0VwxC@4xT
zF3!x)<AE3<6P}TogHRqF91`T|=N^o32L}_&e}?FgAXis}m;x6Q0|NsK4+kR)kY-?G
F008b@LjM2&
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/binast/invalid/continue-outside-while.dir
@@ -0,0 +1,1 @@
+// |jit-test| error: continue must be inside loop
\ No newline at end of file
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..50fc299705103650740558515ac9de0fb94c5120
GIT binary patch
literal 216
zc$`I!!3u&v6h$WyDUs*{T!kMHZCg1YVyKH5p@p;<^+kh|PiAIOf1eoU?sD$oa%omx
zxl^YsE{d4lWe0<m_H)@ehbT4%w1ti;Y<u3~2<HXyR?E?*3LBy3#-F8-Y7jlQ!oq7B
zI_9DQr6zqLr(9alLQzBoVo2Vj24f@+!EZ6VJ*9%bUh|4&Wy;rIzT-U*>xw1G3ZuXw
Ogt%L>_c!j8h)2GdzeocB
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/binast/invalid/labelled-break-outside-while.dir
@@ -0,0 +1,1 @@
+// |jit-test| error: label not found
\ No newline at end of file
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0fb72bf49040b312d1bf2835dc96527df5595df2
GIT binary patch
literal 219
zc$`I!!3u&v6h)^&Bt)tYXeE9?v~8s!VyKH5p@p;<^+iL|JaHzdzfTNt_c-_7!;7=>
z!fBnds3;<KlO1R)?f0~$yD%~a1`A!Ruzm6tdpORBw}b3$s<07iO1!BQoN=7%H*hN~
zyhc}$iw2Y$7c)8J(!wBAjHp29<kJsej707KrTgncszp%qie+WWm)AV%-Vy7HCCLIq
QpAtfxHQ9J8XS|3@ez9apZvX%Q
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/binast/invalid/labelled-continue-outside-while.dir
@@ -0,0 +1,1 @@
+// |jit-test| error: continue must be inside loop
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/js/src/jsapi-tests/binast/invalid/tests/break-outside-while.js
@@ -0,0 +1,3 @@
+while (true) {
+  break;
+}
new file mode 100644
--- /dev/null
+++ b/js/src/jsapi-tests/binast/invalid/tests/break-outside-while.py
@@ -0,0 +1,21 @@
+def filter_ast(ast):
+    # Move a break statement out of a while loop.
+    import filter_utils as utils
+
+    utils.assert_interface(ast, 'Script')
+    global_stmts = utils.get_field(ast, 'statements')
+
+    while_stmt = utils.get_element(global_stmts, 0)
+    utils.assert_interface(while_stmt, 'WhileStatement')
+
+    while_body = utils.get_field(while_stmt, 'body')
+    utils.assert_interface(while_body, 'Block')
+    while_body_stmts = utils.get_field(while_body, 'statements')
+
+    break_stmt = utils.get_element(while_body_stmts, 0)
+    utils.assert_interface(break_stmt, 'BreakStatement')
+
+    utils.remove_element(while_body_stmts, 0)
+    utils.append_element(global_stmts, break_stmt)
+
+    return ast
new file mode 100644
--- /dev/null
+++ b/js/src/jsapi-tests/binast/invalid/tests/continue-outside-while.js
@@ -0,0 +1,3 @@
+while (true) {
+  continue;
+}
new file mode 100644
--- /dev/null
+++ b/js/src/jsapi-tests/binast/invalid/tests/continue-outside-while.py
@@ -0,0 +1,21 @@
+def filter_ast(ast):
+    # Move a continue statement out of a while loop.
+    import filter_utils as utils
+
+    utils.assert_interface(ast, 'Script')
+    global_stmts = utils.get_field(ast, 'statements')
+
+    while_stmt = utils.get_element(global_stmts, 0)
+    utils.assert_interface(while_stmt, 'WhileStatement')
+
+    while_body = utils.get_field(while_stmt, 'body')
+    utils.assert_interface(while_body, 'Block')
+    while_body_stmts = utils.get_field(while_body, 'statements')
+
+    continue_stmt = utils.get_element(while_body_stmts, 0)
+    utils.assert_interface(continue_stmt, 'ContinueStatement')
+
+    utils.remove_element(while_body_stmts, 0)
+    utils.append_element(global_stmts, continue_stmt)
+
+    return ast
new file mode 100644
--- /dev/null
+++ b/js/src/jsapi-tests/binast/invalid/tests/labelled-break-outside-while.js
@@ -0,0 +1,3 @@
+foo: while (true) {
+  break foo;
+}
new file mode 100644
--- /dev/null
+++ b/js/src/jsapi-tests/binast/invalid/tests/labelled-break-outside-while.py
@@ -0,0 +1,24 @@
+def filter_ast(ast):
+    # Move a break statement out of a while loop.
+    import filter_utils as utils
+
+    utils.assert_interface(ast, 'Script')
+    global_stmts = utils.get_field(ast, 'statements')
+
+    labelled_stmt = utils.get_element(global_stmts, 0)
+    utils.assert_interface(labelled_stmt, 'LabelledStatement')
+
+    while_stmt = utils.get_field(labelled_stmt, 'body')
+    utils.assert_interface(while_stmt, 'WhileStatement')
+
+    while_body = utils.get_field(while_stmt, 'body')
+    utils.assert_interface(while_body, 'Block')
+    while_body_stmts = utils.get_field(while_body, 'statements')
+
+    break_stmt = utils.get_element(while_body_stmts, 0)
+    utils.assert_interface(break_stmt, 'BreakStatement')
+
+    utils.remove_element(while_body_stmts, 0)
+    utils.append_element(global_stmts, break_stmt)
+
+    return ast
new file mode 100644
--- /dev/null
+++ b/js/src/jsapi-tests/binast/invalid/tests/labelled-continue-outside-while.js
@@ -0,0 +1,3 @@
+foo: while (true) {
+  continue foo;
+}
new file mode 100644
--- /dev/null
+++ b/js/src/jsapi-tests/binast/invalid/tests/labelled-continue-outside-while.py
@@ -0,0 +1,24 @@
+def filter_ast(ast):
+    # Move a continue statement out of a while loop.
+    import filter_utils as utils
+
+    utils.assert_interface(ast, 'Script')
+    global_stmts = utils.get_field(ast, 'statements')
+
+    labelled_stmt = utils.get_element(global_stmts, 0)
+    utils.assert_interface(labelled_stmt, 'LabelledStatement')
+
+    while_stmt = utils.get_field(labelled_stmt, 'body')
+    utils.assert_interface(while_stmt, 'WhileStatement')
+
+    while_body = utils.get_field(while_stmt, 'body')
+    utils.assert_interface(while_body, 'Block')
+    while_body_stmts = utils.get_field(while_body, 'statements')
+
+    continue_stmt = utils.get_element(while_body_stmts, 0)
+    utils.assert_interface(continue_stmt, 'ContinueStatement')
+
+    utils.remove_element(while_body_stmts, 0)
+    utils.append_element(global_stmts, continue_stmt)
+
+    return ast