Esempio n. 1
0
        public void FunctionVar_ParseTest_CustomPropertyNameOnly()
        {
            ITextProvider tp     = new StringTextProvider("var(--test)");
            TokenStream   tokens = Helpers.MakeTokenStream(tp);
            Function      f      = Function.ParseFunction(null, new ItemFactory(tp, null), tp, tokens);

            Assert.IsInstanceOfType(f, typeof(FunctionVar));

            FunctionVar fv = f as FunctionVar;

            Assert.AreEqual(1, fv.Arguments.Count);
            Assert.IsNotNull(fv.CustomPropertyName);
            Assert.AreEqual("--test", tp.GetText(fv.CustomPropertyName.Start, fv.CustomPropertyName.Length));
        }
Esempio n. 2
0
        public void FunctionVar_ParseTest_InvalidCustomPropertyName()
        {
            ITextProvider tp     = new StringTextProvider("var(test)");
            TokenStream   tokens = Helpers.MakeTokenStream(tp);
            Function      f      = Function.ParseFunction(null, new ItemFactory(tp, null), tp, tokens);

            Assert.IsInstanceOfType(f, typeof(FunctionVar));

            FunctionVar fv = f as FunctionVar;

            Assert.AreEqual(1, fv.Arguments.Count);
            Assert.IsNotNull(fv.CustomPropertyName);

            Assert.IsTrue(fv.ContainsParseErrors);
            Assert.AreEqual(1, fv.CustomPropertyName.ParseErrors.Count);
            Assert.AreEqual(ParseErrorType.CustomPropertyNameExpected, fv.CustomPropertyName.ParseErrors[0].ErrorType);
            Assert.AreEqual(ParseErrorLocation.WholeItem, fv.CustomPropertyName.ParseErrors[0].Location);
        }
Esempio n. 3
0
        public void FunctionVar_ParseTest_NoCustomPropertyName()
        {
            ITextProvider tp     = new StringTextProvider("var()");
            TokenStream   tokens = Helpers.MakeTokenStream(tp);
            Function      f      = Function.ParseFunction(null, new ItemFactory(tp, null), tp, tokens);

            Assert.IsInstanceOfType(f, typeof(FunctionVar));

            FunctionVar fv = f as FunctionVar;

            Assert.AreEqual(0, fv.Arguments.Count);
            Assert.IsNull(fv.CustomPropertyName);

            Assert.IsTrue(fv.ContainsParseErrors);
            Assert.AreEqual(1, fv.CloseBrace.ParseErrors.Count);
            Assert.AreEqual(ParseErrorType.FunctionArgumentMissing, fv.CloseBrace.ParseErrors[0].ErrorType);
            Assert.AreEqual(ParseErrorLocation.BeforeItem, fv.CloseBrace.ParseErrors[0].Location);
        }