Skip to content

Commit

Permalink
hand/lexer_test: Add quiet/lexer/l04.c test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
mewmew committed Feb 23, 2016
1 parent 6b0c3b0 commit fa6f77e
Showing 1 changed file with 215 additions and 1 deletion.
216 changes: 215 additions & 1 deletion uc/hand/lexer/lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1011,8 +1011,222 @@ func TestLexer(t *testing.T) {
},
},
},
{
path: "../../testdata/quiet/lexer/l04.c",
toks: []token.Token{
{
Kind: token.Ident,
Val: "int",
Pos: 0,
},
{
Kind: token.Ident,
Val: "main",
Pos: 4,
},
{
Kind: token.Lparen,
Val: "(",
Pos: 8,
},
{
Kind: token.Ident,
Val: "void",
Pos: 9,
},
{
Kind: token.Rparen,
Val: ")",
Pos: 13,
},
{
Kind: token.Lbrace,
Val: "{",
Pos: 15,
},
{
Kind: token.Ident,
Val: "int",
Pos: 19,
},
{
Kind: token.Ident,
Val: "i",
Pos: 23,
},
{
Kind: token.Semicolon,
Val: ";",
Pos: 24,
},
{
Kind: token.Ident,
Val: "char",
Pos: 28,
},
{
Kind: token.Ident,
Val: "j",
Pos: 33,
},
{
Kind: token.Semicolon,
Val: ";",
Pos: 34,
},
{
Kind: token.KwIf,
Val: "if",
Pos: 38,
},
{
Kind: token.Lparen,
Val: "(",
Pos: 41,
},
{
Kind: token.IntLit,
Val: "1",
Pos: 42,
},
{
Kind: token.Eq,
Val: "==",
Pos: 43,
},
{
Kind: token.IntLit,
Val: "0",
Pos: 45,
},
{
Kind: token.Rparen,
Val: ")",
Pos: 46,
},
{
Kind: token.Ident,
Val: "i",
Pos: 48,
},
{
Kind: token.Assign,
Val: "=",
Pos: 50,
},
{
Kind: token.IntLit,
Val: "0",
Pos: 52,
},
{
Kind: token.Semicolon,
Val: ";",
Pos: 53,
},
{
Kind: token.KwElse,
Val: "else",
Pos: 58,
},
{
Kind: token.Ident,
Val: "i",
Pos: 63,
},
{
Kind: token.Assign,
Val: "=",
Pos: 65,
},
{
Kind: token.IntLit,
Val: "1",
Pos: 67,
},
{
Kind: token.Semicolon,
Val: ";",
Pos: 68,
},
{
Kind: token.KwWhile,
Val: "while",
Pos: 72,
},
{
Kind: token.Lparen,
Val: "(",
Pos: 78,
},
{
Kind: token.IntLit,
Val: "1",
Pos: 79,
},
{
Kind: token.Eq,
Val: "==",
Pos: 80,
},
{
Kind: token.IntLit,
Val: "0",
Pos: 82,
},
{
Kind: token.Rparen,
Val: ")",
Pos: 83,
},
{
Kind: token.Ident,
Val: "i",
Pos: 85,
},
{
Kind: token.Assign,
Val: "=",
Pos: 87,
},
{
Kind: token.IntLit,
Val: "0",
Pos: 89,
},
{
Kind: token.Semicolon,
Val: ";",
Pos: 90,
},
{
Kind: token.KwReturn,
Val: "return",
Pos: 94,
},
{
Kind: token.IntLit,
Val: "42",
Pos: 101,
},
{
Kind: token.Semicolon,
Val: ";",
Pos: 103,
},
{
Kind: token.Rbrace,
Val: "}",
Pos: 105,
},
{
Kind: token.EOF,
Val: "",
Pos: 107,
},
},
},
// TODO: Add tokens for the following test cases.
//{path: "../../testdata/quiet/lexer/l04.c"},
//{path: "../../testdata/quiet/lexer/l05.c"},
//{path: "../../testdata/quiet/lexer/l06.c"},
}
Expand Down

0 comments on commit fa6f77e

Please sign in to comment.