@@ -1022,12 +1022,15 @@ public void init() { // not in constructor because it has to be on Runnable.run(
1022
1022
runtime .magicVariables .forEach ((k , v ) -> {
1023
1023
// even hidden variables may need pre-processing
1024
1024
// for e.g. the __arg may contain functions that originated in a different js context
1025
- recurseAndAttach (k , v , seen );
1026
- setHiddenVariable (k , v );
1025
+ Object o = recurseAndAttach (k , v , seen );
1026
+ if (o == null ) {
1027
+ o = v ;
1028
+ }
1029
+ JS .put (k , o );
1027
1030
});
1028
1031
attachVariables (seen ); // re-hydrate any functions from caller or background
1029
- setHiddenVariable (KARATE , bridge );
1030
- setHiddenVariable (READ , readFunction );
1032
+ JS . put (KARATE , bridge );
1033
+ JS . put (READ , readFunction );
1031
1034
HttpClient client = runtime .featureRuntime .suite .clientFactory .create (this );
1032
1035
// edge case: can be set by dynamic scenario outline background
1033
1036
// or be left as-is because a callonce triggered init()
@@ -1072,12 +1075,6 @@ protected Map<String, Variable> detachVariables() {
1072
1075
return detached ;
1073
1076
}
1074
1077
1075
- // only called by "call" routine
1076
- protected void recurseAndAttach (String name , Object o ) {
1077
- Set <Object > seen = Collections .newSetFromMap (new IdentityHashMap ());
1078
- recurseAndAttach (name , o , seen );
1079
- }
1080
-
1081
1078
private Object recurseAndAttach (String name , Object o , Set <Object > seen ) {
1082
1079
if (o instanceof Value ) {
1083
1080
try {
@@ -1943,7 +1940,8 @@ public Variable call(Variable called, Variable arg, boolean sharedScope) {
1943
1940
case FEATURE :
1944
1941
// will be always a map or a list of maps (loop call result)
1945
1942
Object callResult = callFeature (called .getValue (), arg , -1 , sharedScope );
1946
- recurseAndAttach ("" , callResult );
1943
+ Set <Object > seen = Collections .newSetFromMap (new IdentityHashMap ());
1944
+ recurseAndAttach ("" , callResult , seen );
1947
1945
return new Variable (callResult );
1948
1946
default :
1949
1947
throw new RuntimeException ("not a callable feature or js function: " + called );
0 commit comments