Example #1
0
        public void Test_3_5_10_Selectors_C()
        {
            // An unadorned identifier is an identifier which is not immediately preceded by a '#'.
            // If a ':' followed by an '=' immediately follows an unadorned identifier,
            // with no intervening white space, then the token is to be parsed as an
            // identifier followed by an assignmentOperator not as an keyword followed by an '='.
            Scanner lexer = this.GetLexer("#isGood1Time:true");
            // Identifier token
            object obj = lexer.GetToken();

            Assert.IsInstanceOfType(obj, typeof(QuotedSelectorToken));
            QuotedSelectorToken token = (QuotedSelectorToken)obj;

            Assert.IsTrue(token.IsValid);
            Assert.IsNull(token.ScanError);
            Assert.AreEqual(0, token.StartPosition.Position);
            Assert.AreEqual(12, token.StopPosition.Position);
            Assert.AreEqual("isGood1Time:", token.Value);
            // Assignment token
            obj = lexer.GetToken();
            Assert.IsInstanceOfType(obj, typeof(IdentifierToken));
            IdentifierToken idf = (IdentifierToken)obj;

            Assert.IsTrue(idf.IsValid);
            Assert.IsNull(idf.ScanError);
            Assert.AreEqual(13, idf.StartPosition.Position);
            Assert.AreEqual(16, idf.StopPosition.Position);
            Assert.AreEqual("true", idf.Value);

            // Should be the last one
            obj = lexer.GetToken();
            Assert.IsInstanceOfType(obj, typeof(EofToken));
        }
Example #2
0
        public void Test_3_5_10_Selectors_A()
        {
            Scanner lexer = this.GetLexer("#isGood1Time:");
            object  obj   = lexer.GetToken();

            Assert.IsInstanceOfType(obj, typeof(QuotedSelectorToken));
            QuotedSelectorToken token = (QuotedSelectorToken)obj;

            Assert.IsTrue(token.IsValid);
            Assert.IsNull(token.ScanError);
            Assert.AreEqual(0, token.StartPosition.Position);
            Assert.AreEqual(12, token.StopPosition.Position);
            Assert.AreEqual("isGood1Time:", token.Value);
            // Should be the last one
            obj = lexer.GetToken();
            Assert.IsInstanceOfType(obj, typeof(EofToken));

            lexer = this.GetLexer("#isGood1Time ");
            obj   = lexer.GetToken();
            Assert.IsInstanceOfType(obj, typeof(QuotedSelectorToken));
            token = (QuotedSelectorToken)obj;
            Assert.IsTrue(token.IsValid);
            Assert.IsNull(token.ScanError);
            Assert.AreEqual(0, token.StartPosition.Position);
            Assert.AreEqual(11, token.StopPosition.Position);
            Assert.AreEqual("isGood1Time", token.Value);
            // Should be the last one
            obj = lexer.GetToken();
            Assert.IsInstanceOfType(obj, typeof(WhitespaceToken));

            lexer = this.GetLexer("#with:with: ");
            obj   = lexer.GetToken();
            Assert.IsInstanceOfType(obj, typeof(QuotedSelectorToken));
            token = (QuotedSelectorToken)obj;
            Assert.IsTrue(token.IsValid);
            Assert.IsNull(token.ScanError);
            Assert.AreEqual(0, token.StartPosition.Position);
            Assert.AreEqual(10, token.StopPosition.Position);
            Assert.AreEqual("with:with:", token.Value);
            // Should be the last one
            obj = lexer.GetToken();
            Assert.IsInstanceOfType(obj, typeof(WhitespaceToken));
        }