Skip to content

Commit

Permalink
more argument orders
Browse files Browse the repository at this point in the history
  • Loading branch information
dsainati1 committed Nov 7, 2023
1 parent 3dd41d5 commit 481826f
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 75 deletions.
4 changes: 2 additions & 2 deletions runtime/tests/checker/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func TestCheckDefaultEventDeclaration(t *testing.T) {
require.True(t, exists)

require.IsType(t, variable.Type, &sema.CompositeType{})
require.Equal(t, variable.Type.(*sema.CompositeType).DefaultDestroyEvent.Identifier, "ResourceDestroyed")
require.Equal(t, "ResourceDestroyed", variable.Type.(*sema.CompositeType).DefaultDestroyEvent.Identifier)
})

t.Run("allowed in resource interface", func(t *testing.T) {
Expand All @@ -519,7 +519,7 @@ func TestCheckDefaultEventDeclaration(t *testing.T) {
require.True(t, exists)

require.IsType(t, variable.Type, &sema.InterfaceType{})
require.Equal(t, variable.Type.(*sema.InterfaceType).DefaultDestroyEvent.Identifier, "ResourceDestroyed")
require.Equal(t, "ResourceDestroyed", variable.Type.(*sema.InterfaceType).DefaultDestroyEvent.Identifier)
})

t.Run("fail in struct", func(t *testing.T) {
Expand Down
32 changes: 16 additions & 16 deletions runtime/tests/interpreter/attachments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1276,8 +1276,8 @@ func TestInterpretAttachmentDestructor(t *testing.T) {
require.NoError(t, err)

require.Len(t, events, 2)
require.Equal(t, events[0].QualifiedIdentifier, "A.ResourceDestroyed")
require.Equal(t, events[1].QualifiedIdentifier, "R.ResourceDestroyed")
require.Equal(t, "A.ResourceDestroyed", events[0].QualifiedIdentifier)
require.Equal(t, "R.ResourceDestroyed", events[1].QualifiedIdentifier)
})

t.Run("base destructor executed last", func(t *testing.T) {
Expand Down Expand Up @@ -1327,10 +1327,10 @@ func TestInterpretAttachmentDestructor(t *testing.T) {

require.Len(t, events, 4)
// the only part of this order that is important is that `R` is last
require.Equal(t, events[0].QualifiedIdentifier, "B.ResourceDestroyed")
require.Equal(t, events[1].QualifiedIdentifier, "C.ResourceDestroyed")
require.Equal(t, events[2].QualifiedIdentifier, "A.ResourceDestroyed")
require.Equal(t, events[3].QualifiedIdentifier, "R.ResourceDestroyed")
require.Equal(t, "B.ResourceDestroyed", events[0].QualifiedIdentifier)
require.Equal(t, "C.ResourceDestroyed", events[1].QualifiedIdentifier)
require.Equal(t, "A.ResourceDestroyed", events[2].QualifiedIdentifier)
require.Equal(t, "R.ResourceDestroyed", events[3].QualifiedIdentifier)
})

t.Run("remove runs destroy", func(t *testing.T) {
Expand Down Expand Up @@ -1372,7 +1372,7 @@ func TestInterpretAttachmentDestructor(t *testing.T) {
require.NoError(t, err)

require.Len(t, events, 1)
require.Equal(t, events[0].QualifiedIdentifier, "A.ResourceDestroyed")
require.Equal(t, "A.ResourceDestroyed", events[0].QualifiedIdentifier)
})

t.Run("remove runs resource field destroy", func(t *testing.T) {
Expand Down Expand Up @@ -1421,8 +1421,8 @@ func TestInterpretAttachmentDestructor(t *testing.T) {
require.NoError(t, err)

require.Len(t, events, 2)
require.Equal(t, events[0].QualifiedIdentifier, "R2.ResourceDestroyed")
require.Equal(t, events[1].QualifiedIdentifier, "A.ResourceDestroyed")
require.Equal(t, "R2.ResourceDestroyed", events[0].QualifiedIdentifier)
require.Equal(t, "A.ResourceDestroyed", events[1].QualifiedIdentifier)
})

t.Run("nested attachments destroyed", func(t *testing.T) {
Expand Down Expand Up @@ -1474,9 +1474,9 @@ func TestInterpretAttachmentDestructor(t *testing.T) {
require.NoError(t, err)

require.Len(t, events, 3)
require.Equal(t, events[0].QualifiedIdentifier, "B.ResourceDestroyed")
require.Equal(t, events[1].QualifiedIdentifier, "R2.ResourceDestroyed")
require.Equal(t, events[2].QualifiedIdentifier, "A.ResourceDestroyed")
require.Equal(t, "B.ResourceDestroyed", events[0].QualifiedIdentifier)
require.Equal(t, "R2.ResourceDestroyed", events[1].QualifiedIdentifier)
require.Equal(t, "A.ResourceDestroyed", events[2].QualifiedIdentifier)
})

t.Run("attachment default args properly scoped", func(t *testing.T) {
Expand Down Expand Up @@ -1535,10 +1535,10 @@ func TestInterpretAttachmentDestructor(t *testing.T) {
require.NoError(t, err)

require.Len(t, events, 2)
require.Equal(t, events[0].QualifiedIdentifier, "A.ResourceDestroyed")
require.Equal(t, events[0].GetField(inter, interpreter.EmptyLocationRange, "foo"), interpreter.NewUnmeteredStringValue("foo"))
require.Equal(t, events[0].GetField(inter, interpreter.EmptyLocationRange, "bar"), interpreter.NewIntValueFromInt64(nil, 2))
require.Equal(t, events[1].QualifiedIdentifier, "R.ResourceDestroyed")
require.Equal(t, "A.ResourceDestroyed", events[0].QualifiedIdentifier)
require.Equal(t, interpreter.NewUnmeteredStringValue("foo"), events[0].GetField(inter, interpreter.EmptyLocationRange, "foo"))
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 2), events[0].GetField(inter, interpreter.EmptyLocationRange, "bar"))
require.Equal(t, "R.ResourceDestroyed", events[1].QualifiedIdentifier)
})
}

Expand Down
66 changes: 33 additions & 33 deletions runtime/tests/interpreter/interpreter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6613,10 +6613,10 @@ func TestInterpretResourceMoveInArrayAndDestroy(t *testing.T) {
)

require.Len(t, events, 2)
require.Equal(t, events[0].QualifiedIdentifier, "Foo.ResourceDestroyed")
require.Equal(t, events[0].GetField(inter, interpreter.EmptyLocationRange, "bar"), interpreter.NewIntValueFromInt64(nil, 1))
require.Equal(t, events[1].QualifiedIdentifier, "Foo.ResourceDestroyed")
require.Equal(t, events[1].GetField(inter, interpreter.EmptyLocationRange, "bar"), interpreter.NewIntValueFromInt64(nil, 2))
require.Equal(t, "Foo.ResourceDestroyed", events[0].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 1), events[0].GetField(inter, interpreter.EmptyLocationRange, "bar"))
require.Equal(t, "Foo.ResourceDestroyed", events[1].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 2), events[1].GetField(inter, interpreter.EmptyLocationRange, "bar"))
}

func TestInterpretResourceMoveInDictionaryAndDestroy(t *testing.T) {
Expand Down Expand Up @@ -6655,10 +6655,10 @@ func TestInterpretResourceMoveInDictionaryAndDestroy(t *testing.T) {
require.NoError(t, err)

require.Len(t, events, 2)
require.Equal(t, events[0].QualifiedIdentifier, "Foo.ResourceDestroyed")
require.Equal(t, events[0].GetField(inter, interpreter.EmptyLocationRange, "bar"), interpreter.NewIntValueFromInt64(nil, 1))
require.Equal(t, events[1].QualifiedIdentifier, "Foo.ResourceDestroyed")
require.Equal(t, events[1].GetField(inter, interpreter.EmptyLocationRange, "bar"), interpreter.NewIntValueFromInt64(nil, 2))
require.Equal(t, "Foo.ResourceDestroyed", events[0].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 1), events[0].GetField(inter, interpreter.EmptyLocationRange, "bar"))
require.Equal(t, "Foo.ResourceDestroyed", events[1].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 2), events[1].GetField(inter, interpreter.EmptyLocationRange, "bar"))
}

