Esempio n. 1
0
        public void PatternSearch4_LoopUntilMatch()
        {
            var src = @"{a: 'Budilnik', 'Name': 'Znatoki', q: 2, z: 148, 'hero': 0x7f}";

            var lxr = new JL(new StringSource(src));


            var capture = lxr.LazyFSM(
                (s, t) => s.LoopUntilMatch(
                    (ss, tk) => tk.LoopUntilAny(JSONTokenType.tStringLiteral),
                    (ss, tk) => tk.IsAnyOrAbort(JSONTokenType.tColon),
                    (ss, tk) => tk.IsAnyOrAbort(JSONTokenType.tStringLiteral),
                    (ss, tk) => FSMI.TakeAndComplete
                    ),
                (s, t) => s.Skip(3),
                (s, t) => t.LoopUntilAny(JSONTokenType.tStringLiteral),
                (s, t) => t.IsAnyOrAbort(JSONTokenType.tColon),
                (s, t) => FSMI.Take,
                (s, t) => t.IsAnyOrAbort(JSONTokenType.tBraceClose)
                );

            Assert.IsNotNull(capture);

            Assert.AreEqual(JSONTokenType.tIntLiteral, capture.Type);
            Assert.AreEqual(127, capture.Value);
        }
Esempio n. 2
0
 public FSM(JSONLexer lex)
 {
     lexer  = lex;
     source = lexer.Source;
     tokens = lexer.m_Tokens;
     srcRef = lexer.SourceCodeReference;
 }
Esempio n. 3
0
        public void PatternSearch5_Skip()
        {
            var src = @"{a: 'Budilnik', 'Name': 'Znatoki', q:2, z: 148, 'hero': 0x7f}";

            var lxr = new JL(new StringSource(src));


            var capture = lxr.LazyFSM(
                (s, t) => s.Skip(1),
                (s, t) => FSMI.Take
                );

            Assert.IsNotNull(capture);
            Assert.AreEqual(JSONTokenType.tIdentifier, capture.Type);
            Assert.AreEqual("a", capture.Text);

            capture = lxr.LazyFSM(
                (s, t) => s.Skip(9),
                (s, t) => FSMI.Take
                );

            Assert.IsNotNull(capture);
            Assert.AreEqual(JSONTokenType.tIdentifier, capture.Type);
            Assert.AreEqual("q", capture.Text);
        }
Esempio n. 4
0
        public void ePrematureEOF_Thrown()
        {
          var src = @"";

          var lxr = new JL(new StringSource(src));
          lxr.AnalyzeAll();
        }
        /// <summary>
        /// Checks all pattern match attributes against specified member info until first match found
        /// </summary>
        public static bool Check(MemberInfo info, JSONLexer content)
        {
            var attrs = info.GetCustomAttributes(typeof(JSONPatternMatchAttribute), true).Cast<JSONPatternMatchAttribute>();
            foreach(var attr in attrs)
                if (attr.Match(content)) return true;

            return false;
        }
Esempio n. 6
0
        public void String_Escapes2()
        {
            var src = @"{'str\'ing'}";

            var lxr = new JL(new StringSource(src));

            Aver.AreEqual(@"str'ing", lxr.ElementAt(2).Text);
        }
Esempio n. 7
0
        public void String_Escapes4_Unicode()
        {
            var src = @"{'str\u8978ring'}";

            var lxr = new JL(new StringSource(src));

            Aver.AreEqual("str\u8978ring", lxr.ElementAt(2).Text);
        }
Esempio n. 8
0
        public void String_Escapes2_2()
        {
            var src = @"{a: -2, 'string\'': 2}";

            var lxr = new JL(new StringSource(src));

            Assert.AreEqual(@"string'", lxr.ElementAt(7).Text);
        }
Esempio n. 9
0
        public void String_Escapes6_ForwardSlash()
        {
            var src = @"{'male\/female'}";

            var lxr = new JL(new StringSource(src));

            Assert.AreEqual("male/female", lxr.ElementAt(2).Text);
        }
Esempio n. 10
0
        public void String_Escapes1()
        {
            var src = @"{""str\""ing""}";

            var lxr = new JL(new StringSource(src));

            Assert.AreEqual(@"str""ing", lxr.ElementAt(2).Text);
        }
Esempio n. 11
0
        public void ePrematureEOF_Thrown()
        {
            var src = @"";

            var lxr = new JL(new StringSource(src));

            lxr.AnalyzeAll();
        }
