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

ConstantCaching_CrossRuntime1() public method

public ConstantCaching_CrossRuntime1 ( ) : void
return void
        public void ConstantCaching_CrossRuntime1() {
            var engine2 = Ruby.CreateEngine();

            var c = Engine.Execute(@"
module C
  X = 1
end
C
");
            ((RubyContext)HostingHelpers.GetLanguageContext(engine2)).DefineGlobalVariable("C", c); 

            var m = engine2.Execute(@"
module M
  module N
    O = $C
  end
end
M
");
            Context.DefineGlobalVariable("M", m); 

            TestOutput(@"
module D
  E = $M
end

module Z
  module O
    X = 2
  end
end

i = 0
while i < 6
  puts D::E::N::O::X rescue p $!         # tested cache
  $M.send(:remove_const, :N) if i == 1
  $M.send(:const_set, :N, Z) if i == 3
  i += 1
end
", @"
1
1
#<NameError: uninitialized constant M::N>
#<NameError: uninitialized constant M::N>
2
2
");
        }
Tests