func TestInterpretClosure(t *testing.T) {
Expand Down Expand Up @@ -6918,7 +6918,7 @@ func TestInterpretResourceDestroyExpressionDestructor(t *testing.T) {
require.NoError(t, err)

require.Len(t, events, 1)
require.Equal(t, events[0].QualifiedIdentifier, "R.ResourceDestroyed")
require.Equal(t, "R.ResourceDestroyed", events[0].QualifiedIdentifier)
}

func TestInterpretResourceDestroyExpressionNestedResources(t *testing.T) {
Expand Down Expand Up @@ -6966,10 +6966,10 @@ func TestInterpretResourceDestroyExpressionNestedResources(t *testing.T) {
require.NoError(t, err)

require.Len(t, events, 2)
require.Equal(t, events[0].QualifiedIdentifier, "B.ResourceDestroyed")
require.Equal(t, events[0].GetField(inter, interpreter.EmptyLocationRange, "foo"), interpreter.NewIntValueFromInt64(nil, 5))
require.Equal(t, events[1].QualifiedIdentifier, "A.ResourceDestroyed")
require.Equal(t, events[1].GetField(inter, interpreter.EmptyLocationRange, "foo"), interpreter.NewIntValueFromInt64(nil, 5))
require.Equal(t, "B.ResourceDestroyed", events[0].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 5), events[0].GetField(inter, interpreter.EmptyLocationRange, "foo"))
require.Equal(t, "A.ResourceDestroyed", events[1].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 5), events[1].GetField(inter, interpreter.EmptyLocationRange, "foo"))
}

