|
|
@@ -161,6 +161,10 @@ func TestErrorHandling(t *testing.T) {
|
|
|
`,
|
|
|
"unknown operator: BOOLEAN + BOOLEAN",
|
|
|
},
|
|
|
+ {
|
|
|
+ "foobar",
|
|
|
+ "identifier not found: foobar",
|
|
|
+ },
|
|
|
}
|
|
|
|
|
|
for _, tt := range tests {
|
|
|
@@ -176,6 +180,22 @@ func TestErrorHandling(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func TestLetStatement(t *testing.T) {
|
|
|
+ tests := []struct {
|
|
|
+ input string
|
|
|
+ expected int64
|
|
|
+ }{
|
|
|
+ {"let a = 5;a;", 5},
|
|
|
+ {"let a = 5 * 5;a;", 25},
|
|
|
+ {"let a = 5;let b = a;b;", 5},
|
|
|
+ {"let a = 5; let b = a;let c = a + b + 5;c;", 15},
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, tt := range tests {
|
|
|
+ testIntegerObject(t, testEval(tt.input), tt.expected)
|
|
|
+ }
|
|
|
+}
|
|
|
func testNullObject(t *testing.T, obj object.Object) bool {
|
|
|
if obj != NULL {
|
|
|
t.Errorf("object is not NULL. got=%T (%+v)", obj, obj)
|