Strings
This commit is contained in:
@@ -670,6 +670,25 @@ func TestCallExpressionParameterParsing(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestStringLiteralExpression(t *testing.T) {
|
||||
input := `"hello world";`
|
||||
|
||||
l := lexer.New(input)
|
||||
p := New(l)
|
||||
program := p.ParseProgram()
|
||||
checkParserErrors(t, p)
|
||||
|
||||
stmt := program.Statements[0].(*ast.ExpressionStatement)
|
||||
literal, ok := stmt.Expression.(*ast.StringLiteral)
|
||||
if !ok {
|
||||
t.Fatalf("exp not *ast.StringLiteral. got=%T", stmt.Expression)
|
||||
}
|
||||
|
||||
if literal.Value != "hello world" {
|
||||
t.Errorf("literal.Value not %q. got=%q", "hello world", literal.Value)
|
||||
}
|
||||
}
|
||||
|
||||
func testLetStatement(t *testing.T, s ast.Statement, name string) bool {
|
||||
if s.TokenLiteral() != "let" {
|
||||
t.Errorf("s.TokenLiteral not 'let'. got=%q", s.TokenLiteral())
|
||||
|
||||
Reference in New Issue
Block a user