aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <sokolyuk@gmail.com>2023-06-20 08:57:11 +0200
committerDimitri Sokolyuk <sokolyuk@gmail.com>2023-06-20 08:57:11 +0200
commit550aa0a288a00d820927a84b4f54a25f6c544643 (patch)
treea14763befcd3d535ce30657dfba8aaac1e6f5221
parentc4503a4b5307d82bba3f51852784d57f8f25b488 (diff)
any
-rw-r--r--evaluator/evaluator.go2
-rw-r--r--evaluator/evaluator_test.go8
-rw-r--r--go.mod2
-rw-r--r--parser/parser_test.go14
4 files changed, 13 insertions, 13 deletions
diff --git a/evaluator/evaluator.go b/evaluator/evaluator.go
index e7b7193..c9d13d7 100644
--- a/evaluator/evaluator.go
+++ b/evaluator/evaluator.go
@@ -300,7 +300,7 @@ func isTruthy(obj object.Object) bool {
}
}
-func newError(format string, a ...interface{}) *object.Error {
+func newError(format string, a ...any) *object.Error {
return &object.Error{Message: fmt.Sprintf(format, a...)}
}
diff --git a/evaluator/evaluator_test.go b/evaluator/evaluator_test.go
index fd1cef2..f7c235d 100644
--- a/evaluator/evaluator_test.go
+++ b/evaluator/evaluator_test.go
@@ -94,7 +94,7 @@ func TestBangOperator(t *testing.T) {
func TestIfElseExpressions(t *testing.T) {
tests := []struct {
input string
- expected interface{}
+ expected any
}{
{"if (true) { 10 }", 10},
{"if (false) { 10 }", nil},
@@ -361,7 +361,7 @@ func TestStringConcatenation(t *testing.T) {
func TestBuiltinFunctions(t *testing.T) {
tests := []struct {
input string
- expected interface{}
+ expected any
}{
{`len("")`, 0},
{`len("four")`, 4},
@@ -440,7 +440,7 @@ func TestArrayLiterals(t *testing.T) {
func TestArrayIndexExpressions(t *testing.T) {
tests := []struct {
input string
- expected interface{}
+ expected any
}{
{
"[1, 2, 3][0]",
@@ -538,7 +538,7 @@ func TestHashLiterals(t *testing.T) {
func TestHashIndexExpressions(t *testing.T) {
tests := []struct {
input string
- expected interface{}
+ expected any
}{
{
`{"foo": 5}["foo"]`,
diff --git a/go.mod b/go.mod
index 8197338..058a786 100644
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,3 @@
module monkey
-go 1.19
+go 1.20
diff --git a/parser/parser_test.go b/parser/parser_test.go
index a7f9775..7b91214 100644
--- a/parser/parser_test.go
+++ b/parser/parser_test.go
@@ -12,7 +12,7 @@ func TestLetStatements(t *testing.T) {
tests := []struct {
input string
expectedIdentifier string
- expectedValue interface{}
+ expectedValue any
}{
{"let x = 5;", "x", 5},
{"let y = true;", "y", true},
@@ -44,7 +44,7 @@ func TestLetStatements(t *testing.T) {
func TestReturnStatements(t *testing.T) {
tests := []struct {
input string
- expectedValue interface{}
+ expectedValue any
}{
{"return 5;", 5},
{"return true;", true},
@@ -135,7 +135,7 @@ func TestParsingPrefixExpressions(t *testing.T) {
prefixTests := []struct {
input string
operator string
- value interface{}
+ value any
}{
{"!5;", "!", 5},
{"-15;", "-", 15},
@@ -176,9 +176,9 @@ func TestParsingPrefixExpressions(t *testing.T) {
func TestParsingInfixExpressions(t *testing.T) {
infixTests := []struct {
input string
- leftValue interface{}
+ leftValue any
operator string
- rightValue interface{}
+ rightValue any
}{
{"5 + 5;", 5, "+", 5},
{"5 - 5;", 5, "-", 5},
@@ -934,7 +934,7 @@ func testLetStatement(t *testing.T, s ast.Statement, name string) bool {
return true
}
-func testInfixExpression(t *testing.T, exp ast.Expression, left interface{}, operator string, right interface{}) bool {
+func testInfixExpression(t *testing.T, exp ast.Expression, left any, operator string, right any) bool {
t.Helper()
opExp, ok := exp.(*ast.InfixExpression)
if !ok {
@@ -958,7 +958,7 @@ func testInfixExpression(t *testing.T, exp ast.Expression, left interface{}, ope
return true
}
-func testLiteralExpression(t *testing.T, exp ast.Expression, expected interface{}) bool {
+func testLiteralExpression(t *testing.T, exp ast.Expression, expected any) bool {
t.Helper()
switch v := expected.(type) {
case int: