package org.mozilla.javascript.tests;
import org.mozilla.javascript.*;
import java.util.Collections;
import java.util.Map;

public class Evaluator {

  public static Object eval(String source) {
    return eval(source, null);
  }

  public static Object eval(String source, String id, Scriptable object) {
    return eval(source, Collections.singletonMap(id, object));
  }

  public static Object eval(String source, Map<String, Scriptable> bindings) {
    Context cx = ContextFactory.getGlobal().enterContext();
    try {
      Scriptable scope = cx.initStandardObjects();
      if (bindings != null) {
          for (String id : bindings.keySet()) {
            Scriptable object = bindings.get(id);
            object.setParentScope(scope);
            scope.put(id, scope, object);
          }
      }
      return cx.evaluateString(scope, source, "source", 1, null);
    } finally {
      Context.exit();
    }
  }
}

@@ -612,25 +612,51 @@
    for (
-String id
+Map.Entry%3CString, Scriptable%3E entry
  : bindi
@@ -663,10 +663,12 @@
 ngs.
-k
 e
+ntr
 ySet
@@ -681,24 +681,30 @@
             
+final 
 Scriptable o
@@ -715,23 +715,23 @@
 t = 
-bindings.get(id
+entry.getValue(
 );%0A 
@@ -793,18 +793,30 @@
 ope.put(
-id
+entry.getKey()
 , scope,

use entrySet() instead of keySet() with get()