Exemplo n.º 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
 public dynamic Evaluate(string line)
 {
     return(MrbMethods.mrb_load_string(mrbState, line));
 }