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

RubyHosting3() public method

public RubyHosting3 ( ) : void
return void
        public void RubyHosting3() {
            object value;
            Engine.Execute("C = 1");

            // non-module values are not published:
            Assert(!Runtime.Globals.TryGetVariable("C", out value));

            // built-ins are not published:
            Assert(!Runtime.Globals.TryGetVariable("Object", out value));
            Assert(!Runtime.Globals.TryGetVariable("String", out value));

            // global modules and classes are published:
            Engine.Execute("class D; end");
            Assert(Runtime.Globals.TryGetVariable("D", out value));
            Assert(((RubyClass)value).Name == "D");
            
            // assignment to a constant on Object class also publishes modules and classes:
            Engine.Execute("E = Module.new");
            Assert(Runtime.Globals.TryGetVariable("E", out value));
            Assert(((RubyModule)value).Name == "E");

            // TODO:
            // the library paths are incorrect (not combined with location of .exe file) in partial trust:
            if (_driver.PartialTrust) return;

            var searchPaths = Engine.GetSearchPaths();

            bool result = Engine.RequireFile("fcntl");
            Assert(result == true);

            // built-in class:
            Assert(Context.ObjectClass.TryGetConstant(null, "String", out value) 
                && ((RubyModule)value).Restrictions == ModuleRestrictions.Builtin);

            // IronRuby specific built-in class:
            Assert(Context.ObjectClass.TryGetConstant(null, "IronRuby", out value)
                && ((RubyModule)value).Restrictions == ModuleRestrictions.NotPublished);

            // a class from standard library:
            Assert(Context.ObjectClass.TryGetConstant(null, "Fcntl", out value)
                && ((RubyModule)value).Restrictions == (ModuleRestrictions.None | ModuleRestrictions.NoUnderlyingType));

            // standard library classes are also published (whether implemented in C# or not):
            var module = Runtime.Globals.GetVariable("Fcntl");
            Assert(module is RubyModule && ((RubyModule)module).Name == "Fcntl");
        }
Tests