Esempio n. 12
0
        public void eUnterminatedString2()
        {
            var src = @"a: ""aaaa";

            var lxr = new JL(new StringSource(src));

            lxr.AnalyzeAll();
        }
Esempio n. 13
0
        public void String_Escapes5_Unicode()
        {
            var src = @"{""str\u8978ring""}";

            var lxr = new JL(new StringSource(src));

            Assert.AreEqual("str\u8978ring", lxr.ElementAt(2).Text);
        }
Esempio n. 14
0
        public void String_Escapes3()
        {
            var src = @"{'str\n\rring'}";

            var lxr = new JL(new StringSource(src));

            Assert.AreEqual("str\n\rring", lxr.ElementAt(2).Text);
        }
Esempio n. 15
0
        public void BOF_EOF()
        {
          var src = @"a";

          var lxr = new JL(new StringSource(src));

          var expected = new JSONTokenType[]{JSONTokenType.tBOF, JSONTokenType.tIdentifier, JSONTokenType.tEOF};
          Assert.IsTrue( lxr.Select(t => t.Type).SequenceEqual(expected) );
        }
Esempio n. 16
0
        public void MinusInt()
        {
            var src = @"{-12}";

            var lxr = new JL(new StringSource(src));

            Assert.AreEqual(JSONTokenType.tMinus, lxr.ElementAt(2).Type);
            Assert.AreEqual(12, lxr.ElementAt(3).Value);
        }
Esempio n. 17
0
        public void MinusInt()
        {
            var src = @"{-12}";

            var lxr = new JL(new StringSource(src));

            Aver.IsTrue(JSONTokenType.tMinus == lxr.ElementAt(2).Type);
            Aver.AreObjectsEqual(12, lxr.ElementAt(3).Value);
        }
Esempio n. 18
0
        public void String2()
        {
            var src = @"{""string""}";

            var lxr = new JL(new StringSource(src));

            var expected = new JSONTokenType[] { JSONTokenType.tBOF, JSONTokenType.tBraceOpen, JSONTokenType.tStringLiteral, JSONTokenType.tBraceClose, JSONTokenType.tEOF };

            Assert.IsTrue(lxr.Select(t => t.Type).SequenceEqual(expected));
        }
Esempio n. 19
0
        public void eUnterminatedComment1()
        {
            var src = @"a: /*aa
          
          aa";

            var lxr = new JL(new StringSource(src));

            lxr.AnalyzeAll();
        }
Esempio n. 20
0
        public void BOF_EOF()
        {
            var src = @"a";

            var lxr = new JL(new StringSource(src));

            var expected = new JSONTokenType[] { JSONTokenType.tBOF, JSONTokenType.tIdentifier, JSONTokenType.tEOF };

            Assert.IsTrue(lxr.Select(t => t.Type).SequenceEqual(expected));
        }
Esempio n. 21
0
        public void eUnterminatedString4_Verbatim()
        {
            var src = @"a: $'aa
          
          aa";

            var lxr = new JL(new StringSource(src));

            lxr.AnalyzeAll();
        }
Esempio n. 22
0
        public void JSONPatternMatchAttribute2()
        {
            var src = @"{ code: 1121982, 'FirstName': 'Alex', DOB: null}";

            var lxr = new JL(new StringSource(src));

            var match = JSONPatternMatchAttribute.Check(MethodBase.GetCurrentMethod(), lxr);


            Aver.IsTrue(match);
        }
Esempio n. 23
0
        public void Comments9()
        {
            var src = @"{
          /* //comment text " + "\n\r" + @" */
          }
          ";

            var lxr = new JL(new StringSource(src));

            Aver.AreEqual(" //comment text \n\r ", lxr.ElementAt(2).Text);
        }
Esempio n. 24
0
        public void JSONPatternMatchAttribute3()
        {
            var src = @"{ code: 1121982, color: red, 'first_name': 'Alex', DOB: null}";

            var lxr = new JL(new StringSource(src));

            var match = JSONPatternMatchAttribute.Check(MethodBase.GetCurrentMethod(), lxr);


            Assert.IsTrue(match);
        }
Esempio n. 25
0
        public void ePrematureEOF_CouldLogButThrown()
        {
          var src = @"";

          var msgs = new MessageList();

          var lxr = new JL(new StringSource(src), msgs, throwErrors: true);
          lxr.AnalyzeAll();

          Assert.IsNotNull(msgs.FirstOrDefault(m => m.Type == MessageType.Error && m.Code == (int)JSONMsgCode.ePrematureEOF));
        }
