Пример #1
0
        public void Gen1()
        {
            NativeSymbolBag bag = new NativeSymbolBag();

            bag.AddConstant(new NativeConstant("C1", "1"));
            bag.AddConstant(new NativeConstant("C2", "1+C1"));
            VerifyConstValue(bag, "C2", string.Format("(1 + {0}.C1)", TransformConstants.NativeConstantsName));
        }
Пример #2
0
        public void Gen6()
        {
            NativeSymbolBag bag = new NativeSymbolBag();

            bag.AddConstant(new NativeConstant("A", "B"));
            bag.AddConstant(new NativeConstant("B", "A"));
            VerifyConstValue(bag, "A", string.Format("{0}.B", TransformConstants.NativeConstantsName));
            VerifyConstValue(bag, "B", string.Format("{0}.A", TransformConstants.NativeConstantsName));
        }
Пример #3
0
        public void Value1()
        {
            NativeSymbolBag bag = new NativeSymbolBag();

            bag.AddConstant(new NativeConstant("foo", "1"));
            bag.AddConstant(new NativeConstant("bar", "foo+2"));

            Assert.Equal(1, bag.FindUnresolvedNativeValues().Count);
            Assert.True(bag.TryResolveSymbolsAndValues());
        }
Пример #4
0
        public void Gen10()
        {
            NativeSymbolBag bag = new NativeSymbolBag();

            bag.AddConstant(new NativeConstant("A", "'a'"));
            bag.AddConstant(new NativeConstant("B", "'c'"));
            bag.AddConstant(new NativeConstant("C", "'\\n'"));
            VerifyConstValue(LanguageType.CSharp, bag, "A", "'a'", "System.Char");
            VerifyConstValue(LanguageType.CSharp, bag, "B", "'c'", "System.Char");
            VerifyConstValue(LanguageType.CSharp, bag, "C", "'\\n'", "System.Char");
        }
Пример #5
0
        public void Value4()
        {
            NativeSymbolBag bag      = new NativeSymbolBag();
            NativeConstant  ntConst1 = new NativeConstant("c1", "1");

            bag.AddConstant(ntConst1);
            NativeConstant ntConst2 = new NativeConstant("c2", "5+c1");

            bag.AddConstant(ntConst2);

            Assert.Equal(1, bag.FindUnresolvedNativeValues().Count);
            Assert.True(bag.TryResolveSymbolsAndValues());
        }
Пример #6
0
        public CodeTypeDeclarationCollection ConvertToCodeDom(NativeConstant c, ErrorProvider ep)
        {
            NativeSymbolBag bag = new NativeSymbolBag(_storage);

            bag.AddConstant(c);
            return(ConvertBagToCodeDom(bag, ep));
        }
Пример #7
0
        public void Invalid1()
        {
            NativeSymbolBag bag = new NativeSymbolBag(StorageFactory.CreateStandard());

            bag.AddConstant(new NativeConstant("c1", "(S1)5"));
            VerifyConstValue(bag, "c1", "\"(S1)5\"");
        }
Пример #8
0
        public void Gen11()
        {
            NativeSymbolBag bag = new NativeSymbolBag();

            bag.AddConstant(new NativeConstant("A", "FALSE;"));
            VerifyConstValue(LanguageType.CSharp, bag, "A", "\"FALSE;\"", "System.String");
        }
Пример #9
0
        public void Gen9()
        {
            NativeSymbolBag bag = new NativeSymbolBag();

            bag.AddConstant(new NativeConstant("A", "1.0"));
            VerifyConstValue(LanguageType.CSharp, bag, "A", "1F", "System.Single");
        }
Пример #10
0
        public void Gen8()
        {
            NativeSymbolBag bag = new NativeSymbolBag();

            bag.AddConstant(new NativeConstant("A", "0x5"));
            VerifyConstValue(LanguageType.CSharp, bag, "A", "5");
        }
Пример #11
0
        public void Gen5()
        {
            NativeSymbolBag bag = new NativeSymbolBag();

            bag.AddConstant(new NativeConstant("A", "A"));
            VerifyConstValue(bag, "A", "Nothing", "System.Object");
        }
Пример #12
0
        public void Gen4()
        {
            NativeSymbolBag bag = new NativeSymbolBag();

            bag.AddConstant(new NativeConstant("C1", "42"));
            NativeEnum e1 = new NativeEnum("e1");

            e1.AddValue("v1", "C1+2");
            bag.AddDefinedType(e1);
            VerifyEnumValue(bag, e1, "v1", string.Format("({0}.C1 + 2)", TransformConstants.NativeConstantsName));
        }
Пример #13
0
        public void ValueFromStorage1()
        {
            var ns = new BasicSymbolStorage();

            ns.AddConstant(new NativeConstant("c1", "1"));
            var bag = new NativeSymbolBag(ns);

            bag.AddConstant(new NativeConstant("c2", "5+c1"));

            Assert.Equal(1, bag.FindUnresolvedNativeValues().Count);
            Assert.True(bag.TryResolveSymbolsAndValues());
        }
Пример #14
0
        public void ValueFromStorage3()
        {
            var             ns  = new BasicSymbolStorage();
            NativeSymbolBag bag = new NativeSymbolBag(ns);

            ns.AddDefinedType(new NativeStruct("s1"));

            NativeConstant ntConst1 = new NativeConstant("c1", "(s1)1");

            bag.AddConstant(ntConst1);

            Assert.Equal(1, bag.FindUnresolvedNativeValues().Count);
            Assert.True(bag.TryResolveSymbolsAndValues());
        }
Пример #15
0
        public void Value3()
        {
            NativeSymbolBag bag       = new NativeSymbolBag();
            NativeStruct    ntStruct1 = new NativeStruct("s1");

            bag.AddDefinedType(ntStruct1);

            NativeConstant ntConst1 = new NativeConstant("c1", "(s1)1");

            bag.AddConstant(ntConst1);

            Assert.Equal(1, bag.FindUnresolvedNativeValues().Count);
            Assert.True(bag.TryResolveSymbolsAndValues());
        }
Пример #16
0
        public void ValueFromStorage2()
        {
            var ns  = new BasicSymbolStorage();
            var bag = new NativeSymbolBag(ns);

            NativeEnum ntEnum = new NativeEnum("e1");

            ntEnum.AddValue("v1", "5");
            bag.AddDefinedType(ntEnum);

            NativeConstant ntConst1 = new NativeConstant("c1", "5+v1");

            bag.AddConstant(ntConst1);

            Assert.Equal(1, bag.FindUnresolvedNativeValues().Count);
            Assert.True(bag.TryResolveSymbolsAndValues());
        }