예제 #1
0
        public void DefaultValues()
        {
            var sut = new MethodDeclaration();

            Assert.AreEqual(Names.UnknownMethod, sut.Name);
            Assert.False(sut.IsEntryPoint);
            Assert.AreEqual(Lists.NewList <IMethodDeclaration>(), sut.Body);
            Assert.AreNotEqual(0, sut.GetHashCode());
            Assert.AreNotEqual(1, sut.GetHashCode());
        }
예제 #2
0
        public void Equality_Default()
        {
            var a = new MethodDeclaration();
            var b = new MethodDeclaration();

            Assert.AreEqual(a, b);
            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
        }
예제 #3
0
        public void Equality_DifferentBody()
        {
            var a = new MethodDeclaration();

            a.Body.Add(new ContinueStatement());
            var b = new MethodDeclaration();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
예제 #4
0
        public void Equality_DifferentEntryPoint()
        {
            var a = new MethodDeclaration {
                IsEntryPoint = true
            };
            var b = new MethodDeclaration();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
예제 #5
0
        public static OverloadsCollection Create(IEmitter emitter, MethodDeclaration methodDeclaration)
        {
            string key = methodDeclaration.GetHashCode().ToString();
            if (emitter.OverloadsCache.ContainsKey(key))
            {
                return emitter.OverloadsCache[key];
            }

            return new OverloadsCollection(emitter, methodDeclaration);
        }
예제 #6
0
        public static OverloadsCollection Create(IEmitter emitter, MethodDeclaration methodDeclaration)
        {
            string key = methodDeclaration.GetHashCode().ToString();

            if (emitter.OverloadsCache.ContainsKey(key))
            {
                return(emitter.OverloadsCache[key]);
            }

            return(new OverloadsCollection(emitter, methodDeclaration));
        }
예제 #7
0
 private OverloadsCollection(IEmitter emitter, MethodDeclaration methodDeclaration)
 {
     this.Emitter        = emitter;
     this.Name           = methodDeclaration.Name;
     this.JsName         = this.Emitter.GetEntityName(methodDeclaration, false, true);
     this.Inherit        = !methodDeclaration.HasModifier(Modifiers.Static);
     this.Static         = methodDeclaration.HasModifier(Modifiers.Static);
     this.Member         = this.FindMember(methodDeclaration);
     this.TypeDefinition = this.Member.DeclaringTypeDefinition;
     this.Type           = this.Member.DeclaringType;
     this.InitMembers();
     this.Emitter.OverloadsCache[methodDeclaration.GetHashCode().ToString()] = this;
 }
예제 #8
0
 private OverloadsCollection(IEmitter emitter, MethodDeclaration methodDeclaration)
 {
     this.Emitter = emitter;
     this.Name = methodDeclaration.Name;
     this.JsName = this.Emitter.GetEntityName(methodDeclaration, false, true);
     this.Inherit = !methodDeclaration.HasModifier(Modifiers.Static);
     this.Static = methodDeclaration.HasModifier(Modifiers.Static);
     this.Member = this.FindMember(methodDeclaration);
     this.TypeDefinition = this.Member.DeclaringTypeDefinition;
     this.Type = this.Member.DeclaringType;
     this.InitMembers();
     this.Emitter.OverloadsCache[methodDeclaration.GetHashCode().ToString()] = this;
 }
예제 #9
0
        public void Equality_DifferentName()
        {
            var a = new MethodDeclaration
            {
                Name = _mA
            };
            var b = new MethodDeclaration
            {
                Name = _mB
            };

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
예제 #10
0
        public void Equality_ReallyTheSame()
        {
            var a = new MethodDeclaration
            {
                Name         = _mA,
                IsEntryPoint = true,
                Body         = { new ReturnStatement() }
            };
            var b = new MethodDeclaration
            {
                Name         = _mA,
                IsEntryPoint = true,
                Body         = { new ReturnStatement() }
            };

            Assert.AreEqual(a, b);
            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
        }