func TestInterpretResourceDestroyArray(t *testing.T) {
Expand Down Expand Up @@ -7001,8 +7001,8 @@ func TestInterpretResourceDestroyArray(t *testing.T) {
require.NoError(t, err)

require.Len(t, events, 2)
require.Equal(t, events[0].QualifiedIdentifier, "R.ResourceDestroyed")
require.Equal(t, events[1].QualifiedIdentifier, "R.ResourceDestroyed")
require.Equal(t, "R.ResourceDestroyed", events[0].QualifiedIdentifier)
require.Equal(t, "R.ResourceDestroyed", events[1].QualifiedIdentifier)
}

func TestInterpretResourceDestroyDictionary(t *testing.T) {
Expand Down Expand Up @@ -7034,8 +7034,8 @@ func TestInterpretResourceDestroyDictionary(t *testing.T) {
require.NoError(t, err)

require.Len(t, events, 2)
require.Equal(t, events[0].QualifiedIdentifier, "R.ResourceDestroyed")
require.Equal(t, events[1].QualifiedIdentifier, "R.ResourceDestroyed")
require.Equal(t, "R.ResourceDestroyed", events[0].QualifiedIdentifier)
require.Equal(t, "R.ResourceDestroyed", events[1].QualifiedIdentifier)
}

func TestInterpretResourceDestroyOptionalSome(t *testing.T) {
Expand Down Expand Up @@ -7067,7 +7067,7 @@ func TestInterpretResourceDestroyOptionalSome(t *testing.T) {
require.NoError(t, err)

require.Len(t, events, 1)
require.Equal(t, events[0].QualifiedIdentifier, "R.ResourceDestroyed")
require.Equal(t, "R.ResourceDestroyed", events[0].QualifiedIdentifier)
}

func TestInterpretResourceDestroyOptionalNil(t *testing.T) {
Expand Down Expand Up @@ -9583,15 +9583,15 @@ func TestInterpretNestedDestroy(t *testing.T) {
require.NoError(t, err)

require.Len(t, events, 4)
require.Equal(t, events[0].QualifiedIdentifier, "B.ResourceDestroyed")
require.Equal(t, events[0].GetField(inter, interpreter.EmptyLocationRange, "id"), interpreter.NewIntValueFromInt64(nil, 2))
require.Equal(t, events[1].QualifiedIdentifier, "B.ResourceDestroyed")
require.Equal(t, events[1].GetField(inter, interpreter.EmptyLocationRange, "id"), interpreter.NewIntValueFromInt64(nil, 3))
require.Equal(t, events[2].QualifiedIdentifier, "B.ResourceDestroyed")
require.Equal(t, events[2].GetField(inter, interpreter.EmptyLocationRange, "id"), interpreter.NewIntValueFromInt64(nil, 4))
require.Equal(t, events[3].QualifiedIdentifier, "A.ResourceDestroyed")
require.Equal(t, events[3].GetField(inter, interpreter.EmptyLocationRange, "id"), interpreter.NewIntValueFromInt64(nil, 1))
require.Equal(t, events[3].GetField(inter, interpreter.EmptyLocationRange, "bCount"), interpreter.NewIntValueFromInt64(nil, 3))
require.Equal(t, "B.ResourceDestroyed", events[0].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 2), events[0].GetField(inter, interpreter.EmptyLocationRange, "id"))
require.Equal(t, "B.ResourceDestroyed", events[1].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 3), events[1].GetField(inter, interpreter.EmptyLocationRange, "id"))
require.Equal(t, "B.ResourceDestroyed", events[2].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 4), events[2].GetField(inter, interpreter.EmptyLocationRange, "id"))
require.Equal(t, "A.ResourceDestroyed", events[3].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 1), events[3].GetField(inter, interpreter.EmptyLocationRange, "id"))
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 3), events[3].GetField(inter, interpreter.EmptyLocationRange, "bCount"))

