optimizations
Some checks failed
Build / build (push) Successful in 10m47s
Publish Image / publish (push) Failing after 33s
Test / build (push) Failing after 6m42s

This commit is contained in:
Chuck Smith
2024-04-02 14:54:08 -04:00
parent 88e3330856
commit f08b458325
9 changed files with 313 additions and 355 deletions

View File

@@ -85,6 +85,18 @@ func TestEvalExpressions(t *testing.T) {
{"1 << 2", 4},
{"4 >> 2", 1},
{"5.0 / 2.0", 2.5},
{"1 + 2.1", 3.1},
{"2 - 0.5", 1.5},
{"2 * 2.5", 5.0},
{"5 / 2.0", 2.5},
{"5 % 2.0", 1.0},
{"2.1 + 1", 3.1},
{"2.5 - 2", 0.5},
{"2.5 * 2", 5.0},
{"5.0 / 2", 2.5},
{"5.0 % 2", 1.0},
}
for _, tt := range tests {
@@ -231,27 +243,27 @@ func TestErrorHandling(t *testing.T) {
}{
{
"5 + true;",
"unknown operator: int + bool",
"unsupported operator: int + bool",
},
{
"5 + true; 5;",
"unknown operator: int + bool",
"unsupported operator: int + bool",
},
{
"-true",
"unknown operator: -bool",
"unsupported operator: -bool",
},
{
"true + false;",
"unknown operator: bool + bool",
"unsupported operator: bool + bool",
},
{
"5; true + false; 5",
"unknown operator: bool + bool",
"unsupported operator: bool + bool",
},
{
"if (10 > 1) { true + false; }",
"unknown operator: bool + bool",
"unsupported operator: bool + bool",
},
{
`
@@ -263,7 +275,7 @@ func TestErrorHandling(t *testing.T) {
return 1;
}
`,
"unknown operator: bool + bool",
"unsupported operator: bool + bool",
},
{
"foobar",
@@ -271,7 +283,7 @@ func TestErrorHandling(t *testing.T) {
},
{
`"Hello" - "World"`,
"unknown operator: str - str",
"unsupported operator: str - str",
},
{
`{"name": "Monkey"}[fn(x) { x }];`,
@@ -676,8 +688,8 @@ func TestHashLiterals(t *testing.T) {
(object.String{Value: "two"}).Hash(): 2,
(object.String{Value: "three"}).Hash(): 3,
(object.Integer{Value: 4}).Hash(): 4,
TRUE.Hash(): 5,
FALSE.Hash(): 6,
object.TRUE.Hash(): 5,
object.FALSE.Hash(): 6,
}
if len(result.Pairs) != len(expected) {
@@ -882,7 +894,7 @@ func testBooleanObject(t *testing.T, obj object.Object, expected bool) bool {
}
func testNullObject(t *testing.T, obj object.Object) bool {
if obj != NULL {
if obj != object.NULL {
t.Errorf("object is not NULL. got=%T (%+v)", obj, obj)
return false
}