|
|
|
@ -503,9 +503,16 @@ func TestIfElseExpression(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestFunctionLiteralParsing(t *testing.T) {
|
|
|
|
func TestFunctionLiteralParsing(t *testing.T) {
|
|
|
|
input := `fn(x, y) { x + y; }`
|
|
|
|
tests := []struct {
|
|
|
|
|
|
|
|
input string
|
|
|
|
|
|
|
|
}{
|
|
|
|
|
|
|
|
{"fn(x, y) { x + y; }"},
|
|
|
|
|
|
|
|
{"fn(x, y) -> x + y;"},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
l := lexer.New(input)
|
|
|
|
for _, tt := range tests {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
l := lexer.New(tt.input)
|
|
|
|
p := New(l)
|
|
|
|
p := New(l)
|
|
|
|
program := p.ParseProgram()
|
|
|
|
program := p.ParseProgram()
|
|
|
|
checkParserErrors(t, p)
|
|
|
|
checkParserErrors(t, p)
|
|
|
|
@ -548,6 +555,7 @@ func TestFunctionLiteralParsing(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
testInfixExpression(t, bodyStmt.Expression, "x", "+", "y")
|
|
|
|
testInfixExpression(t, bodyStmt.Expression, "x", "+", "y")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestFunctionParameterParsing(t *testing.T) {
|
|
|
|
func TestFunctionParameterParsing(t *testing.T) {
|
|
|
|
tests := []struct {
|
|
|
|
tests := []struct {
|
|
|
|
|