示例#1
0
        public void mrb_load_string_RaisesAnExceptionForInvalidCode()
        {
            var mrb = MrbMethods.mrb_open();

            Assert.Throws <Exception>(() => MrbMethods.mrb_load_string(mrb, "this is just some junk (not valid Ruby code)"));

            MrbMethods.mrb_close(mrb);
        }
示例#2
0
        public void mrb_load_string_CanRunSomeCodeAndGetFalseBack()
        {
            var mrb = MrbMethods.mrb_open();

            var value = MrbMethods.mrb_load_string(mrb, "false");

            Assert.True(value.IsFalse);

            MrbMethods.mrb_close(mrb);
        }
示例#3
0
        public void mrb_load_stirng_CanRunSomeCodeAndGetNilBack()
        {
            var mrb = MrbMethods.mrb_open();

            var value = MrbMethods.mrb_load_string(mrb, "nil");

            Assert.True(value.IsNil);

            MrbMethods.mrb_close(mrb);
        }
示例#4
0
        public void mrb_load_string_CanRunSomeCodeAndGetAFixnumBack()
        {
            var mrb = MrbMethods.mrb_open();

            var value = MrbMethods.mrb_load_string(mrb, "10 + 20");

            Assert.Equal(MrbValueType.Fixnum, value.ValueType);
            Assert.Equal(30U, value.IntegerValue);

            MrbMethods.mrb_close(mrb);
        }
示例#5
0
 public MRubyEnvironment()
 {
     mrbState = MrbMethods.mrb_open();
 }
示例#6
0
 public dynamic Evaluate(string line)
 {
     return(MrbMethods.mrb_load_string(mrbState, line));
 }
示例#7
0
 public void Dispose()
 {
     MrbMethods.mrb_close(mrbState);
 }
示例#8
0
        public void mrb_close_CanCloseAnEnvironment()
        {
            var mrb = MrbMethods.mrb_open();

            MrbMethods.mrb_close(mrb);
        }