@@ -189,4 +189,22 @@ public void testLocalVariablesSharedBetweenInteractiveEvalChangesParsing() {
189
189
}
190
190
}
191
191
192
+ @ Test
193
+ public void testLocalVariablesAreNotSharedBetweenInteractiveAndNonInteractive () {
194
+ try (Context polyglot = Context .newBuilder ()
195
+ .option (OptionsCatalog .HOME .getName (), System .getProperty ("user.dir" ))
196
+ .allowAllAccess (true )
197
+ .build ()) {
198
+ polyglot .eval (Source .newBuilder ("ruby" , "a = 14" , "test" ).interactive (false ).buildLiteral ());
199
+ polyglot .eval (Source .newBuilder ("ruby" , "b = 2" , "test" ).interactive (true ).buildLiteral ());
200
+ assertTrue (polyglot .eval (Source .newBuilder ("ruby" , "defined?(a).nil?" , "test" ).interactive (true ).buildLiteral ()).asBoolean ());
201
+ assertTrue (polyglot .eval (Source .newBuilder ("ruby" , "defined?(b).nil?" , "test" ).interactive (false ).buildLiteral ()).asBoolean ());
202
+ assertFalse (polyglot .eval (Source .newBuilder ("ruby" , "defined?(b).nil?" , "test" ).interactive (true ).buildLiteral ()).asBoolean ());
203
+ assertTrue (polyglot .eval (Source .newBuilder ("ruby" , "TOPLEVEL_BINDING.eval('defined?(a).nil?')" , "test" ).interactive (false ).buildLiteral ()).asBoolean ());
204
+ assertTrue (polyglot .eval (Source .newBuilder ("ruby" , "TOPLEVEL_BINDING.eval('defined?(b).nil?')" , "test" ).interactive (false ).buildLiteral ()).asBoolean ());
205
+ assertTrue (polyglot .eval (Source .newBuilder ("ruby" , "TOPLEVEL_BINDING.eval('defined?(a).nil?')" , "test" ).interactive (true ).buildLiteral ()).asBoolean ());
206
+ assertTrue (polyglot .eval (Source .newBuilder ("ruby" , "TOPLEVEL_BINDING.eval('defined?(b).nil?')" , "test" ).interactive (true ).buildLiteral ()).asBoolean ());
207
+ }
208
+ }
209
+
192
210
}
0 commit comments