Esempio n. 26
0
        public void Comments4()
        {
            var src = @"{
           //comment text
          }
          ";

            var lxr = new JL(new StringSource(src));

            Assert.AreEqual("comment text", lxr.ElementAt(2).Text);
        }
Esempio n. 27
0
        public void JSONPatternMatchAttribute1()
        {
            var src = @"1,2,3,4,5,6,7,8,9 : 'Name': 'Znatoki' null 'ok'";

            var lxr = new JL(new StringSource(src));

            var match = JSONPatternMatchAttribute.Check(MethodBase.GetCurrentMethod(), lxr);


            Assert.IsFalse(match);
        }
Esempio n. 28
0
        public void Comments8()
        {
            var src = @"{
          /* //comment text " + "\r\n" + @" */
          }
          ";

            var lxr = new JL(new StringSource(src));

            Assert.AreEqual(" //comment text \r\n ", lxr.ElementAt(2).Text);
        }
Esempio n. 29
0
        public void Comments10()
        {
            var src = @"{       
          |* /* //comment text " + "\n\r" + @" */ *|
          }
          ";

            var lxr = new JL(new StringSource(src));

            Assert.AreEqual(" /* //comment text \n\r */ ", lxr.ElementAt(2).Text);
        }
Esempio n. 30
0
        public void Comments13withStrings()
        {
            var src = @"{       
          |*'aaaa /* //comment""text " + "\n\r" + @" */ *|
          }
          ";
            var lxr = new JL(new StringSource(src));

            Assert.AreEqual(JSONTokenType.tComment, lxr.ElementAt(2).Type);
            Assert.AreEqual("'aaaa /* //comment\"text \n\r */ ", lxr.ElementAt(2).Text);
        }
Esempio n. 31
0
        public void ePrematureEOF_CouldLogButThrown()
        {
            var src = @"";

            var msgs = new MessageList();

            var lxr = new JL(new StringSource(src), msgs, throwErrors: true);

            lxr.AnalyzeAll();

            Assert.IsNotNull(msgs.FirstOrDefault(m => m.Type == MessageType.Error && m.Code == (int)JSONMsgCode.ePrematureEOF));
        }
Esempio n. 32
0
        public void Comments12withStrings()
        {
            //string is opened but line break
            var src = @"{       
          '|* /* //comment text " + "\n\r" + @" */ *|'
          }
          ";

            var lxr = new JL(new StringSource(src));

            lxr.AnalyzeAll();
        }
Esempio n. 33
0
 public override bool Match(NFX.CodeAnalysis.JSON.JSONLexer content)
 {
     return(content.LazyFSM(
                (s, t) => s.LoopUntilMatch(
                    (ss, tk) => tk.LoopUntilAny("First-Name", "FirstName", "first_name"),
                    (ss, tk) => tk.IsAnyOrAbort(JSONTokenType.tColon),
                    (ss, tk) => tk.IsAnyOrAbort(JSONTokenType.tStringLiteral),
                    (ss, tk) => FSMI.TakeAndComplete
                    ),
                (s, t) => FSMI.Take
                ) != null);
 }
Esempio n. 34
0
        public void String_Escapes2_2()
        {
          var src = @"{a: -2, 'string\'': 2}";
                                               
          var lxr = new JL(new StringSource(src));

          Assert.AreEqual(@"string'", lxr.ElementAt(7).Text);
        }
Esempio n. 35
0
        public void String_Escapes3()
        {
          var src = @"{'str\n\rring'}";
                                               
          var lxr = new JL(new StringSource(src));

          Assert.AreEqual("str\n\rring", lxr.ElementAt(2).Text);
        }
Esempio n. 36
0
        public void PatternSearch10_LoopUntilAfterMatch()
        {
          var src = @"1,2,3,4,5,6,7,8,9 : 'Name': 'Znatoki' null 'ok'";

          var lxr = new JL(new StringSource(src));

                    
          var capture = lxr.LazyFSM(
                 (s,t) => s.LoopUntilAfterMatch(
                                            (ss, tk) => tk.LoopUntilAny(JSONTokenType.tStringLiteral),
                                            (ss, tk) => tk.IsAnyOrAbort(JSONTokenType.tColon),
                                            (ss, tk) => tk.IsAnyOrAbort(JSONTokenType.tStringLiteral),
                                            (ss, tk) => FSMI.TakeAndComplete
                                          ),
                 (s,t) => FSMI.Take
             );
        
          Assert.IsNotNull( capture );
          Assert.AreEqual( JSONTokenType.tNull, capture.Type );
        }
