|
64 | 64 |
|
65 | 65 | import com.oracle.graal.python.test.PythonTests;
|
66 | 66 | import com.oracle.truffle.api.debug.Breakpoint;
|
| 67 | +import com.oracle.truffle.api.debug.DebugScope; |
67 | 68 | import com.oracle.truffle.api.debug.DebugStackFrame;
|
68 | 69 | import com.oracle.truffle.api.debug.DebugValue;
|
69 | 70 | import com.oracle.truffle.api.debug.DebuggerSession;
|
@@ -404,6 +405,51 @@ public void testGettersSetters() throws Throwable {
|
404 | 405 | }
|
405 | 406 | }
|
406 | 407 |
|
| 408 | + @Test |
| 409 | + public void testInspectJavaArray() throws Throwable { |
| 410 | + final Source source = Source.newBuilder("python", "" + |
| 411 | + "import java\n" + |
| 412 | + "a_int = java.type('int[]')(3)\n" + |
| 413 | + "a_long = java.type('long[]')(3)\n" + |
| 414 | + "a_short = java.type('short[]')(3)\n" + |
| 415 | + "a_byte = java.type('byte[]')(3)\n" + |
| 416 | + "a_float = java.type('float[]')(3)\n" + |
| 417 | + "a_double = java.type('double[]')(3)\n" + |
| 418 | + "a_char = java.type('char[]')(3)\n" + |
| 419 | + "print()\n" + |
| 420 | + "\n", "testInspectJavaArray.py").buildLiteral(); |
| 421 | + try (DebuggerSession session = tester.startSession()) { |
| 422 | + session.install(Breakpoint.newBuilder(DebuggerTester.getSourceImpl(source)).lineIs(9).build()); |
| 423 | + tester.startEval(source); |
| 424 | + expectSuspended((SuspendedEvent event) -> { |
| 425 | + DebugScope globalScope = session.getTopScope("python"); |
| 426 | + DebugValue intValue = globalScope.getDeclaredValue("a_int").getArray().get(0); |
| 427 | + // It's up to Truffle to decide which language it uses for inspection of primitives, |
| 428 | + // we should be fine as long as this doesn't throw an exception |
| 429 | + intValue.getMetaObject(); |
| 430 | + assertEquals("0", intValue.as(String.class)); |
| 431 | + DebugValue longValue = globalScope.getDeclaredValue("a_long").getArray().get(0); |
| 432 | + longValue.getMetaObject(); |
| 433 | + assertEquals("0", longValue.as(String.class)); |
| 434 | + DebugValue shortValue = globalScope.getDeclaredValue("a_short").getArray().get(0); |
| 435 | + shortValue.getMetaObject(); |
| 436 | + assertEquals("0", shortValue.as(String.class)); |
| 437 | + DebugValue byteValue = globalScope.getDeclaredValue("a_byte").getArray().get(0); |
| 438 | + byteValue.getMetaObject(); |
| 439 | + assertEquals("0", byteValue.as(String.class)); |
| 440 | + DebugValue floatValue = globalScope.getDeclaredValue("a_float").getArray().get(0); |
| 441 | + floatValue.getMetaObject(); |
| 442 | + assertEquals("0.0", floatValue.as(String.class)); |
| 443 | + DebugValue doubleValue = globalScope.getDeclaredValue("a_double").getArray().get(0); |
| 444 | + doubleValue.getMetaObject(); |
| 445 | + assertEquals("0.0", doubleValue.as(String.class)); |
| 446 | + DebugValue charValue = globalScope.getDeclaredValue("a_char").getArray().get(0); |
| 447 | + charValue.getMetaObject(); |
| 448 | + assertEquals("\0", charValue.as(String.class)); |
| 449 | + }); |
| 450 | + } |
| 451 | + } |
| 452 | + |
407 | 453 | @Test
|
408 | 454 | public void testSourceFileURI() throws Throwable {
|
409 | 455 | if (System.getProperty("os.name").toLowerCase().contains("mac")) {
|
|
0 commit comments