AssertValuesEqual(
t,
Expand Down Expand Up @@ -11778,11 +11778,11 @@ func TestInterpretSwapDictionaryKeysWithSideEffects(t *testing.T) {

events := getEvents()
require.Len(t, events, 3)
require.Equal(t, events[0].event.QualifiedIdentifier, "Resource.ResourceDestroyed")
require.Equal(t, events[0].event.GetField(inter, interpreter.EmptyLocationRange, "value"), interpreter.NewIntValueFromInt64(nil, 2))
require.Equal(t, events[1].event.QualifiedIdentifier, "Resource.ResourceDestroyed")
require.Equal(t, events[1].event.GetField(inter, interpreter.EmptyLocationRange, "value"), interpreter.NewIntValueFromInt64(nil, 1))
require.Equal(t, events[2].event.QualifiedIdentifier, "Resource.ResourceDestroyed")
require.Equal(t, events[2].event.GetField(inter, interpreter.EmptyLocationRange, "value"), interpreter.NewIntValueFromInt64(nil, 3))
require.Equal(t, "Resource.ResourceDestroyed", events[0].event.QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 2), events[0].event.GetField(inter, interpreter.EmptyLocationRange, "value"))
require.Equal(t, "Resource.ResourceDestroyed", events[1].event.QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 1), events[1].event.GetField(inter, interpreter.EmptyLocationRange, "value"))
require.Equal(t, "Resource.ResourceDestroyed", events[2].event.QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 3), events[2].event.GetField(inter, interpreter.EmptyLocationRange, "value"))
})
}
48 changes: 24 additions & 24 deletions runtime/tests/interpreter/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2298,14 +2298,14 @@ func TestInterpretResourceInterfaceDefaultDestroyEvent(t *testing.T) {
require.NoError(t, err)

require.Len(t, events, 4)
require.Equal(t, events[0].QualifiedIdentifier, "I.ResourceDestroyed")
require.Equal(t, events[0].GetField(inter, interpreter.EmptyLocationRange, "id"), interpreter.NewIntValueFromInt64(nil, 1))
require.Equal(t, events[1].QualifiedIdentifier, "A.ResourceDestroyed")
require.Equal(t, events[1].GetField(inter, interpreter.EmptyLocationRange, "id"), interpreter.NewIntValueFromInt64(nil, 1))
require.Equal(t, events[2].QualifiedIdentifier, "I.ResourceDestroyed")
require.Equal(t, events[2].GetField(inter, interpreter.EmptyLocationRange, "id"), interpreter.NewIntValueFromInt64(nil, 2))
require.Equal(t, events[3].QualifiedIdentifier, "B.ResourceDestroyed")
require.Equal(t, events[3].GetField(inter, interpreter.EmptyLocationRange, "id"), interpreter.NewIntValueFromInt64(nil, 2))
require.Equal(t, "I.ResourceDestroyed", events[0].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 1), events[0].GetField(inter, interpreter.EmptyLocationRange, "id"))
require.Equal(t, "A.ResourceDestroyed", events[1].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 1), events[1].GetField(inter, interpreter.EmptyLocationRange, "id"))
require.Equal(t, "I.ResourceDestroyed", events[2].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 2), events[2].GetField(inter, interpreter.EmptyLocationRange, "id"))
require.Equal(t, "B.ResourceDestroyed", events[3].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 2), events[3].GetField(inter, interpreter.EmptyLocationRange, "id"))
}

