Skip to content

Commit

Permalink
small changes while cleaning up #1558
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed Jun 21, 2021
1 parent 64d88b4 commit 4b56abb
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1022,12 +1022,15 @@ public void init() { // not in constructor because it has to be on Runnable.run(
runtime.magicVariables.forEach((k, v) -> {
// even hidden variables may need pre-processing
// for e.g. the __arg may contain functions that originated in a different js context
recurseAndAttach(k, v, seen);
setHiddenVariable(k, v);
Object o = recurseAndAttach(k, v, seen);
if (o == null) {
o = v;
}
JS.put(k, o);
});
attachVariables(seen); // re-hydrate any functions from caller or background
setHiddenVariable(KARATE, bridge);
setHiddenVariable(READ, readFunction);
JS.put(KARATE, bridge);
JS.put(READ, readFunction);
HttpClient client = runtime.featureRuntime.suite.clientFactory.create(this);
// edge case: can be set by dynamic scenario outline background
// or be left as-is because a callonce triggered init()
Expand Down Expand Up @@ -1072,12 +1075,6 @@ protected Map<String, Variable> detachVariables() {
return detached;
}

// only called by "call" routine
protected void recurseAndAttach(String name, Object o) {
Set<Object> seen = Collections.newSetFromMap(new IdentityHashMap());
recurseAndAttach(name, o, seen);
}

private Object recurseAndAttach(String name, Object o, Set<Object> seen) {
if (o instanceof Value) {
try {
Expand Down Expand Up @@ -1943,7 +1940,8 @@ public Variable call(Variable called, Variable arg, boolean sharedScope) {
case FEATURE:
// will be always a map or a list of maps (loop call result)
Object callResult = callFeature(called.getValue(), arg, -1, sharedScope);
recurseAndAttach("", callResult);
Set<Object> seen = Collections.newSetFromMap(new IdentityHashMap());
recurseAndAttach("", callResult, seen);
return new Variable(callResult);
default:
throw new RuntimeException("not a callable feature or js function: " + called);
Expand Down

0 comments on commit 4b56abb

Please sign in to comment.