Skip to content

Commit 08668ae

Browse files
committed
add tests for reported problems
1 parent 93feecd commit 08668ae

File tree

1 file changed

+22
-0
lines changed
  • graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/interop

1 file changed

+22
-0
lines changed

graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/interop/JavaInteropTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,28 @@ public void evalInteractiveInInteractiveTerminalThrowsSyntaxError() throws IOExc
161161
fail();
162162
}
163163

164+
@Test
165+
public void importingJavaLangStringConvertsEagerly() {
166+
try (Context c = Context.newBuilder().allowExperimentalOptions(true).allowAllAccess(true).build()) {
167+
c.getPolyglotBindings().putMember("b", "hello world");
168+
c.eval("python", "import polyglot; xyz = polyglot.import_value('b'); assert isinstance(xyz, str)");
169+
// should not fail
170+
}
171+
}
172+
173+
@Test
174+
public void evalWithSyntaxErrorThrows() {
175+
try (Context c = Context.newBuilder().build()) {
176+
c.eval("python", "var d=5/0");
177+
} catch (PolyglotException t) {
178+
assertTrue(t.isSyntaxError());
179+
assertFalse(t.isIncompleteSource());
180+
return;
181+
}
182+
183+
fail();
184+
}
185+
164186
@Test
165187
public void truffleMethodExport() {
166188
String source = "import polyglot\n" +

0 commit comments

Comments
 (0)