further improvements
This commit is contained in:
@@ -130,7 +130,7 @@ func testExpectedObject(t *testing.T, expected interface{}, actual object.Object
|
||||
}
|
||||
|
||||
case object.Null:
|
||||
if actual != Null {
|
||||
if actual != object.NULL {
|
||||
t.Errorf("object is not Null: %T (%+v)", actual, actual)
|
||||
}
|
||||
|
||||
@@ -302,14 +302,14 @@ func TestConditionals(t *testing.T) {
|
||||
{"if (1 < 2) { 10 }", 10},
|
||||
{"if (1 < 2) { 10 } else { 20 }", 10},
|
||||
{"if (1 > 2) { 10 } else { 20 }", 20},
|
||||
{"if (1 > 2) { 10 }", Null},
|
||||
{"if (false) { 10 }", Null},
|
||||
{"if (1 > 2) { 10 }", object.NULL},
|
||||
{"if (false) { 10 }", object.NULL},
|
||||
{"if ((if (false) { 10 })) { 10 } else { 20 }", 20},
|
||||
{"if (true) { a := 5; }", Null},
|
||||
{"if (true) { 10; a := 5; }", Null},
|
||||
{"if (false) { 10 } else { b := 5; }", Null},
|
||||
{"if (false) { 10 } else { 10; b := 5; }", Null},
|
||||
{"if (true) { a := 5; } else { 10 }", Null},
|
||||
{"if (true) { a := 5; }", object.NULL},
|
||||
{"if (true) { 10; a := 5; }", object.NULL},
|
||||
{"if (false) { 10 } else { b := 5; }", object.NULL},
|
||||
{"if (false) { 10 } else { 10; b := 5; }", object.NULL},
|
||||
{"if (true) { a := 5; } else { 10 }", object.NULL},
|
||||
{"x := 0; if (true) { x = 1; }; if (false) { x = 2; }; x", 1},
|
||||
{"if (1 < 2) { 10 } else if (1 == 2) { 20 }", 10},
|
||||
{"if (1 > 2) { 10 } else if (1 == 2) { 20 } else { 30 }", 30},
|
||||
@@ -430,13 +430,13 @@ func TestIndexExpressions(t *testing.T) {
|
||||
{"[1, 2, 3][1]", 2},
|
||||
{"[1, 2, 3][0 + 2]", 3},
|
||||
{"[[1, 1, 1]][0][0]", 1},
|
||||
{"[][0]", Null},
|
||||
{"[1, 2, 3][99]", Null},
|
||||
{"[1][-1]", Null},
|
||||
{"[][0]", object.NULL},
|
||||
{"[1, 2, 3][99]", object.NULL},
|
||||
{"[1][-1]", object.NULL},
|
||||
{"{1: 1, 2: 2}[1]", 1},
|
||||
{"{1: 1, 2: 2}[2]", 2},
|
||||
{"{1: 1}[0]", Null},
|
||||
{"{}[0]", Null},
|
||||
{"{1: 1}[0]", object.NULL},
|
||||
{"{}[0]", object.NULL},
|
||||
{`"abc"[0]`, "a"},
|
||||
{`"abc"[1]`, "b"},
|
||||
{`"abc"[2]`, "c"},
|
||||
@@ -506,7 +506,7 @@ func TestFunctionsWithoutReturnValue(t *testing.T) {
|
||||
noReturn := fn() { };
|
||||
noReturn();
|
||||
`,
|
||||
expected: Null,
|
||||
expected: object.NULL,
|
||||
},
|
||||
{
|
||||
input: `
|
||||
@@ -515,7 +515,7 @@ func TestFunctionsWithoutReturnValue(t *testing.T) {
|
||||
noReturn();
|
||||
noReturnTwo();
|
||||
`,
|
||||
expected: Null,
|
||||
expected: object.NULL,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -724,16 +724,16 @@ func TestBuiltinFunctions(t *testing.T) {
|
||||
},
|
||||
{`len([1, 2, 3])`, 3},
|
||||
{`len([])`, 0},
|
||||
{`print("hello", "world!")`, Null},
|
||||
{`print("hello", "world!")`, object.NULL},
|
||||
{`first([1, 2, 3])`, 1},
|
||||
{`first([])`, Null},
|
||||
{`first([])`, object.NULL},
|
||||
{`first(1)`,
|
||||
&object.Error{
|
||||
Message: "TypeError: first() expected argument #1 to be `array` got `int`",
|
||||
},
|
||||
},
|
||||
{`last([1, 2, 3])`, 3},
|
||||
{`last([])`, Null},
|
||||
{`last([])`, object.NULL},
|
||||
{`last(1)`,
|
||||
&object.Error{
|
||||
Message: "TypeError: last() expected argument #1 to be `array` got `int`",
|
||||
|
||||
Reference in New Issue
Block a user