public void Dlr_RubyObjects()
        {
            var scope = Engine.CreateScope();

            Engine.Execute(@"
scope.ruby_array = [100, 200]
scope.ruby_hash = { 1 => 3, 2 => 4 }

def inc(a)
  a + 1
end

scope.ruby_method = method(:inc)
scope.ruby_proc = proc { |a| a + 2 } 
", scope);

#if !CLR2
            dynamic s = scope;
            AreEqual(s.ruby_array[0], 100);
            AreEqual(s.ruby_hash[1], 3);
            AreEqual(s.ruby_method(1), 2);
            AreEqual(s.ruby_proc(1), 3);
#endif
            object method = scope.GetVariable("ruby_method");
            AreEqual(MyInvokeBinder.Invoke(method, 1), 2);

            object proc = scope.GetVariable("ruby_proc");
            AreEqual(MyInvokeBinder.Invoke(proc, 1), 3);
        }
        public void Dlr_MethodMissing()
        {
            var    scope          = CreateInteropScope();
            object dynamic_object = scope.GetVariable("dynamic_object");

            AreEqual(MyInvokeMemberBinder.Invoke(dynamic_object, "non_existent_method"), "dynamic_non_existent_method");

            AreEqual(MySetMemberBinder.Invoke(dynamic_object, "non_existent_member", 100), 100);

            // Ruby doesn't have "mising_property" so we get a method, not the value:
            AreEqual(MyInvokeBinder.Invoke(MyGetMemberBinder.Invoke(dynamic_object, "non_existent_member")), 100);

            AreEqual(MyGetIndexBinder.Invoke(dynamic_object, "non_existent_index"), "dynamic_element_non_existent_index");
            AreEqual(MySetIndexBinder.Invoke(dynamic_object, "non_existent_index", 100), 100);
            AreEqual(MyGetIndexBinder.Invoke(dynamic_object, "non_existent_index"), 100);

            AreEqual(MyInvokeMemberBinder.Invoke(dynamic_object, "explicit_attribute"), "explicit_attribute");
        }
        public void Dlr_Miscellaneous()
        {
            var    scope       = CreateInteropScope();
            object misc_object = scope.GetVariable("misc");

            object misc_class = MyInvokeMemberBinder.Invoke(misc_object, "class");

            AreEqual(Engine.Runtime.Globals.GetVariable <object>("Miscellaneous"), misc_class);

            // singleton methods are only invokable on the class object, not the instance:
            AreEqual(MyInvokeMemberBinder.Invoke(misc_class, "static_method"), "static_method");
            AreEqual(MyInvokeMemberBinder.Invoke(misc_object, "static_method"), "FallbackInvokeMember");

            object callable = MyInvokeMemberBinder.Invoke(misc_object, "get_a_ruby_callable");

            AreEqual(MyInvokeMemberBinder.Invoke(misc_object, "ruby_callable_called"), false);
            MyInvokeBinder.Invoke(callable);
            AreEqual(MyInvokeMemberBinder.Invoke(misc_object, "ruby_callable_called"), true);

            // "ToString" is not handled in any special way by Ruby binder.
            // The call falls back to the caller's binder that should then call .NET ToString method.
            // ToString is overridden by all Ruby objects to call to_s.
            AreEqual(MyInvokeMemberBinder.Invoke(misc_class, "ToString"), "FallbackInvokeMember");
        }