func TestInterpretResourceInterfaceDefaultDestroyEventMultipleInheritance(t *testing.T) {
Expand Down Expand Up @@ -2353,12 +2353,12 @@ func TestInterpretResourceInterfaceDefaultDestroyEventMultipleInheritance(t *tes
require.NoError(t, err)

require.Len(t, events, 3)
require.Equal(t, events[0].QualifiedIdentifier, "I.ResourceDestroyed")
require.Equal(t, events[0].GetField(inter, interpreter.EmptyLocationRange, "id"), interpreter.NewIntValueFromInt64(nil, 1))
require.Equal(t, events[1].QualifiedIdentifier, "J.ResourceDestroyed")
require.Equal(t, events[1].GetField(inter, interpreter.EmptyLocationRange, "id"), interpreter.NewIntValueFromInt64(nil, 1))
require.Equal(t, events[2].QualifiedIdentifier, "A.ResourceDestroyed")
require.Equal(t, events[2].GetField(inter, interpreter.EmptyLocationRange, "id"), interpreter.NewIntValueFromInt64(nil, 1))
require.Equal(t, "I.ResourceDestroyed", events[0].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 1), events[0].GetField(inter, interpreter.EmptyLocationRange, "id"))
require.Equal(t, "J.ResourceDestroyed", events[1].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 1), events[1].GetField(inter, interpreter.EmptyLocationRange, "id"))
require.Equal(t, "A.ResourceDestroyed", events[2].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 1), events[2].GetField(inter, interpreter.EmptyLocationRange, "id"))
}

func TestInterpretResourceInterfaceDefaultDestroyEventIndirectInheritance(t *testing.T) {
Expand Down Expand Up @@ -2406,12 +2406,12 @@ func TestInterpretResourceInterfaceDefaultDestroyEventIndirectInheritance(t *tes
require.NoError(t, err)

require.Len(t, events, 3)
require.Equal(t, events[0].QualifiedIdentifier, "J.ResourceDestroyed")
require.Equal(t, events[0].GetField(inter, interpreter.EmptyLocationRange, "id"), interpreter.NewIntValueFromInt64(nil, 1))
require.Equal(t, events[1].QualifiedIdentifier, "I.ResourceDestroyed")
require.Equal(t, events[1].GetField(inter, interpreter.EmptyLocationRange, "id"), interpreter.NewIntValueFromInt64(nil, 1))
require.Equal(t, events[2].QualifiedIdentifier, "A.ResourceDestroyed")
require.Equal(t, events[2].GetField(inter, interpreter.EmptyLocationRange, "id"), interpreter.NewIntValueFromInt64(nil, 1))
require.Equal(t, "J.ResourceDestroyed", events[0].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 1), events[0].GetField(inter, interpreter.EmptyLocationRange, "id"))
require.Equal(t, "I.ResourceDestroyed", events[1].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 1), events[1].GetField(inter, interpreter.EmptyLocationRange, "id"))
require.Equal(t, "A.ResourceDestroyed", events[2].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 1), events[2].GetField(inter, interpreter.EmptyLocationRange, "id"))
}

func TestInterpretResourceInterfaceDefaultDestroyEventNoCompositeEvent(t *testing.T) {
Expand Down Expand Up @@ -2456,8 +2456,8 @@ func TestInterpretResourceInterfaceDefaultDestroyEventNoCompositeEvent(t *testin
require.NoError(t, err)

require.Len(t, events, 1)
require.Equal(t, events[0].QualifiedIdentifier, "I.ResourceDestroyed")
require.Equal(t, events[0].GetField(inter, interpreter.EmptyLocationRange, "id"), interpreter.NewIntValueFromInt64(nil, 1))
require.Equal(t, "I.ResourceDestroyed", events[0].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 1), events[0].GetField(inter, interpreter.EmptyLocationRange, "id"))
}

func TestInterpretDefaultDestroyEventArgumentScoping(t *testing.T) {
Expand Down Expand Up @@ -2498,6 +2498,6 @@ func TestInterpretDefaultDestroyEventArgumentScoping(t *testing.T) {
require.NoError(t, err)

require.Len(t, events, 1)
require.Equal(t, events[0].QualifiedIdentifier, "R.ResourceDestroyed")
require.Equal(t, events[0].GetField(inter, interpreter.EmptyLocationRange, "x"), interpreter.NewIntValueFromInt64(nil, 1))
require.Equal(t, "R.ResourceDestroyed", events[0].QualifiedIdentifier)
require.Equal(t, interpreter.NewIntValueFromInt64(nil, 1), events[0].GetField(inter, interpreter.EmptyLocationRange, "x"))
}

0 comments on commit 481826f

Please sign in to comment.