* Test of size method, of class BiVariableMap.
*/
@Test
public void testSize() {
logger1.info("size");
ScriptingContainer container =
new ScriptingContainer(LocalContextScope.SINGLETHREAD, LocalVariableBehavior.TRANSIENT);
BiVariableMap instance = container.getVarMap();
container.put("ARGV", new String[] {"spring", "fall"});
container.put("SEASON", new String[] {"summer", "winter"});
container.put("$sports", new String[] {"baseball", "hiking", "soccer", "ski"});
container.put("@weather", new String[] {"snow", "sleet", "drizzle", "rain"});
container.put("trees", new String[] {"cypress", "hemlock", "spruce"});
assertTrue(instance.size() == 5);
String[] expResult = {"snow", "sleet", "drizzle", "rain"};
String[] weather = (String[]) container.remove("@weather");
assertArrayEquals(expResult, weather);
assertTrue(instance.size() == 4);
// transient local variable should vanish after eval
container.runScriptlet("a = 1");
assertTrue(instance.size() == 3);
container = new ScriptingContainer(LocalContextScope.SINGLETHREAD, LocalVariableBehavior.PERSISTENT);
instance = container.getVarMap();
container.put("ARGV", new String[] {"spring", "fall"});
container.put("SEASON", new String[] {"summer", "winter"});
container.put("$sports", new String[] {"baseball", "hiking", "soccer", "ski"});
container.put("@weather", new String[] {"snow", "sleet", "drizzle", "rain"});
container.put("trees", new String[] {"cypress", "hemlock", "spruce"});
assertTrue(instance.size() == 5);
// persistent local variable should be kept even after eval, plus retrieved.
container.runScriptlet("a = 1");
assertTrue(instance.size() == 6);
container = new ScriptingContainer(LocalContextScope.SINGLETHREAD, LocalVariableBehavior.GLOBAL);
instance = container.getVarMap();
container.put("ARGV", new String[] {"spring", "fall"});
container.put("SEASON", new String[] {"summer", "winter"});
container.put("$sports", new String[] {"baseball", "hiking", "soccer", "ski"});
container.put("@weather", new String[] {"snow", "sleet", "drizzle", "rain"});
container.put("trees", new String[] {"cypress", "hemlock", "spruce"});
// $sports and @weather are not eligible key for local global type.
assertTrue(instance.size() == 3);
// local global variable should not be dropped.
// "a" in Ruby code is not local global var.
container.runScriptlet("a = 1");
assertTrue(instance.size() == 3);
}