summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Tews <git@tews.dev>2024-06-19 05:42:56 +0200
committerMichael Tews <michael@tews.dev>2026-04-12 11:11:02 +0200
commit0e3db367f467a2fd9b1ce0266699cce31c3c60eb (patch)
treea041b4dea9bb688099987481e0deb25001f83132
parent0ec476ead75c0d86b5c9ab0d048f26166ab6aef8 (diff)
test(lexer): updated TestNextToken with new tokens
-rw-r--r--lexer/lexer_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/lexer/lexer_test.go b/lexer/lexer_test.go
index 5706209..d89805d 100644
--- a/lexer/lexer_test.go
+++ b/lexer/lexer_test.go
@@ -18,6 +18,12 @@ func TestNextToken(t *testing.T) {
let result = add(five, ten);
!-/*5;
5 < 10 > 5;
+
+ if (5 < 10) {
+ return true;
+ } else {
+ return false;
+ }
`
tests := []struct {
@@ -72,6 +78,23 @@ func TestNextToken(t *testing.T) {
{token.GT, ">"},
{token.INT, "5"},
{token.SEMICOLON, ";"},
+ {token.IF, "if"},
+ {token.LPAREN, "("},
+ {token.INT, "5"},
+ {token.LT, "<"},
+ {token.INT, "10"},
+ {token.RPAREN, ")"},
+ {token.LBRACE, "{"},
+ {token.RETURN, "return"},
+ {token.TRUE, "true"},
+ {token.SEMICOLON, ";"},
+ {token.RBRACE, "}"},
+ {token.ELSE, "else"},
+ {token.LBRACE, "{"},
+ {token.RETURN, "return"},
+ {token.FALSE, "false"},
+ {token.SEMICOLON, ";"},
+ {token.RBRACE, "}"},
{token.EOF, ""},
}