Esempio n. 37
0
        public void Comments8()
        {
          var src = @"{
          /* //comment text "+"\r\n"+@" */
          }
          ";

          var lxr = new JL(new StringSource(src));

          Assert.AreEqual(" //comment text \r\n ", lxr.ElementAt(2).Text);
        }
Esempio n. 38
0
        public void PatternSearch3()
        {
          var src = @"{a: 2, b: 'Znatoki'}";

          var lxr = new JL(new StringSource(src));

                    
          var bvalue = lxr.LazyFSM(
                 (s,t) => t.LoopUntilAny("b"),
                 (s,t) => t.IsAnyOrAbort(JSONTokenType.tColon),
                 (s,t) => FSMI.Take,
                 (s,t) => t.IsAnyOrAbort(JSONTokenType.tComma)
             );
          
          Assert.AreEqual( null, bvalue );
        }
Esempio n. 39
0
        public void PatternSearch7_LoopUntilAfterMatch()
        {
          var src = @"{a: 'Budilnik', 'Name': 'Znatoki', q: 2, z: 148, 'hero': 0x7f}";

          var lxr = new JL(new StringSource(src));

                    
          var capture = lxr.LazyFSM(
                 (s,t) => s.LoopUntilAfterMatch(
                                            (ss, tk) => tk.IsAnyOrAbort(JSONTokenType.tStringLiteral),
                                            (ss, tk) => tk.IsAnyOrAbort(JSONTokenType.tColon),
                                            (ss, tk) => tk.IsAnyOrAbort(JSONTokenType.tStringLiteral),
                                            (ss, tk) => FSMI.TakeAndComplete
                                          ),
                 (s,t) => FSMI.Take
             );
        
          Assert.IsNotNull( capture );
          Assert.AreEqual( JSONTokenType.tComma, capture.Type );
        }
Esempio n. 40
0
        public void eUnterminatedComment1()
        {
          var src = @"a: /*aa
          
          aa";

          var lxr = new JL(new StringSource(src));
          lxr.AnalyzeAll();
        }
Esempio n. 41
0
        public void MinusInt()
        {
          var src = @"{-12}";
                                               
          var lxr = new JL(new StringSource(src));

          Assert.AreEqual(JSONTokenType.tMinus, lxr.ElementAt(2).Type);
          Assert.AreEqual(12, lxr.ElementAt(3).Value);
        }
Esempio n. 42
0
        public void Comments13withStrings()
        {
          var src = @"{       
          |*'aaaa /* //comment""text "+"\n\r"+@" */ *|
          }
          ";
          var lxr = new JL(new StringSource(src));

          Assert.AreEqual(JSONTokenType.tComment, lxr.ElementAt(2).Type);
          Assert.AreEqual("'aaaa /* //comment\"text \n\r */ ", lxr.ElementAt(2).Text);
        }
Esempio n. 43
0
        public void Comments3()
        {
          var src = @"{/*
                     
          'string //'}//inner
          */
          }
          ";

          var lxr = new JL(new StringSource(src));

          var expected = new JSONTokenType[]{JSONTokenType.tBOF, JSONTokenType.tBraceOpen, JSONTokenType.tComment, JSONTokenType.tBraceClose, JSONTokenType.tEOF};
          Assert.IsTrue( lxr.Select(t => t.Type).SequenceEqual(expected) );
        }
Esempio n. 44
0
        public void Comments12withStrings()
        {
          //string is opened but line break
          var src = @"{       
          '|* /* //comment text "+"\n\r"+@" */ *|'
          }
          ";

          var lxr = new JL(new StringSource(src));

          lxr.AnalyzeAll();
        }
Esempio n. 45
0
        public void Comments11withStrings()
        {
          var src = @"{       
          $'|* /* //comment text "+"\n\r"+@" */ *|'
          }
          ";

          var lxr = new JL(new StringSource(src));

          Assert.AreEqual(JSONTokenType.tStringLiteral, lxr.ElementAt(2).Type);
          Assert.AreEqual("|* /* //comment text \n\r */ *|", lxr.ElementAt(2).Text);
        }
