Skip to content

Commit

Permalink
add unit tests for string with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
JunNishimura committed Oct 7, 2024
1 parent 9d73d5a commit 96c02a9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions evaluator/evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ func TestEvalStringExpression(t *testing.T) {
input: `"hello"`,
expected: "hello",
},
{
name: "string with space",
input: `"hello world"`,
expected: "hello world",
},
}

for _, tt := range tests {
Expand Down
10 changes: 10 additions & 0 deletions lexer/lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ func TestSingleProgram(t *testing.T) {
{Type: token.EOF, Literal: ""},
},
},
{
name: "string literal with space",
input: `"hello world"`,
expected: []token.Token{
{Type: token.DOUBLE_QUOTE, Literal: "\""},
{Type: token.STRING, Literal: "hello world"},
{Type: token.DOUBLE_QUOTE, Literal: "\""},
{Type: token.EOF, Literal: ""},
},
},
{
name: "array",
input: "[1, 2]",
Expand Down
5 changes: 5 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ func TestStringAtom(t *testing.T) {
input: `"hello"`,
expected: "hello",
},
{
name: "string with space",
input: `"hello world"`,
expected: "hello world",
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 96c02a9

Please sign in to comment.