further improvements
Some checks failed
Build / build (push) Successful in 10m40s
Publish Image / publish (push) Failing after 34s
Test / build (push) Has been cancelled

This commit is contained in:
2024-04-01 17:02:44 -04:00
parent aebbe43999
commit f9e6e164b0
26 changed files with 168 additions and 138 deletions

View File

@@ -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`",