Exemple #1
0
        public void TokenTest(Kind kind, string src, int start, int end)
        {
            var lexer = new Lexer(src);
            var token = lexer.Read(null);

            SigoAssert.Equal(kind, token.Kind);
            SigoAssert.Equal(start, token.Start);
            SigoAssert.Equal(end, token.End);

            switch (kind)
            {
            case Kind.Number:
                SigoAssert.Equal(double.Parse(src.Substring(start, end - start)), token.Value);
                break;

            case Kind.String:
                SigoAssert.Equal(src.Substring(start + 1, end - start - 2), token.Value);
                break;

            default:
                SigoAssert.Null(token.Value);
                break;
            }
        }