예제 #1
0
        public void SetUp()
        {
            _state = new MondState();
            MondClassBinder.Bind <ClassTests.Person>(_state);

            var functions = new List <string>
            {
                "ArgumentTypes",

                "ReturnDouble", "ReturnFloat",
                "ReturnInt", "ReturnUInt",
                "ReturnShort", "ReturnUShort",
                "ReturnSByte", "ReturnByte",
                "ReturnString", "ReturnBool",
                "ReturnVoid",
                "ReturnNullString",

                "ReturnClass",

                "Add", "Concat", "Greet"
            };

            foreach (var func in functions)
            {
                _state[func] = MondFunctionBinder.Bind(typeof(FunctionTests).GetTypeInfo().GetMethod(func));
            }
        }
예제 #2
0
        public IEnumerable <KeyValuePair <string, MondValue> > GetDefinitions(MondState state)
        {
            var module = MondModuleBinder.Bind(typeof(DateTimeModule), state);

            MondClassBinder.Bind <DateTimeClass>(state);
            yield return(new KeyValuePair <string, MondValue>("DateTime", module));
        }
예제 #3
0
파일: ClassTests.cs 프로젝트: xserve98/Mond
        public void Constructor()
        {
            Assert.True(_state.Run("return global.brian.test;") == 123);

            Assert.True(MondClassBinder.Bind <NoConstructor>(_state) == null);

            Assert.DoesNotThrow(() => MondClassBinder.Bind <MultipleConstructors>(_state));
        }
예제 #4
0
파일: ClassTests.cs 프로젝트: xserve98/Mond
        public void SetUp()
        {
            _state           = new MondState();
            _state["Person"] = MondClassBinder.Bind <Person>(_state);

            _state.Run(@"
                global.brian = global.Person('Brian');
            ");
        }
예제 #5
0
        public MondValue ToMond(MondState state)
        {
            MondClassBinder.Bind <NamespaceReference>(state, out var prototype);

            var obj = new MondValue(state)
            {
                UserData  = this,
                Prototype = prototype
            };

            obj.Lock();

            return(obj);
        }
예제 #6
0
        public static MondValue Create(MondState state)
        {
            MondClassBinder.Bind <AsyncClass>(state, out var prototype);

            var instance = new AsyncClass();

            var obj = MondValue.Object();

            obj.UserData  = instance;
            obj.Prototype = prototype;
            obj.Lock();

            return(obj);
        }
예제 #7
0
        public static MondValue Create(MondState state, RequireLibrary require)
        {
            MondClassBinder.Bind <RequireClass>(state, out var prototype);

            var instance = new RequireClass();

            instance._require = require;

            var obj = new MondValue(MondValueType.Object);

            obj.UserData  = instance;
            obj.Prototype = prototype;
            obj.Lock();

            return(obj);
        }
예제 #8
0
        public static MondValue Create(MondState state, ConsoleInputLibrary consoleInput)
        {
            MondValue prototype;

            MondClassBinder.Bind <ConsoleInputClass>(state, out prototype);

            var instance = new ConsoleInputClass();

            instance._consoleInput = consoleInput;

            var obj = new MondValue(MondValueType.Object);

            obj.UserData  = instance;
            obj.Prototype = prototype;
            obj.Lock();

            return(obj);
        }
예제 #9
0
        public IEnumerable <KeyValuePair <string, MondValue> > GetDefinitions(MondState state)
        {
            var regexClass = MondClassBinder.Bind <RegexClass>(state);

            yield return(new KeyValuePair <string, MondValue>("Regex", regexClass));
        }
예제 #10
0
파일: ClassTests.cs 프로젝트: xserve98/Mond
 public void Duplicates()
 {
     Assert.DoesNotThrow(() => MondClassBinder.Bind <TestDuplicate>(_state));
 }