Esempio n. 46
0
        public void Comments10()
        {
          var src = @"{       
          |* /* //comment text "+"\n\r"+@" */ *|
          }
          ";

          var lxr = new JL(new StringSource(src));

          Assert.AreEqual(" /* //comment text \n\r */ ", lxr.ElementAt(2).Text);
        }
Esempio n. 47
0
        public void String_Escapes5_Unicode()
        {
          var src = @"{""str\u8978ring""}";
                                               
          var lxr = new JL(new StringSource(src));

          Assert.AreEqual("str\u8978ring", lxr.ElementAt(2).Text);
        }
Esempio n. 48
0
        public void String2()
        {
          var src = @"{""string""}";

          var lxr = new JL(new StringSource(src));

          var expected = new JSONTokenType[]{JSONTokenType.tBOF, JSONTokenType.tBraceOpen, JSONTokenType.tStringLiteral, JSONTokenType.tBraceClose, JSONTokenType.tEOF};
          Assert.IsTrue( lxr.Select(t => t.Type).SequenceEqual(expected) );
        }
Esempio n. 49
0
        public void String_Escapes6_ForwardSlash()
        {
          var src = @"{'male\/female'}";
                                               
          var lxr = new JL(new StringSource(src));

          Assert.AreEqual("male/female", lxr.ElementAt(2).Text);
        }
Esempio n. 50
0
        public void eUnterminatedString2()
        {
          var src = @"a: ""aaaa";

          var lxr = new JL(new StringSource(src));
          lxr.AnalyzeAll();
        }
Esempio n. 51
0
        public void PatternSearch()
        {
          var src = @"{a: 2, b: 'Znatoki', c: false, d: null, e: ['a','b','c']}";

          var lxr = new JL(new StringSource(src));

                    
          var bvalue = lxr.LazyFSM(
                 (s,t) => t.LoopUntilAny("b"),
                 (s,t) => t.IsAnyOrAbort(JSONTokenType.tColon),
                 (s,t) => FSMI.TakeAndComplete
             );
          
          Assert.AreEqual( "Znatoki", bvalue.Text );
        }
Esempio n. 52
0
        public void eUnterminatedString4_Verbatim()
        {
          var src = @"a: $'aa
          
          aa";

          var lxr = new JL(new StringSource(src));
          lxr.AnalyzeAll();
        }
Esempio n. 53
0
        public void PatternSearch5_Skip()
        {
          var src = @"{a: 'Budilnik', 'Name': 'Znatoki', q:2, z: 148, 'hero': 0x7f}";

          var lxr = new JL(new StringSource(src));

                    
          var capture = lxr.LazyFSM(
                 (s,t) => s.Skip(1),
                 (s,t) => FSMI.Take
             );
        
          Assert.IsNotNull( capture );
          Assert.AreEqual( JSONTokenType.tIdentifier, capture.Type );
          Assert.AreEqual( "a", capture.Text );

          capture = lxr.LazyFSM(
                 (s,t) => s.Skip(9),
                 (s,t) => FSMI.Take
             );
        
          Assert.IsNotNull( capture );
          Assert.AreEqual( JSONTokenType.tIdentifier, capture.Type );
          Assert.AreEqual( "q", capture.Text );
        }
Esempio n. 54
0
        public void String_Escapes1()
        {
          var src = @"{""str\""ing""}";
                                              
          var lxr = new JL(new StringSource(src));

          Assert.AreEqual(@"str""ing", lxr.ElementAt(2).Text);
        }
Esempio n. 55
0
        public void JSONPatternMatchAttribute3()
        {
          var src = @"{ code: 1121982, color: red, 'first_name': 'Alex', DOB: null}";

          var lxr = new JL(new StringSource(src));

          var match = JSONPatternMatchAttribute.Check(MethodBase.GetCurrentMethod(), lxr);          
         
        
          Assert.IsTrue( match );
        }
