Пример #1
0
        public void AliasForMember_ShouldProcessSymbolName()
        {
            var context = new Context();

            context.DefineConstructor(typeof(ClassWithAliasedMember));

            var name = context.Eval("ClassWithAliasedMember[Symbol.for('MySymbol')].name").Value.ToString();

            Assert.AreEqual("MySymbol", name);
        }
Пример #2
0
        public void AliasForMember_ShouldChangeNameOfFunction()
        {
            var context = new Context();

            context.DefineConstructor(typeof(ClassWithAliasedMember));

            var name = context.Eval("ClassWithAliasedMember.NameForJsSide.name").Value.ToString();

            Assert.AreEqual("NameForJsSide", name);
        }
Пример #3
0
        public void CreateInstanceOfGenericType()
        {
            var context = new Context();

            context.DefineConstructor(typeof(List <>));

            var result = context.Eval("new (List(Number))()").Value;

            Assert.AreSame(typeof(List <Number>), result.GetType());
        }
Пример #4
0
        public void AliasForMember_ShouldChangePropertyName()
        {
            var context = new Context();

            context.DefineConstructor(typeof(ClassWithAliasedMember));

            var names = context.Eval("Object.getOwnPropertyNames(ClassWithAliasedMember)").Value as NiL.JS.BaseLibrary.Array;

            Assert.IsTrue((bool)NiL.JS.BaseLibrary.Array.includes(names, new Arguments {
                "NameForJsSide"
            }));
            Assert.IsFalse((bool)NiL.JS.BaseLibrary.Array.includes(names, new Arguments {
                "NameForDotNetSide"
            }));
        }