public void RubyHosting1B() {
ScriptScope scope = Engine.CreateScope();
scope.SetVariable("SomeValue", 1);
scope.SetVariable("other_value", 2);
// Method names are unmangled for scope lookups.
// "tmp" is defined in the top-level binding, which is associated with the scope:
Engine.Execute("tmp = some_value + other_value", scope);
// "tmp" symbol is extracted from scope's top-level binding and passed to the compiler as a compiler option
// so that the parser treats it as a local variable.
string tmpDefined = Engine.Execute<MutableString>("defined?(tmp)", scope).ToString();
Assert(tmpDefined == "local-variable");
// The code is eval'd against the existing top-level local scope created by the first execution.
// tmp2 local is looked up dynamically:
Engine.Execute("tmp2 = 10", scope);
// result= is turned into a scope variable assignment in method_missing:
Engine.Execute("self.result = tmp", scope);
// If "scope" variable is not defined on "self" and in the DLR scope we alias it for "self":
Engine.Execute("scope.result += tmp2", scope);
int result = scope.GetVariable<int>("result");
Assert(result == 13);
// Ruby local variables are not exposed:
Assert(scope.ContainsVariable("tmp") == false);
}