Esempio n. 56
0
        public void BasicTokens2()
        {
          var src = @"{a: 2, b: true, c: false, d: null, e: ['a','b','c']}";

          var lxr = new JL(new StringSource(src));

          var expected = new JSONTokenType[]
          { 
           JSONTokenType.tBOF, JSONTokenType.tBraceOpen,
           JSONTokenType.tIdentifier, JSONTokenType.tColon, JSONTokenType.tIntLiteral, JSONTokenType.tComma,
           JSONTokenType.tIdentifier, JSONTokenType.tColon, JSONTokenType.tTrue, JSONTokenType.tComma,
           JSONTokenType.tIdentifier, JSONTokenType.tColon, JSONTokenType.tFalse, JSONTokenType.tComma,
           JSONTokenType.tIdentifier, JSONTokenType.tColon, JSONTokenType.tNull, JSONTokenType.tComma,
           JSONTokenType.tIdentifier, JSONTokenType.tColon, JSONTokenType.tSqBracketOpen, JSONTokenType.tStringLiteral, JSONTokenType.tComma,
                                                                                          JSONTokenType.tStringLiteral, JSONTokenType.tComma,
                                                                                          JSONTokenType.tStringLiteral,
                                                            JSONTokenType.tSqBracketClose,
           JSONTokenType.tBraceClose, JSONTokenType.tEOF};

           //lxr.AnalyzeAll();
           //Console.Write(lxr.ToString());
          Assert.IsTrue( lxr.Select(t => t.Type).SequenceEqual(expected) );
        }
Esempio n. 57
0
        public void JSONPatternMatchAttribute1()
        {
          var src = @"1,2,3,4,5,6,7,8,9 : 'Name': 'Znatoki' null 'ok'";

          var lxr = new JL(new StringSource(src));

          var match = JSONPatternMatchAttribute.Check(MethodBase.GetCurrentMethod(), lxr);          
         
        
          Assert.IsFalse( match );
        }
Esempio n. 58
0
        public void Comments4()
        {
          var src = @"{
           //comment text
          }
          ";

          var lxr = new JL(new StringSource(src));

          Assert.AreEqual("comment text", lxr.ElementAt(2).Text);
        }
Esempio n. 59
0
        public void TokenClassifications()
        {
          var src = @"a 'string' : 12 //comment";

          var tokens = new JL(new StringSource(src)).Tokens;

          Assert.IsTrue( tokens[0].IsBOF);
          Assert.IsTrue( tokens[0].IsNonLanguage);
          Assert.IsFalse( tokens[0].IsPrimary);
          Assert.AreEqual(TokenKind.BOF, tokens[0].Kind);

          Assert.AreEqual( JSONTokenType.tIdentifier, tokens[1].Type);
          Assert.IsFalse( tokens[1].IsNonLanguage);
          Assert.IsTrue( tokens[1].IsPrimary);
          Assert.AreEqual(TokenKind.Identifier, tokens[1].Kind);

          Assert.AreEqual( JSONTokenType.tStringLiteral, tokens[2].Type);
          Assert.IsFalse( tokens[2].IsNonLanguage);
          Assert.IsTrue( tokens[2].IsPrimary);
          Assert.IsTrue( tokens[2].IsTextualLiteral);
          Assert.AreEqual(TokenKind.Literal, tokens[2].Kind);

          Assert.AreEqual( JSONTokenType.tColon, tokens[3].Type);
          Assert.IsFalse( tokens[3].IsNonLanguage);
          Assert.IsTrue( tokens[3].IsPrimary);
          Assert.IsTrue( tokens[3].IsOperator);
          Assert.AreEqual(TokenKind.Operator, tokens[3].Kind);


          Assert.AreEqual( JSONTokenType.tIntLiteral, tokens[4].Type);
          Assert.IsFalse( tokens[4].IsNonLanguage);
          Assert.IsTrue( tokens[4].IsPrimary);
          Assert.IsTrue( tokens[4].IsNumericLiteral);
          Assert.AreEqual(TokenKind.Literal, tokens[4].Kind);

          Assert.AreEqual( JSONTokenType.tComment, tokens[5].Type);
          Assert.IsFalse( tokens[5].IsNonLanguage);
          Assert.IsFalse( tokens[5].IsPrimary);
          Assert.IsTrue( tokens[5].IsComment);
          Assert.AreEqual(TokenKind.Comment, tokens[5].Kind);

        }
Esempio n. 60
0
        public void BasicTokensWithIdentifierAndDoubleLiteral()
        {
          var src = @"{a: 2.2}";

          var lxr = new JL(new StringSource(src));

          var expected = new JSONTokenType[]
          { 
           JSONTokenType.tBOF, JSONTokenType.tBraceOpen,
           JSONTokenType.tIdentifier, JSONTokenType.tColon, JSONTokenType.tDoubleLiteral,
           JSONTokenType.tBraceClose, JSONTokenType.tEOF};

          Assert.IsTrue( lxr.Select(t => t.Type).SequenceEqual(expected) );
        }