Skip to content

Commit

Permalink
revert test to internal version, given 2414df1 was reverted
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Feb 7, 2024
1 parent 63b3df4 commit dbef6ed
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions runtime/tests/interpreter/dynamic_casting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3899,6 +3899,7 @@ func TestInterpretDynamicCastingReferenceCasting(t *testing.T) {
type testCase struct {
operation ast.Operation
returnsOptional bool
checkError func(t *testing.T, err error)
}

test := func(testCase testCase) {
Expand Down Expand Up @@ -3952,23 +3953,30 @@ func TestInterpretDynamicCastingReferenceCasting(t *testing.T) {
_, err := inter.Invoke("test")
RequireError(t, err)

// StorageReferenceValue.ReferencedValue turns the ForceCastTypeMismatchError
// of the failed dereference into a DereferenceError
var dereferenceError interpreter.DereferenceError
require.ErrorAs(t, err, &dereferenceError)

assert.Equal(t, 22, dereferenceError.LocationRange.StartPosition().Line)
testCase.checkError(t, err)
})
}

testCases := []testCase{
{
operation: ast.OperationForceCast,
returnsOptional: false,
checkError: func(t *testing.T, err error) {
// StorageReferenceValue.ReferencedValue turns the ForceCastTypeMismatchError
// of the failed dereference into a DereferenceError
var dereferenceError interpreter.DereferenceError
require.ErrorAs(t, err, &dereferenceError)

assert.Equal(t, 22, dereferenceError.LocationRange.StartPosition().Line)
},
},
{
operation: ast.OperationFailableCast,
returnsOptional: true,
checkError: func(t *testing.T, err error) {
var mismatchError interpreter.ForceCastTypeMismatchError
require.ErrorAs(t, err, &mismatchError)
},
},
}

Expand Down

0 comments on commit dbef6ed

Please sign in to comment.