Add null literal
This commit is contained in:
@@ -87,6 +87,9 @@ func Eval(node ast.Node, env *object.Environment) object.Object {
|
||||
case *ast.Boolean:
|
||||
return nativeBoolToBooleanObject(node.Value)
|
||||
|
||||
case *ast.Null:
|
||||
return NULL
|
||||
|
||||
case *ast.PrefixExpression:
|
||||
right := Eval(node.Right, env)
|
||||
if isError(right) {
|
||||
|
||||
@@ -623,6 +623,11 @@ func testIntegerObject(t *testing.T, obj object.Object, expected int64) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func TestNullExpression(t *testing.T) {
|
||||
evaluated := testEval("null")
|
||||
testNullObject(t, evaluated)
|
||||
}
|
||||
|
||||
func testBooleanObject(t *testing.T, obj object.Object, expected bool) bool {
|
||||
result, ok := obj.(*object.Boolean)
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user