Skip to content

Commit 07ea0f2

Browse files
msimacektomasstupka
authored andcommitted
Fix invalid python code in tests
1 parent d91cefb commit 07ea0f2

File tree

1 file changed

+31
-26
lines changed
  • graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/compiler

1 file changed

+31
-26
lines changed

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/compiler/CompilerTests.java

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -254,52 +254,57 @@ public void testBreakFromFinally() {
254254

255255
@Test
256256
public void testReturnFromWith() {
257-
String source = "for i in range(10):\n" +
258-
" with foo() as cm:\n" +
259-
" return a\n";
257+
String source = "def foo():\n" +
258+
" for i in range(10):\n" +
259+
" with foo() as cm:\n" +
260+
" return a\n";
260261
doTest(source);
261262
}
262263

263264
@Test
264265
public void testReturnFromTry() {
265-
String source = "for i in range(10):\n" +
266-
" try:\n" +
267-
" return a\n" +
268-
" finally:" +
269-
" print('finally')";
266+
String source = "def foo():\n" +
267+
" for i in range(10):\n" +
268+
" try:\n" +
269+
" return a\n" +
270+
" finally:" +
271+
" print('finally')";
270272
doTest(source);
271273
}
272274

273275
@Test
274276
public void testReturnFromExcept() {
275-
String source = "for i in range(10):\n" +
276-
" try:\n" +
277-
" 1 / 0\n" +
278-
" except RuntimeError as e:" +
279-
" return a";
277+
String source = "def foo():\n" +
278+
" for i in range(10):\n" +
279+
" try:\n" +
280+
" 1 / 0\n" +
281+
" except RuntimeError as e:" +
282+
" return a";
280283
doTest(source);
281284
}
282285

283286
@Test
284287
public void testReturnFromFinally() {
285-
String source = "for i in range(10):\n" +
286-
" try:\n" +
287-
" if i:\n" +
288-
" return a\n" +
289-
" print(i)\n" +
290-
" finally:\n" +
291-
" print('finally')\n" +
292-
" return b";
288+
String source = "def foo():\n" +
289+
" for i in range(10):\n" +
290+
" try:\n" +
291+
" if i:\n" +
292+
" return a\n" +
293+
" print(i)\n" +
294+
" finally:\n" +
295+
" print('finally')\n" +
296+
" return b";
293297
doTest(source);
294298
}
295299

296300
@Test
297301
public void testFinallyCancelReturn() {
298-
String source = "for i in range(10):\n" +
299-
" try:\n" +
300-
" return a\n" +
301-
" finally:" +
302-
" continue";
302+
String source = "def foo():\n" +
303+
" for i in range(10):\n" +
304+
" try:\n" +
305+
" return a\n" +
306+
" finally:" +
307+
" continue";
303308
doTest(source);
304309
}
305310

0 commit comments

Comments
 (0)