IronRuby.Tests.Tests.RubyHosting1A C# (CSharp) Method

RubyHosting1A() public method

public RubyHosting1A ( ) : void
return void
        public void RubyHosting1A() {
            ScriptScope scope = Engine.Runtime.CreateScope();
            scope.SetVariable("x", 1);
            scope.SetVariable("y", 2);

            // Reads x, y from scope via method_missing.
            // The code is instance-eval'd as a proc against the scope so both instance and 
            // singleton method definitions define a singleton method on main object.
            // Method definition on main object bound to a scope copies the method to the scope.
            Engine.Execute("def z; x + y; end", scope);
            Engine.Execute("def self.w(a); a + 1; end", scope);

            int z = scope.GetVariable<Func<int>>("z")();
            Assert(z == 3);

            int w = scope.GetVariable<Func<int, int>>("w")(1);
            Assert(w == 2);
        }
Tests