@@ -192,8 +192,15 @@ public static void assertPrints(String expected, Path scriptName) {
192
192
public static void assertPrints (String expected , String code ) {
193
193
final ByteArrayOutputStream byteArray = new ByteArrayOutputStream ();
194
194
final PrintStream printStream = new PrintStream (byteArray );
195
- String source = code ;
196
- PythonTests .runScript (new String [0 ], source , printStream , System .err );
195
+ PythonTests .runScript (new String [0 ], code , printStream , System .err );
196
+ String result = byteArray .toString ().replaceAll ("\r \n " , "\n " );
197
+ assertEquals (expected .replaceAll (" at 0x[0-9a-f]*>" , " at 0xabcd>" ), result .replaceAll (" at 0x[0-9a-f]*>" , " at 0xabcd>" ));
198
+ }
199
+
200
+ public static void assertPrints (String expected , org .graalvm .polyglot .Source code ) {
201
+ final ByteArrayOutputStream byteArray = new ByteArrayOutputStream ();
202
+ final PrintStream printStream = new PrintStream (byteArray );
203
+ PythonTests .runScript (new String [0 ], code , printStream , System .err );
197
204
String result = byteArray .toString ().replaceAll ("\r \n " , "\n " );
198
205
assertEquals (expected .replaceAll (" at 0x[0-9a-f]*>" , " at 0xabcd>" ), result .replaceAll (" at 0x[0-9a-f]*>" , " at 0xabcd>" ));
199
206
}
@@ -311,6 +318,15 @@ public static void runScript(String[] args, String source, OutputStream out, Out
311
318
}
312
319
}
313
320
321
+ public static void runScript (String [] args , org .graalvm .polyglot .Source source , OutputStream out , OutputStream err ) {
322
+ try {
323
+ enterContext (args );
324
+ context .eval (source );
325
+ } finally {
326
+ flush (out , err );
327
+ }
328
+ }
329
+
314
330
public static void runScript (String [] args , String source , OutputStream out , OutputStream err , Runnable cb ) {
315
331
try {
316
332
enterContext (args );
0 commit comments