Пример #1
0
        public void GetMethodFromSecondSuperClass()
        {
            DefinedClass proto = new DefinedClass("proto");
            DefinedClass super = new DefinedClass("object");
            IFunction method = new NativeMethod(this.DummyMethod);
            super.SetValue("foo", method);
            DefinedClass klass = new DefinedClass("Spam", new IType[] { proto, super });

            var result = klass.GetMethod("foo");
            Assert.IsNotNull(result);
            Assert.IsTrue(klass.HasMethod("foo"));
        }
Пример #2
0
        public void DefineMethodUsingSetValue()
        {
            DefinedClass klass = new DefinedClass("Spam");
            IFunction method = new NativeMethod(this.DummyMethod);

            klass.SetValue("foo", method);

            var result = klass.GetMethod("foo");
            Assert.IsNotNull(result);
            Assert.AreEqual(method, result);
            Assert.IsTrue(klass.HasMethod("foo"));
            Assert.IsTrue(klass.HasValue("foo"));
        }
Пример #3
0
        public void ReplaceMethodWithAttribute()
        {
            DefinedClass klass = new DefinedClass("Spam");
            IFunction method = new NativeMethod(this.DummyMethod);

            klass.SetMethod("foo", method);
            klass.SetValue("foo", 1);

            var result = klass.GetMethod("foo");
            Assert.IsNull(result);
            Assert.IsFalse(klass.HasMethod("foo"));
            Assert.AreEqual(1, klass.GetValue("foo"));
            Assert.IsTrue(klass.HasValue("foo"));
        }
Пример #4
0
        public void GetUndefinedMethodAsNull()
        {
            DefinedClass klass = new DefinedClass("Spam");

            var result = klass.GetMethod("foo");
            Assert.IsNull(result);
            Assert.IsFalse(klass.HasMethod("foo"));
        }