From 782db6c79268b469c215b130ea0fb6943918d840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Mon, 28 Oct 2024 17:41:23 -0700 Subject: [PATCH] refactor test utils --- cmd/info/main.go | 2 +- compiler/compiler_test.go | 2 +- encoding/ccf/ccf_test.go | 138 ++--- encoding/ccf/ccf_type_id_test.go | 6 +- encoding/json/encoding_test.go | 45 +- fuzz.go | 4 +- {tests/fuzz => fuzz}/crashers_test.go | 2 +- interpreter/account_test.go | 3 +- interpreter/arithmetic_test.go | 2 +- interpreter/attachments_test.go | 2 +- interpreter/bitwise_test.go | 2 +- interpreter/builtinfunctions_test.go | 3 +- interpreter/character_test.go | 2 +- interpreter/composite_value_test.go | 3 +- interpreter/condition_test.go | 5 +- interpreter/container_mutation_test.go | 5 +- interpreter/contract_test.go | 2 +- interpreter/conversion_test.go | 2 +- interpreter/deepcopyremove_test.go | 4 +- interpreter/dynamic_casting_test.go | 3 +- interpreter/encoding_test.go | 21 +- interpreter/entitlements_test.go | 2 +- interpreter/enum_test.go | 3 +- interpreter/equality_test.go | 3 +- interpreter/errors_test.go | 6 +- interpreter/fixedpoint_test.go | 3 +- interpreter/for_test.go | 3 +- interpreter/function_test.go | 12 +- interpreter/if_test.go | 5 +- interpreter/import_test.go | 5 +- interpreter/inspect_test.go | 2 +- interpreter/integers_test.go | 4 +- interpreter/interface_test.go | 14 +- interpreter/interpreter_tracing_test.go | 4 +- interpreter/invocation_test.go | 2 +- interpreter/member_test.go | 4 +- interpreter/memory_metering_test.go | 10 +- interpreter/metatype_test.go | 3 +- interpreter/metering_test.go | 20 +- interpreter/misc_test.go | 7 +- interpreter/path_test.go | 2 +- interpreter/range_value_test.go | 8 +- interpreter/reference_test.go | 5 +- interpreter/resources_test.go | 8 +- interpreter/runtimetype_test.go | 30 +- interpreter/statictype_test.go | 74 +-- interpreter/storage_test.go | 3 +- interpreter/string_test.go | 3 +- interpreter/switch_test.go | 5 +- interpreter/transactions_test.go | 5 +- interpreter/transfer_test.go | 2 +- interpreter/uuid_test.go | 5 +- interpreter/value_function_test.go | 7 +- interpreter/value_test.go | 68 +-- interpreter/value_uint64.go | 3 +- interpreter/values_test.go | 65 +-- interpreter/while_test.go | 3 +- old_parser/declaration_test.go | 340 ++++++------ old_parser/expression_test.go | 376 +++++++------- old_parser/lexer/lexer_test.go | 4 +- old_parser/parser_test.go | 26 +- old_parser/statement_test.go | 96 ++-- old_parser/type_test.go | 146 +++--- parser/declaration_test.go | 484 +++++++++--------- parser/expression_test.go | 400 +++++++-------- parser/lexer/lexer_test.go | 4 +- parser/parser_test.go | 26 +- parser/statement_test.go | 112 ++-- parser/type_test.go | 154 +++--- runtime/account_test.go | 12 +- runtime/attachments_test.go | 3 +- runtime/capabilities_test.go | 4 +- runtime/capabilitycontrollers_test.go | 4 +- runtime/contract_test.go | 7 +- runtime/contract_update_test.go | 4 +- runtime/contract_update_validation_test.go | 4 +- runtime/convertTypes_test.go | 10 +- runtime/convertValues_test.go | 5 +- runtime/coverage_test.go | 5 +- runtime/crypto_test.go | 2 +- runtime/debugger_test.go | 2 +- runtime/deployedcontract_test.go | 5 +- runtime/deployment_test.go | 5 +- runtime/entitlements_test.go | 5 +- runtime/error_test.go | 2 +- runtime/ft_test.go | 15 +- runtime/import_test.go | 6 +- .../imported_values_memory_metering_test.go | 6 +- runtime/inbox_test.go | 2 +- runtime/literal_test.go | 4 +- runtime/predeclaredvalues_test.go | 6 +- runtime/program_params_validation_test.go | 6 +- runtime/resource_duplicate_test.go | 4 +- runtime/resourcedictionary_test.go | 17 +- runtime/rlp_test.go | 4 +- runtime/runtime_memory_metering_test.go | 4 +- runtime/runtime_test.go | 6 +- runtime/sharedstate_test.go | 3 +- runtime/storage_test.go | 5 +- runtime/type_test.go | 2 +- runtime/validation_test.go | 4 +- sema/accesses_test.go | 2 +- sema/account_test.go | 6 +- sema/any_test.go | 2 +- sema/arrays_dictionaries_test.go | 2 +- sema/assert_test.go | 2 +- sema/assignment_test.go | 2 +- sema/attachments_test.go | 2 +- sema/boolean_test.go | 2 +- sema/builtinfunctions_test.go | 2 +- sema/capability_controller_test.go | 2 +- sema/capability_test.go | 11 +- sema/casting_test.go | 2 +- sema/character_test.go | 2 +- sema/composite_test.go | 2 +- sema/conditional_test.go | 2 +- sema/conditions_test.go | 2 +- sema/conformance_test.go | 2 +- sema/contract_test.go | 2 +- sema/crypto_test.go | 2 +- sema/declaration_test.go | 2 +- sema/dictionary_test.go | 2 +- sema/dynamic_casting_test.go | 6 +- sema/entitlements_test.go | 2 +- sema/entrypoint_test.go | 2 +- sema/enum_test.go | 2 +- sema/error_handling_test.go | 6 +- sema/events_test.go | 6 +- sema/external_mutation_test.go | 2 +- sema/fixedpoint_test.go | 2 +- sema/for_test.go | 2 +- sema/force_test.go | 2 +- sema/function_expression_test.go | 2 +- sema/function_test.go | 2 +- sema/gen/golden_test.go | 2 +- sema/genericfunction_test.go | 2 +- sema/hashable_struct_test.go | 2 +- sema/if_test.go | 2 +- sema/import_test.go | 22 +- sema/indexing_test.go | 2 +- sema/initialization_test.go | 2 +- sema/integer_test.go | 2 +- sema/interface_test.go | 2 +- sema/intersection_test.go | 2 +- sema/invalid_test.go | 2 +- sema/invocation_test.go | 12 +- sema/member_test.go | 2 +- sema/metatype_test.go | 2 +- sema/move_test.go | 2 +- sema/nesting_test.go | 2 +- sema/never_test.go | 2 +- sema/nil_coalescing_test.go | 2 +- sema/occurrences_test.go | 2 +- sema/operations_test.go | 2 +- sema/optional_test.go | 2 +- sema/overloading_test.go | 2 +- sema/path_test.go | 2 +- sema/pragma_test.go | 2 +- sema/predeclaredvalues_test.go | 2 +- sema/purity_test.go | 2 +- sema/range_test.go | 6 +- sema/range_value_test.go | 2 +- sema/reference_test.go | 10 +- sema/resource_test.go | 5 +- sema/return_test.go | 2 +- sema/rlp_test.go | 2 +- sema/runtimetype_test.go | 2 +- sema/storable_test.go | 2 +- sema/string_test.go | 2 +- sema/swap_test.go | 2 +- sema/switch_test.go | 2 +- sema/transactions_test.go | 2 +- sema/type_inference_test.go | 2 +- sema/typeargument_test.go | 2 +- sema/utils_test.go | 2 +- sema/while_test.go | 2 +- stdlib/account_test.go | 4 +- stdlib/builtin_test.go | 17 +- ..._to_v1_contract_upgrade_validation_test.go | 40 +- stdlib/rlp/rlp_test.go | 2 +- stdlib/test_test.go | 6 +- test_utils/common_utils/utils.go | 112 ++++ .../interpreter_utils}/interpreter.go | 6 +- .../interpreter_utils/values.go | 155 +----- .../runtime_utils/location.go | 0 .../runtime_utils/testinterface.go | 0 .../runtime_utils/testledger.go | 0 .../runtime_utils/testruntime.go | 0 test_utils/runtime_utils/transactions.go | 68 +++ {tests => test_utils}/sema_utils/utils.go | 9 +- tools/analysis/analysis_test.go | 2 +- .../compatibility-check/contracts_checker.go | 3 +- types_test.go | 24 +- values_test.go | 16 +- 194 files changed, 1874 insertions(+), 1817 deletions(-) rename {tests/fuzz => fuzz}/crashers_test.go (96%) create mode 100644 test_utils/common_utils/utils.go rename {tests/runtime_utils => test_utils/interpreter_utils}/interpreter.go (92%) rename tests/utils/utils.go => test_utils/interpreter_utils/values.go (56%) rename {tests => test_utils}/runtime_utils/location.go (100%) rename {tests => test_utils}/runtime_utils/testinterface.go (100%) rename {tests => test_utils}/runtime_utils/testledger.go (100%) rename {tests => test_utils}/runtime_utils/testruntime.go (100%) create mode 100644 test_utils/runtime_utils/transactions.go rename {tests => test_utils}/sema_utils/utils.go (97%) diff --git a/cmd/info/main.go b/cmd/info/main.go index 62a91f8a6c..7ca71664cc 100644 --- a/cmd/info/main.go +++ b/cmd/info/main.go @@ -31,7 +31,7 @@ import ( "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/sema_utils" + "github.com/onflow/cadence/test_utils/sema_utils" ) type command struct { diff --git a/compiler/compiler_test.go b/compiler/compiler_test.go index 60c96154aa..b9a0e2d866 100644 --- a/compiler/compiler_test.go +++ b/compiler/compiler_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/compiler/ir" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCompilerSimple(t *testing.T) { diff --git a/encoding/ccf/ccf_test.go b/encoding/ccf/ccf_test.go index 3332bbb065..c4513037ae 100644 --- a/encoding/ccf/ccf_test.go +++ b/encoding/ccf/ccf_test.go @@ -38,9 +38,9 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) var deterministicEncMode, _ = ccf.EncOptions{ @@ -100,7 +100,7 @@ func TestEncodeOptional(t *testing.T) { newStructType := func() *cadence.StructType { return cadence.NewStructType( - utils.TestLocation, + TestLocation, "Foo", []cadence.Field{ { @@ -122,7 +122,7 @@ func TestEncodeOptional(t *testing.T) { newStructTypeWithOptionalAbstractField := func() *cadence.StructType { return cadence.NewStructType( - utils.TestLocation, + TestLocation, "Foo", []cadence.Field{ { @@ -807,7 +807,7 @@ func TestEncodeOptional(t *testing.T) { val: func() cadence.Value { structTypeWithOptionalAbstractField := newStructTypeWithOptionalAbstractField() simpleStructType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -3576,7 +3576,7 @@ func TestEncodeArray(t *testing.T) { name: "Resource Interface Array", val: func() cadence.Value { resourceInterfaceType := cadence.NewResourceInterfaceType( - utils.TestLocation, + TestLocation, "Bar", nil, nil, @@ -3930,13 +3930,13 @@ func TestEncodeArray(t *testing.T) { name: "Struct Interface Array", val: func() cadence.Value { structInterfaceType := cadence.NewStructInterfaceType( - utils.TestLocation, + TestLocation, "FooStructInterface", nil, nil, ) structType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -4075,13 +4075,13 @@ func TestEncodeArray(t *testing.T) { name: "Contract Interface Array", val: func() cadence.Value { contractInterfaceType := cadence.NewContractInterfaceType( - utils.TestLocation, + TestLocation, "FooContractInterface", nil, nil, ) contractType := cadence.NewContractType( - utils.TestLocation, + TestLocation, "FooContract", []cadence.Field{ { @@ -5414,7 +5414,7 @@ func TestEncodeStruct(t *testing.T) { name: "no field", val: func() cadence.Value { noFieldStructType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{}, nil, @@ -5473,7 +5473,7 @@ func TestEncodeStruct(t *testing.T) { name: "Simple", val: func() cadence.Value { simpleStructType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -5824,7 +5824,7 @@ func TestEncodeEvent(t *testing.T) { name: "Simple", val: func() cadence.Value { simpleEventType := cadence.NewEventType( - utils.TestLocation, + TestLocation, "FooEvent", []cadence.Field{ { @@ -5928,7 +5928,7 @@ func TestEncodeEvent(t *testing.T) { name: "abstract event", val: func() cadence.Value { abstractEventType := cadence.NewEventType( - utils.TestLocation, + TestLocation, "FooEvent", []cadence.Field{ { @@ -5943,7 +5943,7 @@ func TestEncodeEvent(t *testing.T) { nil, ) simpleStructType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -6090,7 +6090,7 @@ func TestEncodeEvent(t *testing.T) { val: func() cadence.Value { fooResourceType := newFooResourceType() resourceEventType := cadence.NewEventType( - utils.TestLocation, + TestLocation, "FooEvent", []cadence.Field{ { @@ -6238,7 +6238,7 @@ func TestEncodeEvent(t *testing.T) { t.Run(tc.name, func(t *testing.T) { actualCBOR, err := ccf.EventsEncMode.Encode(tc.val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, tc.expected, actualCBOR) + AssertEqualWithDiff(t, tc.expected, actualCBOR) decodedVal, err := ccf.EventsDecMode.Decode(nil, actualCBOR) require.NoError(t, err) @@ -6259,7 +6259,7 @@ func TestEncodeContract(t *testing.T) { name: "Simple", val: func() cadence.Value { simpleContractType := cadence.NewContractType( - utils.TestLocation, + TestLocation, "FooContract", []cadence.Field{ { @@ -6363,7 +6363,7 @@ func TestEncodeContract(t *testing.T) { name: "abstract contract", val: func() cadence.Value { simpleStructType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -6374,7 +6374,7 @@ func TestEncodeContract(t *testing.T) { nil, ) abstractContractType := cadence.NewContractType( - utils.TestLocation, + TestLocation, "FooContract", []cadence.Field{ { @@ -6525,7 +6525,7 @@ func TestEncodeContract(t *testing.T) { val: func() cadence.Value { fooResourceType := newFooResourceType() resourceContractType := cadence.NewContractType( - utils.TestLocation, + TestLocation, "FooContract", []cadence.Field{ { @@ -6677,7 +6677,7 @@ func TestEncodeEnum(t *testing.T) { name: "Simple", val: func() cadence.Value { simpleEnumType := cadence.NewEnumType( - utils.TestLocation, + TestLocation, "FooEnum", nil, []cadence.Field{ @@ -6764,7 +6764,7 @@ func TestEncodeAttachment(t *testing.T) { name: "no field", val: func() cadence.Value { attachmentType := cadence.NewAttachmentType( - utils.TestLocation, + TestLocation, "FooAttachment", nil, []cadence.Field{}, @@ -6825,7 +6825,7 @@ func TestEncodeAttachment(t *testing.T) { name: "simple", val: func() cadence.Value { attachmentType := cadence.NewAttachmentType( - utils.TestLocation, + TestLocation, "FooAttachment", nil, []cadence.Field{ @@ -6906,7 +6906,7 @@ func TestEncodeAttachment(t *testing.T) { name: "struct field", val: func() cadence.Value { structType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -6917,7 +6917,7 @@ func TestEncodeAttachment(t *testing.T) { nil, ) attachmentType := cadence.NewAttachmentType( - utils.TestLocation, + TestLocation, "FooAttachment", nil, []cadence.Field{ @@ -7508,7 +7508,7 @@ func TestEncodeValueOfReferenceType(t *testing.T) { newSimpleStructType := func() *cadence.StructType { return cadence.NewStructType( - utils.TestLocation, + TestLocation, "Foo", []cadence.Field{ { @@ -8840,7 +8840,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewStructType( - utils.TestLocation, + TestLocation, "S", []cadence.Field{}, [][]cadence.Parameter{}, @@ -8889,7 +8889,7 @@ func TestEncodeType(t *testing.T) { val := cadence.TypeValue{ StaticType: cadence.NewStructType( - utils.TestLocation, + TestLocation, "S", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -8993,7 +8993,7 @@ func TestEncodeType(t *testing.T) { // Encode value without sorting of composite fields. actualCBOR, err := ccf.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) // Decode value without enforcing sorting of composite fields. decodedVal, err := ccf.Decode(nil, actualCBOR) @@ -9012,7 +9012,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewStructType( - utils.TestLocation, + TestLocation, "S", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -9113,7 +9113,7 @@ func TestEncodeType(t *testing.T) { }, cadence.TypeValue{ StaticType: cadence.NewStructType( - utils.TestLocation, + TestLocation, "S", []cadence.Field{ {Identifier: "bar", Type: cadence.IntType}, @@ -9134,21 +9134,21 @@ func TestEncodeType(t *testing.T) { t.Parallel() fooTy := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", []cadence.Field{}, [][]cadence.Parameter{}, ) fooTy2 := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo2", []cadence.Field{}, [][]cadence.Parameter{}, ) barTy := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Bar", []cadence.Field{ { @@ -9274,7 +9274,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewResourceType( - utils.TestLocation, + TestLocation, "R", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -9372,7 +9372,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewContractType( - utils.TestLocation, + TestLocation, "C", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -9470,7 +9470,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewStructInterfaceType( - utils.TestLocation, + TestLocation, "S", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -9568,7 +9568,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewResourceInterfaceType( - utils.TestLocation, + TestLocation, "R", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -9666,7 +9666,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewContractInterfaceType( - utils.TestLocation, + TestLocation, "C", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -9764,7 +9764,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewEventType( - utils.TestLocation, + TestLocation, "E", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -9860,7 +9860,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewEnumType( - utils.TestLocation, + TestLocation, "E", cadence.StringType, []cadence.Field{ @@ -9961,7 +9961,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewAttachmentType( - utils.TestLocation, + TestLocation, "A", cadence.StringType, []cadence.Field{ @@ -10059,7 +10059,7 @@ func TestEncodeType(t *testing.T) { t.Parallel() baseType := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "FooBase", []cadence.Field{ {Identifier: "bar", Type: cadence.StringType}, @@ -10071,7 +10071,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewAttachmentType( - utils.TestLocation, + TestLocation, "A", baseType, []cadence.Field{ @@ -11050,7 +11050,7 @@ func TestEncodeCapability(t *testing.T) { t.Parallel() simpleStructType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -11722,7 +11722,7 @@ func TestExportRecursiveType(t *testing.T) { }, } ty := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", fields, nil, @@ -11815,7 +11815,7 @@ func TestExportTypeValueRecursiveType(t *testing.T) { }, } ty := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", fields, [][]cadence.Parameter{}, @@ -12061,21 +12061,21 @@ func TestExportTypeValueRecursiveType(t *testing.T) { t.Parallel() fooTy := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", []cadence.Field{}, [][]cadence.Parameter{}, ) fooTy2 := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo2", []cadence.Field{}, [][]cadence.Parameter{}, ) barTy := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Bar", []cadence.Field{ { @@ -12729,7 +12729,7 @@ func testEncode(t *testing.T, val cadence.Value, expectedCBOR []byte) (actualCBO actualCBOR, err := deterministicEncMode.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) return actualCBOR } @@ -12748,7 +12748,7 @@ func testDecode(t *testing.T, actualCBOR []byte, expectedVal cadence.Value) { // TODO: make resource (illegal nesting) func newResourceStructType() *cadence.StructType { return cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -12766,7 +12766,7 @@ func newResourceStructType() *cadence.StructType { func newFooResourceType() *cadence.ResourceType { return cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", []cadence.Field{ { @@ -12780,7 +12780,7 @@ func newFooResourceType() *cadence.ResourceType { func newFoooResourceTypeWithAbstractField() *cadence.ResourceType { return cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Fooo", []cadence.Field{ { @@ -13187,7 +13187,7 @@ func TestExportFunctionValue(t *testing.T) { }, } ty := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", fields, nil, @@ -14038,7 +14038,7 @@ func TestDeployedEvents(t *testing.T) { // Encode Cadence value to CCF actualCBOR, err := ccf.EventsEncMode.Encode(tc.event) require.NoError(t, err) - utils.AssertEqualWithDiff(t, tc.expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, tc.expectedCBOR, actualCBOR) // Decode CCF to Cadence value decodedEvent, err := ccf.EventsDecMode.Decode(nil, actualCBOR) @@ -15912,7 +15912,7 @@ func TestSortEntitlementSet(t *testing.T) { // Encode value without sorting. actualCBOR, err := ccf.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) // Decode value without enforcing sorting. decodedVal, err := ccf.Decode(nil, actualCBOR) @@ -16010,7 +16010,7 @@ func TestSortEntitlementSet(t *testing.T) { // Encode value with sorted entitlement types. actualCBOR, err := sortEntitlementTypesEncMode.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) // Decode value enforcing sorting of composite fields. decodedVal, err := enforceSortedEntitlementTypesDecMode.Decode(nil, actualCBOR) @@ -16079,7 +16079,7 @@ func TestSortEntitlementSet(t *testing.T) { // Encode value without sorting. actualCBOR, err := ccf.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) // Decode value without enforcing sorting. decodedVal, err := ccf.Decode(nil, actualCBOR) @@ -16156,7 +16156,7 @@ func TestSortEntitlementSet(t *testing.T) { // Encode value with sorting. actualCBOR, err := sortEntitlementTypesEncMode.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) // Decode value without enforcing sorting. decodedVal, err := ccf.Decode(nil, actualCBOR) @@ -16404,7 +16404,7 @@ func TestSortOptions(t *testing.T) { // Encode value without sorting. actualCBOR, err := ccf.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) // Decode value without enforcing sorting. decodedVal, err := ccf.Decode(nil, actualCBOR) @@ -16593,7 +16593,7 @@ func TestSortOptions(t *testing.T) { // Encode value with sorted composite fields. actualCBOR, err := sortFieldsEncMode.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) // Decode value enforcing sorting of composite fields. decodedVal, err := enforceSortedFieldsDecMode.Decode(nil, actualCBOR) @@ -16782,7 +16782,7 @@ func TestSortOptions(t *testing.T) { // Encode value with sorted Intersection types. actualCBOR, err := sortIntersectionTypesEncMode.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) // Decode value enforcing sorting of Intersection types. decodedVal, err := enforceSortedIntersectionTypesDecMode.Decode(nil, actualCBOR) @@ -16971,7 +16971,7 @@ func TestSortOptions(t *testing.T) { // Encode value with sorted composite fields and Intersection types. actualCBOR, err := deterministicEncMode.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) // Decode value enforcing sorting of composite fields and Intersection types. decodedVal, err := deterministicDecMode.Decode(nil, actualCBOR) @@ -17111,7 +17111,7 @@ func TestDecodeFunctionTypeBackwardCompatibility(t *testing.T) { testDecode(t, data, val) } -func TestEncodeEventWithAttachement(t *testing.T) { +func TestEncodeEventWithAttachment(t *testing.T) { script := ` access(all) struct S { access(all) let x: Int @@ -17146,11 +17146,11 @@ func TestEncodeEventWithAttachement(t *testing.T) { } func exportEventFromScript(t *testing.T, script string) cadence.Event { - rt := runtime_utils.NewTestInterpreterRuntime() + rt := NewTestInterpreterRuntime() var events []cadence.Event - inter := &runtime_utils.TestRuntimeInterface{ + inter := &TestRuntimeInterface{ OnEmitEvent: func(event cadence.Event) error { events = append(events, event) return nil diff --git a/encoding/ccf/ccf_type_id_test.go b/encoding/ccf/ccf_type_id_test.go index 271623e4e4..2019a2bbfa 100644 --- a/encoding/ccf/ccf_type_id_test.go +++ b/encoding/ccf/ccf_type_id_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestCCFTypeID(t *testing.T) { @@ -117,7 +117,7 @@ func TestCadenceTypeByCCFTypeID(t *testing.T) { func simpleStructType() *cadence.StructType { return cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -131,7 +131,7 @@ func simpleStructType() *cadence.StructType { func simpleStructType2() *cadence.StructType { return cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct2", []cadence.Field{ { diff --git a/encoding/json/encoding_test.go b/encoding/json/encoding_test.go index 308c8e0e7c..da52ff3cc8 100644 --- a/encoding/json/encoding_test.go +++ b/encoding/json/encoding_test.go @@ -28,14 +28,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/onflow/cadence" "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/sema_utils" - - "github.com/onflow/cadence" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) type encodeTest struct { @@ -1337,7 +1336,7 @@ func TestEncodeStruct(t *testing.T) { t.Parallel() simpleStructType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -1390,7 +1389,7 @@ func TestEncodeStruct(t *testing.T) { fooResourceType := newFooResourceType() resourceStructType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -1499,7 +1498,7 @@ func TestEncodeEvent(t *testing.T) { t.Parallel() simpleEventType := cadence.NewEventType( - utils.TestLocation, + TestLocation, "FooEvent", []cadence.Field{ { @@ -1552,7 +1551,7 @@ func TestEncodeEvent(t *testing.T) { fooResourceType := newFooResourceType() resourceEventType := cadence.NewEventType( - utils.TestLocation, + TestLocation, "FooEvent", []cadence.Field{ { @@ -1625,7 +1624,7 @@ func TestEncodeContract(t *testing.T) { t.Parallel() simpleContractType := cadence.NewContractType( - utils.TestLocation, + TestLocation, "FooContract", []cadence.Field{ { @@ -1678,7 +1677,7 @@ func TestEncodeContract(t *testing.T) { fooResourceType := newFooResourceType() resourceContractType := cadence.NewContractType( - utils.TestLocation, + TestLocation, "FooContract", []cadence.Field{ { @@ -1916,7 +1915,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewStructType( - utils.TestLocation, + TestLocation, "S", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -1977,7 +1976,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewResourceType( - utils.TestLocation, + TestLocation, "R", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -2038,7 +2037,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewContractType( - utils.TestLocation, + TestLocation, "C", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -2099,7 +2098,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewStructInterfaceType( - utils.TestLocation, + TestLocation, "S", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -2160,7 +2159,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewResourceInterfaceType( - utils.TestLocation, + TestLocation, "R", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -2221,7 +2220,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewContractInterfaceType( - utils.TestLocation, + TestLocation, "C", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -2282,7 +2281,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewEventType( - utils.TestLocation, + TestLocation, "E", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -2341,7 +2340,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewEnumType( - utils.TestLocation, + TestLocation, "E", cadence.StringType, []cadence.Field{ @@ -3317,7 +3316,7 @@ func TestExportRecursiveType(t *testing.T) { }, } ty := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", fields, nil, @@ -3368,7 +3367,7 @@ func TestExportTypeValueRecursiveType(t *testing.T) { }, } ty := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", fields, [][]cadence.Parameter{}, @@ -3415,14 +3414,14 @@ func TestExportTypeValueRecursiveType(t *testing.T) { t.Parallel() fooTy := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", []cadence.Field{}, [][]cadence.Parameter{}, ) barTy := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Bar", []cadence.Field{ { @@ -3638,7 +3637,7 @@ func testDecode(t *testing.T, actualJSON string, expectedVal cadence.Value, opti func newFooResourceType() *cadence.ResourceType { return cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", []cadence.Field{ { diff --git a/fuzz.go b/fuzz.go index 35774a3137..3b98f72655 100644 --- a/fuzz.go +++ b/fuzz.go @@ -23,7 +23,7 @@ import ( "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func Fuzz(data []byte) int { @@ -40,7 +40,7 @@ func Fuzz(data []byte) int { checker, err := sema.NewChecker( program, - utils.TestLocation, + TestLocation, nil, &sema.Config{ AccessCheckMode: sema.AccessCheckModeNotSpecifiedUnrestricted, diff --git a/tests/fuzz/crashers_test.go b/fuzz/crashers_test.go similarity index 96% rename from tests/fuzz/crashers_test.go rename to fuzz/crashers_test.go index b52a889d73..9ac802ac36 100644 --- a/tests/fuzz/crashers_test.go +++ b/fuzz/crashers_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence" ) -const crashersDir = "../../../crashers" +const crashersDir = "crashers" func TestCrashers(t *testing.T) { diff --git a/interpreter/account_test.go b/interpreter/account_test.go index 9ef518efb9..a003477a56 100644 --- a/interpreter/account_test.go +++ b/interpreter/account_test.go @@ -34,7 +34,8 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) type storageKey struct { diff --git a/interpreter/arithmetic_test.go b/interpreter/arithmetic_test.go index 4c56b41345..86d966ac92 100644 --- a/interpreter/arithmetic_test.go +++ b/interpreter/arithmetic_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) var integerTestValues = map[string]interpreter.NumberValue{ diff --git a/interpreter/attachments_test.go b/interpreter/attachments_test.go index 3c61208033..384ee9f647 100644 --- a/interpreter/attachments_test.go +++ b/interpreter/attachments_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" "github.com/stretchr/testify/require" ) diff --git a/interpreter/bitwise_test.go b/interpreter/bitwise_test.go index b0e9e9cd74..a288e7e667 100644 --- a/interpreter/bitwise_test.go +++ b/interpreter/bitwise_test.go @@ -24,7 +24,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) var bitwiseTestValueFunctions = map[string]func(int) interpreter.NumberValue{ diff --git a/interpreter/builtinfunctions_test.go b/interpreter/builtinfunctions_test.go index b527af6900..93402c80e5 100644 --- a/interpreter/builtinfunctions_test.go +++ b/interpreter/builtinfunctions_test.go @@ -29,7 +29,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretToString(t *testing.T) { diff --git a/interpreter/character_test.go b/interpreter/character_test.go index 298fb1c604..b079563f09 100644 --- a/interpreter/character_test.go +++ b/interpreter/character_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretCharacterUtf8Field(t *testing.T) { diff --git a/interpreter/composite_value_test.go b/interpreter/composite_value_test.go index cacf0c145d..de85e30b22 100644 --- a/interpreter/composite_value_test.go +++ b/interpreter/composite_value_test.go @@ -29,7 +29,8 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretCompositeValue(t *testing.T) { diff --git a/interpreter/condition_test.go b/interpreter/condition_test.go index 74d1deabc9..ef1df7b638 100644 --- a/interpreter/condition_test.go +++ b/interpreter/condition_test.go @@ -31,8 +31,9 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretFunctionPreTestCondition(t *testing.T) { diff --git a/interpreter/container_mutation_test.go b/interpreter/container_mutation_test.go index 10a37e6a30..5f67eab2b1 100644 --- a/interpreter/container_mutation_test.go +++ b/interpreter/container_mutation_test.go @@ -29,10 +29,11 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) -func TestInterpetArrayMutation(t *testing.T) { +func TestInterpretArrayMutation(t *testing.T) { t.Parallel() diff --git a/interpreter/contract_test.go b/interpreter/contract_test.go index e4f9e8b30f..6d437fdec1 100644 --- a/interpreter/contract_test.go +++ b/interpreter/contract_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/interpreter" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestInterpretContractUseBeforeInitializationComplete(t *testing.T) { diff --git a/interpreter/conversion_test.go b/interpreter/conversion_test.go index a3eb0122a0..a798b10fb0 100644 --- a/interpreter/conversion_test.go +++ b/interpreter/conversion_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" . "github.com/onflow/cadence/interpreter" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestByteArrayValueToByteSlice(t *testing.T) { diff --git a/interpreter/deepcopyremove_test.go b/interpreter/deepcopyremove_test.go index de16e42445..0f12a4b034 100644 --- a/interpreter/deepcopyremove_test.go +++ b/interpreter/deepcopyremove_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestValueDeepCopyAndDeepRemove(t *testing.T) { @@ -40,7 +40,7 @@ func TestValueDeepCopyAndDeepRemove(t *testing.T) { inter, err := interpreter.NewInterpreter( nil, - utils.TestLocation, + TestLocation, &interpreter.Config{ Storage: storage, }, diff --git a/interpreter/dynamic_casting_test.go b/interpreter/dynamic_casting_test.go index 03b532b119..255a7b719e 100644 --- a/interpreter/dynamic_casting_test.go +++ b/interpreter/dynamic_casting_test.go @@ -32,7 +32,8 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) // dynamic casting operation -> returns optional diff --git a/interpreter/encoding_test.go b/interpreter/encoding_test.go index 5bcc19bc7e..2eb4047209 100644 --- a/interpreter/encoding_test.go +++ b/interpreter/encoding_test.go @@ -30,12 +30,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/onflow/cadence/common" . "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - - "github.com/onflow/cadence/common" - "github.com/onflow/cadence/tests/utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) type encodeDecodeTest struct { @@ -492,7 +491,7 @@ func TestEncodeDecodeComposite(t *testing.T) { expected := NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "TestStruct", common.CompositeKindStructure, nil, @@ -530,7 +529,7 @@ func TestEncodeDecodeComposite(t *testing.T) { expected := NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "TestResource", common.CompositeKindResource, fields, @@ -4256,7 +4255,7 @@ func TestEncodeDecodeStorageCapabilityControllerValue(t *testing.T) { BorrowType: &ReferenceStaticType{ ReferencedType: NewCompositeStaticTypeComputeTypeID( nil, - utils.TestLocation, + TestLocation, "SimpleStruct", ), Authorization: UnauthorizedAccess, @@ -4305,7 +4304,7 @@ func TestEncodeDecodeStorageCapabilityControllerValue(t *testing.T) { value := &StorageCapabilityControllerValue{ TargetPath: publicPathValue, BorrowType: &ReferenceStaticType{ - ReferencedType: NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "SimpleInterface"), + ReferencedType: NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "SimpleInterface"), Authorization: UnauthorizedAccess, }, CapabilityID: capabilityID, @@ -4485,8 +4484,8 @@ func TestEncodeDecodeStorageCapabilityControllerValue(t *testing.T) { BorrowType: &ReferenceStaticType{ ReferencedType: &IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "I1"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "I2"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "I1"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "I2"), }, }, Authorization: UnauthorizedAccess, @@ -4705,7 +4704,7 @@ func TestEncodeDecodeAccountCapabilityControllerValue(t *testing.T) { BorrowType: &ReferenceStaticType{ ReferencedType: &IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "SimpleInterface"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "SimpleInterface"), }, }, Authorization: UnauthorizedAccess, diff --git a/interpreter/entitlements_test.go b/interpreter/entitlements_test.go index 0475ec1191..79d368de70 100644 --- a/interpreter/entitlements_test.go +++ b/interpreter/entitlements_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretEntitledReferenceRuntimeTypes(t *testing.T) { diff --git a/interpreter/enum_test.go b/interpreter/enum_test.go index 54e563c784..fa3e9a0c05 100644 --- a/interpreter/enum_test.go +++ b/interpreter/enum_test.go @@ -24,10 +24,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - . "github.com/onflow/cadence/tests/utils" - "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretEnum(t *testing.T) { diff --git a/interpreter/equality_test.go b/interpreter/equality_test.go index dee8dc54c9..68cfd10f04 100644 --- a/interpreter/equality_test.go +++ b/interpreter/equality_test.go @@ -31,7 +31,8 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretEquality(t *testing.T) { diff --git a/interpreter/errors_test.go b/interpreter/errors_test.go index 568158cf58..4c120a0994 100644 --- a/interpreter/errors_test.go +++ b/interpreter/errors_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" . "github.com/onflow/cadence/interpreter" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestOverwriteError_Error(t *testing.T) { @@ -47,11 +47,11 @@ func TestErrorOutputIncludesLocationRage(t *testing.T) { t.Parallel() require.Equal(t, Error{ - Location: utils.TestLocation, + Location: TestLocation, Err: DereferenceError{ Cause: "the value being referenced has been destroyed or moved", LocationRange: LocationRange{ - Location: utils.TestLocation, + Location: TestLocation, HasPosition: ast.Range{ StartPos: ast.Position{Offset: 0, Column: 0, Line: 0}, EndPos: ast.Position{Offset: 0, Column: 0, Line: 0}, diff --git a/interpreter/fixedpoint_test.go b/interpreter/fixedpoint_test.go index 0fe9d9258b..fa19591104 100644 --- a/interpreter/fixedpoint_test.go +++ b/interpreter/fixedpoint_test.go @@ -29,7 +29,8 @@ import ( "github.com/onflow/cadence/fixedpoint" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretNegativeZeroFixedPoint(t *testing.T) { diff --git a/interpreter/for_test.go b/interpreter/for_test.go index 370546ffdf..48246d29b0 100644 --- a/interpreter/for_test.go +++ b/interpreter/for_test.go @@ -30,7 +30,8 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretForStatement(t *testing.T) { diff --git a/interpreter/function_test.go b/interpreter/function_test.go index e4e293fa9c..b16b77c642 100644 --- a/interpreter/function_test.go +++ b/interpreter/function_test.go @@ -27,8 +27,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretResultVariable(t *testing.T) { @@ -60,7 +60,7 @@ func TestInterpretResultVariable(t *testing.T) { require.IsType(t, &interpreter.CompositeValue{}, result) resource := result.(*interpreter.CompositeValue) assert.Equal(t, common.CompositeKindResource, resource.Kind) - utils.AssertValuesEqual( + AssertValuesEqual( t, inter, interpreter.UInt8Value(1), @@ -98,7 +98,7 @@ func TestInterpretResultVariable(t *testing.T) { resource := innerValue.(*interpreter.CompositeValue) assert.Equal(t, common.CompositeKindResource, resource.Kind) - utils.AssertValuesEqual( + AssertValuesEqual( t, inter, interpreter.UInt8Value(1), @@ -162,7 +162,7 @@ func TestInterpretResultVariable(t *testing.T) { resource := innerValue.(*interpreter.CompositeValue) assert.Equal(t, common.CompositeKindResource, resource.Kind) - utils.AssertValuesEqual( + AssertValuesEqual( t, inter, interpreter.UInt8Value(1), @@ -316,7 +316,7 @@ func TestInterpretFunctionSubtyping(t *testing.T) { result, err := inter.Invoke("main") require.NoError(t, err) - utils.AssertValuesEqual( + AssertValuesEqual( t, inter, interpreter.NewUnmeteredSomeValueNonCopying(interpreter.UInt8Value(4)), diff --git a/interpreter/if_test.go b/interpreter/if_test.go index 4242062e39..ef92e2a576 100644 --- a/interpreter/if_test.go +++ b/interpreter/if_test.go @@ -24,11 +24,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" - "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretIfStatement(t *testing.T) { diff --git a/interpreter/import_test.go b/interpreter/import_test.go index a5a2e808b7..b1599e2a09 100644 --- a/interpreter/import_test.go +++ b/interpreter/import_test.go @@ -29,8 +29,9 @@ import ( "github.com/onflow/cadence/common/orderedmap" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretVirtualImport(t *testing.T) { diff --git a/interpreter/inspect_test.go b/interpreter/inspect_test.go index da6e78537e..e0ea1ff19f 100644 --- a/interpreter/inspect_test.go +++ b/interpreter/inspect_test.go @@ -23,7 +23,7 @@ import ( "github.com/onflow/cadence/common" . "github.com/onflow/cadence/interpreter" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInspectValue(t *testing.T) { diff --git a/interpreter/integers_test.go b/interpreter/integers_test.go index 9da93b1745..86f1eb4f22 100644 --- a/interpreter/integers_test.go +++ b/interpreter/integers_test.go @@ -28,10 +28,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - . "github.com/onflow/cadence/tests/utils" - "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) var testIntegerTypesAndValues = map[string]interpreter.Value{ diff --git a/interpreter/interface_test.go b/interpreter/interface_test.go index b61c422ba5..09580c8171 100644 --- a/interpreter/interface_test.go +++ b/interpreter/interface_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestInterpretInterfaceDefaultImplementation(t *testing.T) { @@ -456,7 +456,7 @@ func TestInterpretInterfaceFunctionConditionsInheritance(t *testing.T) { // Implementation should satisfy inherited conditions _, err = inter.Invoke("main", interpreter.NewUnmeteredIntValueFromInt64(5)) - utils.RequireError(t, err) + RequireError(t, err) assert.ErrorAs(t, err, &interpreter.ConditionError{}) }) @@ -496,7 +496,7 @@ func TestInterpretInterfaceFunctionConditionsInheritance(t *testing.T) { // Implementation should satisfy inherited conditions _, err = inter.Invoke("main", interpreter.NewUnmeteredIntValueFromInt64(5)) - utils.RequireError(t, err) + RequireError(t, err) assert.ErrorAs(t, err, &interpreter.ConditionError{}) }) @@ -539,11 +539,11 @@ func TestInterpretInterfaceFunctionConditionsInheritance(t *testing.T) { // Implementation should satisfy both inherited conditions _, err = inter.Invoke("main", interpreter.NewUnmeteredIntValueFromInt64(5)) - utils.RequireError(t, err) + RequireError(t, err) assert.ErrorAs(t, err, &interpreter.ConditionError{}) _, err = inter.Invoke("main", interpreter.NewUnmeteredIntValueFromInt64(25)) - utils.RequireError(t, err) + RequireError(t, err) assert.ErrorAs(t, err, &interpreter.ConditionError{}) }) @@ -588,11 +588,11 @@ func TestInterpretInterfaceFunctionConditionsInheritance(t *testing.T) { // Implementation should satisfy both inherited conditions _, err = inter.Invoke("main", interpreter.NewUnmeteredIntValueFromInt64(5)) - utils.RequireError(t, err) + RequireError(t, err) assert.ErrorAs(t, err, &interpreter.ConditionError{}) _, err = inter.Invoke("main", interpreter.NewUnmeteredIntValueFromInt64(25)) - utils.RequireError(t, err) + RequireError(t, err) assert.ErrorAs(t, err, &interpreter.ConditionError{}) }) diff --git a/interpreter/interpreter_tracing_test.go b/interpreter/interpreter_tracing_test.go index dfcfc16521..5f2a758fbc 100644 --- a/interpreter/interpreter_tracing_test.go +++ b/interpreter/interpreter_tracing_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func setupInterpreterWithTracingCallBack( @@ -38,7 +38,7 @@ func setupInterpreterWithTracingCallBack( storage := newUnmeteredInMemoryStorage() inter, err := interpreter.NewInterpreter( nil, - utils.TestLocation, + TestLocation, &interpreter.Config{ OnRecordTrace: func(inter *interpreter.Interpreter, operationName string, diff --git a/interpreter/invocation_test.go b/interpreter/invocation_test.go index 4e9164f36f..1d08c47f14 100644 --- a/interpreter/invocation_test.go +++ b/interpreter/invocation_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestInterpretFunctionInvocationCheckArgumentTypes(t *testing.T) { diff --git a/interpreter/member_test.go b/interpreter/member_test.go index a7dd3c454a..f73b4e8be6 100644 --- a/interpreter/member_test.go +++ b/interpreter/member_test.go @@ -25,8 +25,8 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/interpreter" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretMemberAccessType(t *testing.T) { diff --git a/interpreter/memory_metering_test.go b/interpreter/memory_metering_test.go index 56fae49cb0..725ea93037 100644 --- a/interpreter/memory_metering_test.go +++ b/interpreter/memory_metering_test.go @@ -23,7 +23,7 @@ import ( "testing" "github.com/onflow/cadence/activations" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -33,7 +33,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) type assumeValidPublicKeyValidator struct{} @@ -8152,7 +8152,7 @@ func TestInterpretASTMetering(t *testing.T) { let Foo = 1 `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) require.NoError(t, err) @@ -8450,7 +8450,7 @@ func TestInterpretASTMetering(t *testing.T) { let B = 1 `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) require.NoError(t, err) @@ -8960,7 +8960,7 @@ func TestInterpretValueStringConversion(t *testing.T) { interpreter.NewUnmeteredCapabilityValue( 4, interpreter.AddressValue{1}, - interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "Bar"), + interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "Bar"), )) }) diff --git a/interpreter/metatype_test.go b/interpreter/metatype_test.go index ad96c6b1d9..edcd83a901 100644 --- a/interpreter/metatype_test.go +++ b/interpreter/metatype_test.go @@ -30,7 +30,8 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretMetaTypeEquality(t *testing.T) { diff --git a/interpreter/metering_test.go b/interpreter/metering_test.go index a7ea9882d0..267b15d985 100644 --- a/interpreter/metering_test.go +++ b/interpreter/metering_test.go @@ -28,8 +28,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretStatementHandler(t *testing.T) { @@ -44,7 +44,7 @@ func TestInterpretStatementHandler(t *testing.T) { } `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) require.NoError(t, err) @@ -73,7 +73,7 @@ func TestInterpretStatementHandler(t *testing.T) { Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, - utils.ImportedLocation, + ImportedLocation, importedLocation, ) @@ -116,7 +116,7 @@ func TestInterpretStatementHandler(t *testing.T) { }, ImportLocationHandler: func(inter *interpreter.Interpreter, location common.Location) interpreter.Import { assert.Equal(t, - utils.ImportedLocation, + ImportedLocation, location, ) @@ -197,7 +197,7 @@ func TestInterpretLoopIterationHandler(t *testing.T) { Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, - utils.ImportedLocation, + ImportedLocation, importedLocation, ) @@ -241,7 +241,7 @@ func TestInterpretLoopIterationHandler(t *testing.T) { }, ImportLocationHandler: func(inter *interpreter.Interpreter, location common.Location) interpreter.Import { assert.Equal(t, - utils.ImportedLocation, + ImportedLocation, location, ) @@ -303,7 +303,7 @@ func TestInterpretFunctionInvocationHandler(t *testing.T) { } `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) require.NoError(t, err) @@ -332,7 +332,7 @@ func TestInterpretFunctionInvocationHandler(t *testing.T) { Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, - utils.ImportedLocation, + ImportedLocation, importedLocation, ) @@ -368,7 +368,7 @@ func TestInterpretFunctionInvocationHandler(t *testing.T) { }, ImportLocationHandler: func(inter *interpreter.Interpreter, location common.Location) interpreter.Import { assert.Equal(t, - utils.ImportedLocation, + ImportedLocation, location, ) diff --git a/interpreter/misc_test.go b/interpreter/misc_test.go index d3c3138580..9c8e7c8886 100644 --- a/interpreter/misc_test.go +++ b/interpreter/misc_test.go @@ -39,8 +39,9 @@ import ( "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) type ParseCheckAndInterpretOptions struct { @@ -5257,7 +5258,7 @@ func TestInterpretReferenceFailableDowncasting(t *testing.T) { func(invocation interpreter.Invocation) interpreter.Value { authorized := bool(invocation.Arguments[0].(interpreter.BoolValue)) - var auth interpreter.Authorization = interpreter.UnauthorizedAccess + var auth = interpreter.UnauthorizedAccess if authorized { auth = interpreter.ConvertSemaAccessToStaticAuthorization( invocation.Interpreter, diff --git a/interpreter/path_test.go b/interpreter/path_test.go index 015ef66643..10ff7f32f9 100644 --- a/interpreter/path_test.go +++ b/interpreter/path_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretPath(t *testing.T) { diff --git a/interpreter/range_value_test.go b/interpreter/range_value_test.go index ba3b714129..eb88cb4b50 100644 --- a/interpreter/range_value_test.go +++ b/interpreter/range_value_test.go @@ -30,8 +30,8 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) type containsTestCase struct { @@ -440,7 +440,7 @@ func TestInclusiveRange(t *testing.T) { ) } - utils.AssertValuesEqual( + AssertValuesEqual( t, inter, expectedRangeValue, @@ -456,7 +456,7 @@ func TestInclusiveRange(t *testing.T) { expectedValue = interpreter.AsBoolValue(tc.expectedWithoutStep) } - utils.AssertValuesEqual( + AssertValuesEqual( t, inter, expectedValue, diff --git a/interpreter/reference_test.go b/interpreter/reference_test.go index 7af848436c..273f49d74d 100644 --- a/interpreter/reference_test.go +++ b/interpreter/reference_test.go @@ -28,8 +28,9 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretResourceReferenceInstanceOf(t *testing.T) { diff --git a/interpreter/resources_test.go b/interpreter/resources_test.go index fd639a5739..564c745258 100644 --- a/interpreter/resources_test.go +++ b/interpreter/resources_test.go @@ -24,11 +24,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" - "github.com/onflow/cadence/interpreter" + "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretOptionalResourceBindingWithSecondValue(t *testing.T) { diff --git a/interpreter/runtimetype_test.go b/interpreter/runtimetype_test.go index c1ea4ea109..526d28856d 100644 --- a/interpreter/runtimetype_test.go +++ b/interpreter/runtimetype_test.go @@ -24,7 +24,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" "github.com/stretchr/testify/assert" ) @@ -65,7 +65,7 @@ func TestInterpretOptionalType(t *testing.T) { assert.Equal(t, interpreter.TypeValue{ Type: &interpreter.OptionalStaticType{ - Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"), + Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "R"), }, }, inter.Globals.Get("c").GetValue(inter), @@ -124,7 +124,7 @@ func TestInterpretVariableSizedArrayType(t *testing.T) { assert.Equal(t, interpreter.TypeValue{ Type: &interpreter.VariableSizedStaticType{ - Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"), + Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "R"), }, }, inter.Globals.Get("c").GetValue(inter), @@ -184,7 +184,7 @@ func TestInterpretConstantSizedArrayType(t *testing.T) { assert.Equal(t, interpreter.TypeValue{ Type: &interpreter.ConstantSizedStaticType{ - Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"), + Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "R"), Size: int64(400), }, }, @@ -250,7 +250,7 @@ func TestInterpretDictionaryType(t *testing.T) { assert.Equal(t, interpreter.TypeValue{ Type: &interpreter.DictionaryStaticType{ - ValueType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"), + ValueType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "R"), KeyType: interpreter.PrimitiveStaticTypeInt, }, }, @@ -305,14 +305,14 @@ func TestInterpretCompositeType(t *testing.T) { assert.Equal(t, interpreter.TypeValue{ - Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"), + Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "R"), }, inter.Globals.Get("a").GetValue(inter), ) assert.Equal(t, interpreter.TypeValue{ - Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "S"), + Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "S"), }, inter.Globals.Get("b").GetValue(inter), ) @@ -334,7 +334,7 @@ func TestInterpretCompositeType(t *testing.T) { assert.Equal(t, interpreter.TypeValue{ - Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "F"), + Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "F"), }, inter.Globals.Get("f").GetValue(inter), ) @@ -433,7 +433,7 @@ func TestInterpretReferenceType(t *testing.T) { assert.Equal(t, interpreter.TypeValue{ Type: &interpreter.ReferenceStaticType{ - ReferencedType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"), + ReferencedType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "R"), Authorization: interpreter.NewEntitlementSetAuthorization( nil, func() []common.TypeID { return []common.TypeID{"S.test.X"} }, @@ -458,7 +458,7 @@ func TestInterpretReferenceType(t *testing.T) { assert.Equal(t, interpreter.TypeValue{ Type: &interpreter.ReferenceStaticType{ - ReferencedType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "S"), + ReferencedType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "S"), Authorization: interpreter.NewEntitlementSetAuthorization( nil, func() []common.TypeID { return []common.TypeID{"S.test.X"} }, @@ -513,7 +513,7 @@ func TestInterpretIntersectionType(t *testing.T) { interpreter.TypeValue{ Type: &interpreter.IntersectionStaticType{ Types: []*interpreter.InterfaceStaticType{ - interpreter.NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "R"), + interpreter.NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "R"), }, }, }, @@ -529,7 +529,7 @@ func TestInterpretIntersectionType(t *testing.T) { interpreter.TypeValue{ Type: &interpreter.IntersectionStaticType{ Types: []*interpreter.InterfaceStaticType{ - interpreter.NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "S"), + interpreter.NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "S"), }, }, }, @@ -545,8 +545,8 @@ func TestInterpretIntersectionType(t *testing.T) { interpreter.TypeValue{ Type: &interpreter.IntersectionStaticType{ Types: []*interpreter.InterfaceStaticType{ - interpreter.NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "S"), - interpreter.NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "S2"), + interpreter.NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "S"), + interpreter.NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "S2"), }, }, }, @@ -612,7 +612,7 @@ func TestInterpretCapabilityType(t *testing.T) { interpreter.TypeValue{ Type: &interpreter.CapabilityStaticType{ BorrowType: &interpreter.ReferenceStaticType{ - ReferencedType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"), + ReferencedType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "R"), Authorization: interpreter.UnauthorizedAccess, }, }, diff --git a/interpreter/statictype_test.go b/interpreter/statictype_test.go index 76f3570deb..145296ad56 100644 --- a/interpreter/statictype_test.go +++ b/interpreter/statictype_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" . "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestCapabilityStaticType_Equal(t *testing.T) { @@ -182,12 +182,12 @@ func TestCompositeStaticType_Equal(t *testing.T) { require.True(t, NewCompositeStaticTypeComputeTypeID( nil, - utils.TestLocation, + TestLocation, "X", ).Equal( NewCompositeStaticTypeComputeTypeID( nil, - utils.TestLocation, + TestLocation, "X", ), ), @@ -201,12 +201,12 @@ func TestCompositeStaticType_Equal(t *testing.T) { require.False(t, NewCompositeStaticTypeComputeTypeID( nil, - utils.TestLocation, + TestLocation, "X", ).Equal( NewCompositeStaticTypeComputeTypeID( nil, - utils.TestLocation, + TestLocation, "Y", ), ), @@ -333,8 +333,8 @@ func TestInterfaceStaticType_Equal(t *testing.T) { t.Parallel() require.True(t, - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"). - Equal(NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X")), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"). + Equal(NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X")), ) }) @@ -343,8 +343,8 @@ func TestInterfaceStaticType_Equal(t *testing.T) { t.Parallel() require.False(t, - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"). - Equal(NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y")), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"). + Equal(NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y")), ) }) @@ -749,14 +749,14 @@ func TestIntersectionStaticType_Equal(t *testing.T) { require.True(t, (&IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), }, }).Equal( &IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), }, }, ), @@ -785,13 +785,13 @@ func TestIntersectionStaticType_Equal(t *testing.T) { require.False(t, (&IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), }, }).Equal( &IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), }, }, ), @@ -805,14 +805,14 @@ func TestIntersectionStaticType_Equal(t *testing.T) { require.True(t, (&IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), }, }).Equal( &IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), }, }, ), @@ -826,14 +826,14 @@ func TestIntersectionStaticType_Equal(t *testing.T) { require.True(t, (&IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), }, }).Equal( &IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), }, }, ), @@ -847,14 +847,14 @@ func TestIntersectionStaticType_Equal(t *testing.T) { require.False(t, (&IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), }, }).Equal( &IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Z"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Z"), }, }, ), @@ -868,13 +868,13 @@ func TestIntersectionStaticType_Equal(t *testing.T) { require.False(t, (&IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), }, }).Equal( &IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), }, }, ), @@ -888,14 +888,14 @@ func TestIntersectionStaticType_Equal(t *testing.T) { require.False(t, (&IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), }, }).Equal( &IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Z"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Z"), }, }, ), @@ -909,8 +909,8 @@ func TestIntersectionStaticType_Equal(t *testing.T) { require.False(t, (&IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), }, }).Equal( &ReferenceStaticType{ diff --git a/interpreter/storage_test.go b/interpreter/storage_test.go index 01e9299c38..0693df2d9b 100644 --- a/interpreter/storage_test.go +++ b/interpreter/storage_test.go @@ -29,7 +29,8 @@ import ( "github.com/onflow/cadence/common" . "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestCompositeStorage(t *testing.T) { diff --git a/interpreter/string_test.go b/interpreter/string_test.go index 410d2f478c..580608e26e 100644 --- a/interpreter/string_test.go +++ b/interpreter/string_test.go @@ -26,7 +26,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretRecursiveValueString(t *testing.T) { diff --git a/interpreter/switch_test.go b/interpreter/switch_test.go index 0cbe894063..2a30c6cbdb 100644 --- a/interpreter/switch_test.go +++ b/interpreter/switch_test.go @@ -24,11 +24,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" - "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretSwitchStatement(t *testing.T) { diff --git a/interpreter/transactions_test.go b/interpreter/transactions_test.go index 8a4167a0b1..21a1642f99 100644 --- a/interpreter/transactions_test.go +++ b/interpreter/transactions_test.go @@ -29,8 +29,9 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretTransactions(t *testing.T) { diff --git a/interpreter/transfer_test.go b/interpreter/transfer_test.go index c40a4f0ee3..72447e2dd9 100644 --- a/interpreter/transfer_test.go +++ b/interpreter/transfer_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestInterpretTransferCheck(t *testing.T) { diff --git a/interpreter/uuid_test.go b/interpreter/uuid_test.go index aa4154ff19..efdc8d1010 100644 --- a/interpreter/uuid_test.go +++ b/interpreter/uuid_test.go @@ -28,8 +28,9 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretResourceUUID(t *testing.T) { diff --git a/interpreter/value_function_test.go b/interpreter/value_function_test.go index 0cf1fd6464..2d25e8bc1b 100644 --- a/interpreter/value_function_test.go +++ b/interpreter/value_function_test.go @@ -24,10 +24,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/onflow/cadence/common" - "github.com/onflow/cadence/tests/utils" - . "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestFunctionStaticType(t *testing.T) { @@ -67,7 +66,7 @@ func TestFunctionStaticType(t *testing.T) { inter.SharedState.Config.CompositeTypeHandler = func(location common.Location, typeID TypeID) *sema.CompositeType { return &sema.CompositeType{ - Location: utils.TestLocation, + Location: TestLocation, Identifier: "foo", Kind: common.CompositeKindStructure, } @@ -92,7 +91,7 @@ func TestFunctionStaticType(t *testing.T) { var compositeValue Value = NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "foo", common.CompositeKindStructure, []CompositeField{}, diff --git a/interpreter/value_test.go b/interpreter/value_test.go index 8f4df2bcc1..295f5a4346 100644 --- a/interpreter/value_test.go +++ b/interpreter/value_test.go @@ -36,15 +36,15 @@ import ( . "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func newTestCompositeValue(inter *Interpreter, owner common.Address) *CompositeValue { return NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "Test", common.CompositeKindStructure, nil, @@ -53,7 +53,7 @@ func newTestCompositeValue(inter *Interpreter, owner common.Address) *CompositeV } var testCompositeValueType = &sema.CompositeType{ - Location: utils.TestLocation, + Location: TestLocation, Identifier: "Test", Kind: common.CompositeKindStructure, Members: &sema.StringMemberOrderedMap{}, @@ -94,7 +94,7 @@ func TestOwnerNewArray(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -137,7 +137,7 @@ func TestOwnerArrayDeepCopy(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{ Storage: storage, OnMeterComputation: getMeterCompFuncWithExpectedKinds(t, @@ -206,7 +206,7 @@ func TestOwnerArrayElement(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -248,7 +248,7 @@ func TestOwnerArraySetIndex(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -300,7 +300,7 @@ func TestOwnerArrayAppend(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -346,7 +346,7 @@ func TestOwnerArrayInsert(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -392,7 +392,7 @@ func TestOwnerArrayRemove(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -436,7 +436,7 @@ func TestOwnerNewDictionary(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -483,7 +483,7 @@ func TestOwnerDictionary(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -530,7 +530,7 @@ func TestOwnerDictionaryCopy(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{ Storage: storage, OnMeterComputation: getMeterCompFuncWithExpectedKinds(t, @@ -603,7 +603,7 @@ func TestOwnerDictionarySetSome(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -657,7 +657,7 @@ func TestOwnerDictionaryInsertNonExisting(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -712,7 +712,7 @@ func TestOwnerDictionaryRemove(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -773,7 +773,7 @@ func TestOwnerDictionaryInsertExisting(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -1115,7 +1115,7 @@ func TestStringer(t *testing.T) { return NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "Foo", common.CompositeKindResource, fields, @@ -1137,7 +1137,7 @@ func TestStringer(t *testing.T) { compositeValue := NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "Foo", common.CompositeKindResource, fields, @@ -1410,7 +1410,7 @@ func TestVisitor(t *testing.T) { value = NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "Foo", common.CompositeKindStructure, fields, @@ -1742,7 +1742,7 @@ func TestGetHashInput(t *testing.T) { return NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "Foo", common.CompositeKindEnum, fields, @@ -1770,7 +1770,7 @@ func TestGetHashInput(t *testing.T) { return NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, strings.Repeat("a", 32), common.CompositeKindEnum, fields, @@ -2959,7 +2959,7 @@ func TestCompositeValue_Equal(t *testing.T) { NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "X", common.CompositeKindStructure, fields1, @@ -2970,7 +2970,7 @@ func TestCompositeValue_Equal(t *testing.T) { NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "X", common.CompositeKindStructure, fields2, @@ -3384,7 +3384,7 @@ func TestPublicKeyValue(t *testing.T) { inter, err := NewInterpreter( nil, - utils.TestLocation, + TestLocation, &Config{ Storage: storage, }, @@ -3433,7 +3433,7 @@ func TestPublicKeyValue(t *testing.T) { inter, err := NewInterpreter( nil, - utils.TestLocation, + TestLocation, &Config{ Storage: storage, }, @@ -3589,7 +3589,7 @@ func newTestInterpreter(tb testing.TB) *Interpreter { inter, err := NewInterpreter( nil, - utils.TestLocation, + TestLocation, &Config{ Storage: storage, AtreeValueValidationEnabled: true, @@ -3756,7 +3756,7 @@ func TestValue_ConformsToStaticType(t *testing.T) { return NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "Test", common.CompositeKindStructure, fields, @@ -3775,7 +3775,7 @@ func TestValue_ConformsToStaticType(t *testing.T) { members := &sema.StringMemberOrderedMap{} compositeType := &sema.CompositeType{ - Location: utils.TestLocation, + Location: TestLocation, Identifier: "Test", Kind: common.CompositeKindStructure, Members: members, @@ -3801,7 +3801,7 @@ func TestValue_ConformsToStaticType(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -4493,7 +4493,7 @@ func TestOverwriteDictionaryValueWhereKeyIsStoredInSeparateAtreeSlab(t *testing. return NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "Test", common.CompositeKindEnum, []CompositeField{ @@ -4518,7 +4518,7 @@ func TestOverwriteDictionaryValueWhereKeyIsStoredInSeparateAtreeSlab(t *testing. &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{ Storage: storage, AtreeValueValidationEnabled: true, @@ -4594,7 +4594,7 @@ func TestOverwriteDictionaryValueWhereKeyIsStoredInSeparateAtreeSlab(t *testing. &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{ Storage: storage, AtreeValueValidationEnabled: true, diff --git a/interpreter/value_uint64.go b/interpreter/value_uint64.go index 5c11cca04b..f8b3cdb2ce 100644 --- a/interpreter/value_uint64.go +++ b/interpreter/value_uint64.go @@ -19,12 +19,11 @@ package interpreter import ( + "encoding/binary" "math" "math/big" "unsafe" - "encoding/binary" - "github.com/onflow/atree" "github.com/onflow/cadence/ast" diff --git a/interpreter/values_test.go b/interpreter/values_test.go index e725b5a30c..b874aa4213 100644 --- a/interpreter/values_test.go +++ b/interpreter/values_test.go @@ -36,7 +36,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) // TODO: make these program args? @@ -64,7 +65,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { Program: ast.NewProgram(nil, []ast.Declaration{}), Elaboration: sema.NewElaboration(nil), }, - utils.TestLocation, + TestLocation, &interpreter.Config{ Storage: storage, ImportLocationHandler: func(inter *interpreter.Interpreter, location common.Location) interpreter.Import { @@ -119,7 +120,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { value, found := testMap.Get(inter, interpreter.EmptyLocationRange, orgKey) require.True(t, found) - utils.AssertValuesEqual(t, inter, orgValue, value) + AssertValuesEqual(t, inter, orgValue, value) return false }) @@ -138,7 +139,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { orgValue, ok := entries.get(inter, key) require.True(t, ok, "cannot find key: %v", key) - utils.AssertValuesEqual(t, inter, orgValue, value) + AssertValuesEqual(t, inter, orgValue, value) return true }, ) @@ -164,7 +165,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { value, found := copyOfTestMap.Get(inter, interpreter.EmptyLocationRange, orgKey) require.True(t, found) - utils.AssertValuesEqual(t, inter, orgValue, value) + AssertValuesEqual(t, inter, orgValue, value) return false }) @@ -192,7 +193,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { value, found := testMap.Get(inter, interpreter.EmptyLocationRange, orgKey) require.True(t, found) - utils.AssertValuesEqual(t, inter, orgValue, value) + AssertValuesEqual(t, inter, orgValue, value) return false }) @@ -233,7 +234,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { value, found := dictionary.Get(inter, interpreter.EmptyLocationRange, orgKey) require.True(t, found) - utils.AssertValuesEqual(t, inter, orgValue, value) + AssertValuesEqual(t, inter, orgValue, value) return false }) @@ -284,7 +285,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { // Removed value must be same as the original value innerValue := someValue.InnerValue(inter, interpreter.EmptyLocationRange) - utils.AssertValuesEqual(t, inter, orgValue, innerValue) + AssertValuesEqual(t, inter, orgValue, innerValue) return false }) @@ -344,7 +345,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { // Removed value must be same as the original value innerValue := someValue.InnerValue(inter, interpreter.EmptyLocationRange) - utils.AssertValuesEqual(t, inter, orgValue, innerValue) + AssertValuesEqual(t, inter, orgValue, innerValue) return false }) @@ -412,7 +413,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { // Removed value must be same as the original value innerValue := someValue.InnerValue(inter, interpreter.EmptyLocationRange) - utils.AssertValuesEqual(t, inter, value1, innerValue) + AssertValuesEqual(t, inter, value1, innerValue) } // Check the values @@ -428,7 +429,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { // Read value must be updated value innerValue := someValue.InnerValue(inter, interpreter.EmptyLocationRange) - utils.AssertValuesEqual(t, inter, value2, innerValue) + AssertValuesEqual(t, inter, value2, innerValue) } }) @@ -515,7 +516,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { // Removed value must be same as the original value innerValue := someValue.InnerValue(inter, interpreter.EmptyLocationRange) - utils.AssertValuesEqual(t, inter, orgValue, innerValue) + AssertValuesEqual(t, inter, orgValue, innerValue) deleteCount++ } @@ -583,7 +584,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { value, found := movedDictionary.Get(inter, interpreter.EmptyLocationRange, orgKey) require.True(t, found) - utils.AssertValuesEqual(t, inter, orgValue, value) + AssertValuesEqual(t, inter, orgValue, value) return false }) @@ -607,7 +608,7 @@ func TestInterpretRandomArrayOperations(t *testing.T) { Program: ast.NewProgram(nil, []ast.Declaration{}), Elaboration: sema.NewElaboration(nil), }, - utils.TestLocation, + TestLocation, &interpreter.Config{ Storage: storage, ImportLocationHandler: func(inter *interpreter.Interpreter, location common.Location) interpreter.Import { @@ -651,7 +652,7 @@ func TestInterpretRandomArrayOperations(t *testing.T) { for index, orgElement := range elements { element := testArray.Get(inter, interpreter.EmptyLocationRange, index) - utils.AssertValuesEqual(t, inter, orgElement, element) + AssertValuesEqual(t, inter, orgElement, element) } owner := testArray.GetOwner() @@ -666,10 +667,10 @@ func TestInterpretRandomArrayOperations(t *testing.T) { inter, func(element interpreter.Value) (resume bool) { orgElement := elements[index] - utils.AssertValuesEqual(t, inter, orgElement, element) + AssertValuesEqual(t, inter, orgElement, element) elementByIndex := testArray.Get(inter, interpreter.EmptyLocationRange, index) - utils.AssertValuesEqual(t, inter, element, elementByIndex) + AssertValuesEqual(t, inter, element, elementByIndex) index++ return true @@ -695,7 +696,7 @@ func TestInterpretRandomArrayOperations(t *testing.T) { for index, orgElement := range elements { element := copyOfTestArray.Get(inter, interpreter.EmptyLocationRange, index) - utils.AssertValuesEqual(t, inter, orgElement, element) + AssertValuesEqual(t, inter, orgElement, element) } owner := copyOfTestArray.GetOwner() @@ -717,7 +718,7 @@ func TestInterpretRandomArrayOperations(t *testing.T) { // go over original elements again and check no missing data (no side effect should be found) for index, orgElement := range elements { element := testArray.Get(inter, interpreter.EmptyLocationRange, index) - utils.AssertValuesEqual(t, inter, orgElement, element) + AssertValuesEqual(t, inter, orgElement, element) } owner := testArray.GetOwner() @@ -755,7 +756,7 @@ func TestInterpretRandomArrayOperations(t *testing.T) { // Go over original values again and check no missing data (no side effect should be found) for index, element := range newElements { value := testArray.Get(inter, interpreter.EmptyLocationRange, index) - utils.AssertValuesEqual(t, inter, element, value) + AssertValuesEqual(t, inter, element, value) } }) @@ -789,7 +790,7 @@ func TestInterpretRandomArrayOperations(t *testing.T) { // Go over original values again and check no missing data (no side effect should be found) for index, element := range newElements { value := testArray.Get(inter, interpreter.EmptyLocationRange, index) - utils.AssertValuesEqual(t, inter, element, value) + AssertValuesEqual(t, inter, element, value) } }) @@ -831,7 +832,7 @@ func TestInterpretRandomArrayOperations(t *testing.T) { removedValue := testArray.Remove(inter, interpreter.EmptyLocationRange, 0) // Removed value must be same as the original value - utils.AssertValuesEqual(t, inter, element, removedValue) + AssertValuesEqual(t, inter, element, removedValue) } // Array must be empty @@ -896,7 +897,7 @@ func TestInterpretRandomArrayOperations(t *testing.T) { removedValue := testArray.RemoveFirst(inter, interpreter.EmptyLocationRange) // Removed value must be same as the original value - utils.AssertValuesEqual(t, inter, orgValue, removedValue) + AssertValuesEqual(t, inter, orgValue, removedValue) deleteCount++ } @@ -957,7 +958,7 @@ func TestInterpretRandomArrayOperations(t *testing.T) { // Check the elements for index, orgElement := range elements { element := movedArray.Get(inter, interpreter.EmptyLocationRange, index) - utils.AssertValuesEqual(t, inter, orgElement, element) + AssertValuesEqual(t, inter, orgElement, element) } owner = movedArray.GetOwner() @@ -979,7 +980,7 @@ func TestInterpretRandomCompositeValueOperations(t *testing.T) { Program: ast.NewProgram(nil, []ast.Declaration{}), Elaboration: sema.NewElaboration(nil), }, - utils.TestLocation, + TestLocation, &interpreter.Config{ Storage: storage, ImportLocationHandler: func(inter *interpreter.Interpreter, location common.Location) interpreter.Import { @@ -1005,7 +1006,7 @@ func TestInterpretRandomCompositeValueOperations(t *testing.T) { for fieldName, orgFieldValue := range orgFields { fieldValue := testComposite.GetField(inter, interpreter.EmptyLocationRange, fieldName) - utils.AssertValuesEqual(t, inter, orgFieldValue, fieldValue) + AssertValuesEqual(t, inter, orgFieldValue, fieldValue) } owner := testComposite.GetOwner() @@ -1017,7 +1018,7 @@ func TestInterpretRandomCompositeValueOperations(t *testing.T) { testComposite.ForEachField(inter, func(name string, value interpreter.Value) (resume bool) { orgValue, ok := orgFields[name] require.True(t, ok) - utils.AssertValuesEqual(t, inter, orgValue, value) + AssertValuesEqual(t, inter, orgValue, value) fieldCount++ // continue iteration @@ -1042,7 +1043,7 @@ func TestInterpretRandomCompositeValueOperations(t *testing.T) { for name, orgValue := range orgFields { value := copyOfTestComposite.GetField(inter, interpreter.EmptyLocationRange, name) - utils.AssertValuesEqual(t, inter, orgValue, value) + AssertValuesEqual(t, inter, orgValue, value) } owner := copyOfTestComposite.GetOwner() @@ -1062,7 +1063,7 @@ func TestInterpretRandomCompositeValueOperations(t *testing.T) { // go over original values again and check no missing data (no side effect should be found) for name, orgValue := range orgFields { value := testComposite.GetField(inter, interpreter.EmptyLocationRange, name) - utils.AssertValuesEqual(t, inter, orgValue, value) + AssertValuesEqual(t, inter, orgValue, value) } owner := testComposite.GetOwner() @@ -1115,7 +1116,7 @@ func TestInterpretRandomCompositeValueOperations(t *testing.T) { // Check the elements for fieldName, orgFieldValue := range fields { fieldValue := movedComposite.GetField(inter, interpreter.EmptyLocationRange, fieldName) - utils.AssertValuesEqual(t, inter, orgFieldValue, fieldValue) + AssertValuesEqual(t, inter, orgFieldValue, fieldValue) } owner = composite.GetOwner() @@ -1714,7 +1715,7 @@ func TestCheckStorageHealthInMiddleOfDeepRemove(t *testing.T) { Program: ast.NewProgram(nil, []ast.Declaration{}), Elaboration: sema.NewElaboration(nil), }, - utils.TestLocation, + TestLocation, &interpreter.Config{ Storage: storage, ImportLocationHandler: func(inter *interpreter.Interpreter, location common.Location) interpreter.Import { @@ -1792,7 +1793,7 @@ func TestCheckStorageHealthInMiddleOfTransferAndRemove(t *testing.T) { Program: ast.NewProgram(nil, []ast.Declaration{}), Elaboration: sema.NewElaboration(nil), }, - utils.TestLocation, + TestLocation, &interpreter.Config{ Storage: storage, ImportLocationHandler: func(inter *interpreter.Interpreter, location common.Location) interpreter.Import { diff --git a/interpreter/while_test.go b/interpreter/while_test.go index 10bcf69db6..c341dfdf57 100644 --- a/interpreter/while_test.go +++ b/interpreter/while_test.go @@ -23,9 +23,8 @@ import ( "github.com/stretchr/testify/require" - . "github.com/onflow/cadence/tests/utils" - "github.com/onflow/cadence/interpreter" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretWhileStatement(t *testing.T) { diff --git a/old_parser/declaration_test.go b/old_parser/declaration_test.go index f41fd0c978..23463f9479 100644 --- a/old_parser/declaration_test.go +++ b/old_parser/declaration_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestParseVariableDeclaration(t *testing.T) { @@ -41,7 +41,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations("var x = 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -77,7 +77,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations(" pub var x = 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessAll, @@ -113,7 +113,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations("let x = 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -149,7 +149,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations("let x <- 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -185,7 +185,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations("let r2: @R <- r") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -228,7 +228,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseStatements("var x <- y <- z") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -275,7 +275,7 @@ func TestParseVariableDeclaration(t *testing.T) { StaticModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for variable", @@ -291,7 +291,7 @@ func TestParseVariableDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("static var x = 1") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -313,7 +313,7 @@ func TestParseVariableDeclaration(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for variable", @@ -329,7 +329,7 @@ func TestParseVariableDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("native var x = 1") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -361,7 +361,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse("()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 0, Offset: 0}, @@ -379,7 +379,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse(" ( )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 1, Offset: 1}, @@ -397,7 +397,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse("( a : Int )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Parameters: []*ast.Parameter{ { @@ -435,7 +435,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse("( a b : Int )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Parameters: []*ast.Parameter{ { @@ -473,7 +473,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse("( a b : Int , c : Int )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Parameters: []*ast.Parameter{ { @@ -527,7 +527,7 @@ func TestParseParameterList(t *testing.T) { t.Parallel() _, errs := parse("( a b : Int c : Int )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &MissingCommaInParameterListError{ Pos: ast.Position{Offset: 14, Line: 1, Column: 14}, @@ -549,7 +549,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("fun foo () { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -586,7 +586,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("pub fun foo () { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessAll, @@ -623,7 +623,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("fun foo (): X { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -682,7 +682,7 @@ func TestParseFunctionDeclaration(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -797,7 +797,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("/// Test\nfun foo() {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -835,7 +835,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("\n /// First line\n \n/// Second line\n\n\nfun foo() {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -873,7 +873,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("\n /** Cool dogs.\n\n Cool cats!! */\n\n\nfun foo() {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -916,7 +916,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("fun main(): Int{ return 1 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -985,7 +985,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1022,7 +1022,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("native fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1046,7 +1046,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1083,7 +1083,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("static fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1108,7 +1108,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1145,7 +1145,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("static native fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1168,7 +1168,7 @@ func TestParseFunctionDeclaration(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier after native modifier", @@ -1185,7 +1185,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("native static fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1210,7 +1210,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessAll, @@ -1247,7 +1247,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("pub static native fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1271,7 +1271,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1321,7 +1321,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1378,7 +1378,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1443,7 +1443,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected '(' as start of parameter list, got '<'", @@ -1466,7 +1466,7 @@ func TestParseFunctionDeclaration(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing '>' at end of type parameter list", @@ -1489,7 +1489,7 @@ func TestParseFunctionDeclaration(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &MissingCommaInParameterListError{ Pos: ast.Position{Offset: 13, Line: 1, Column: 13}, @@ -1521,7 +1521,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("pub") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessAll, result, ) @@ -1534,7 +1534,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("pub ( set )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessPubSettableLegacy, result, ) @@ -1545,7 +1545,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("pub ( ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected keyword \"set\", got EOF", @@ -1555,7 +1555,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1566,7 +1566,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("pub ( set ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token ')'", @@ -1576,7 +1576,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1587,7 +1587,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("pub ( foo )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected keyword \"set\", got \"foo\"", @@ -1597,7 +1597,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1610,7 +1610,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("priv") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessSelf, result, ) @@ -1623,7 +1623,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( all )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessAll, result, ) @@ -1636,7 +1636,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( account )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessAccount, result, ) @@ -1649,7 +1649,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( contract )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessContract, result, ) @@ -1662,7 +1662,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( self )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessSelf, result, ) @@ -1673,7 +1673,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected keyword \"all\", \"account\", \"contract\", or \"self\", got EOF", @@ -1683,7 +1683,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1694,7 +1694,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( self ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token ')'", @@ -1704,7 +1704,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1715,7 +1715,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( foo )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected keyword \"all\", \"account\", \"contract\", or \"self\", got \"foo\"", @@ -1725,7 +1725,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1741,7 +1741,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected end in import declaration: expected string, address, or identifier", @@ -1753,7 +1753,7 @@ func TestParseImportDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -1766,7 +1766,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import "foo"`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -1789,7 +1789,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import 0x42`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -1812,7 +1812,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import 0x10000000000000001`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "address too large", @@ -1836,7 +1836,7 @@ func TestParseImportDeclaration(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -1847,7 +1847,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import 1`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in import declaration: " + @@ -1860,7 +1860,7 @@ func TestParseImportDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -1874,7 +1874,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import foo from "bar"`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -1900,7 +1900,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import foo "bar"`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in import declaration: " + @@ -1913,7 +1913,7 @@ func TestParseImportDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -1926,7 +1926,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import foo , bar , baz from 0x42`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -1962,7 +1962,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import foo , bar , from 0x42`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: `expected identifier, got keyword "from"`, @@ -1974,7 +1974,7 @@ func TestParseImportDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -1987,7 +1987,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import foo`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -2013,7 +2013,7 @@ func TestParseImportDeclaration(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -2076,7 +2076,7 @@ func TestParseEvent(t *testing.T) { result, errs := testParseDeclarations("event E()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -2119,7 +2119,7 @@ func TestParseEvent(t *testing.T) { result, errs := testParseDeclarations(" priv event E2 ( a : Int , b : String )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ @@ -2224,7 +2224,7 @@ func TestParseFieldWithVariableKind(t *testing.T) { result, errs := parse("var x : Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, VariableKind: ast.VariableKindVariable, @@ -2258,7 +2258,7 @@ func TestParseFieldWithVariableKind(t *testing.T) { result, errs := parse("let x : Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, VariableKind: ast.VariableKindConstant, @@ -2316,7 +2316,7 @@ func TestParseField(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, Flags: ast.FieldDeclarationFlagsIsNative, @@ -2367,7 +2367,7 @@ func TestParseField(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, Flags: ast.FieldDeclarationFlagsIsStatic, @@ -2422,7 +2422,7 @@ func TestParseField(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, Flags: ast.FieldDeclarationFlagsIsStatic | ast.FieldDeclarationFlagsIsNative, @@ -2458,7 +2458,7 @@ func TestParseField(t *testing.T) { // For now, leading unknown identifiers are valid. // This will be rejected in Stable Cadence. - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -2481,7 +2481,7 @@ func TestParseField(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier after native modifier", @@ -2505,7 +2505,7 @@ func TestParseField(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessAll, Flags: ast.FieldDeclarationFlagsIsStatic | ast.FieldDeclarationFlagsIsNative, @@ -2541,7 +2541,7 @@ func TestParseField(t *testing.T) { // For now, leading unknown identifiers are valid. // This will be rejected in Stable Cadence. - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -2565,7 +2565,7 @@ func TestParseCompositeDeclaration(t *testing.T) { result, errs := testParseDeclarations(" pub struct S { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessAll, @@ -2592,7 +2592,7 @@ func TestParseCompositeDeclaration(t *testing.T) { result, errs := testParseDeclarations(" pub resource R : RI { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessAll, @@ -2640,7 +2640,7 @@ func TestParseCompositeDeclaration(t *testing.T) { require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -2822,7 +2822,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { result, errs := testParseDeclarations("pub attachment E for S {} ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.AttachmentDeclaration{ Access: ast.AccessAll, @@ -2857,7 +2857,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { }`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -2903,7 +2903,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("attachment E {} ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected 'for', got '{'", @@ -2921,7 +2921,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { result, errs := testParseDeclarations("pub attachment E for S: I {} ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.AttachmentDeclaration{ Access: ast.AccessAll, @@ -2963,7 +2963,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { result, errs := testParseDeclarations("pub attachment E for S: I1, I2 {} ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.AttachmentDeclaration{ Access: ast.AccessAll, @@ -3018,7 +3018,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { }`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.AttachmentDeclaration{ Access: ast.AccessAll, @@ -3162,7 +3162,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { result, errs := testParseDeclarations(" pub struct interface S { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.InterfaceDeclaration{ Access: ast.AccessAll, @@ -3187,7 +3187,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(" pub struct interface interface { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected interface name, got keyword \"interface\"", @@ -3199,7 +3199,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -3225,7 +3225,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.InterfaceDeclaration{ Access: ast.AccessNotSpecified, @@ -3400,7 +3400,7 @@ func TestParseEnumDeclaration(t *testing.T) { result, errs := testParseDeclarations(" pub enum E { case c ; pub case d }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessAll, @@ -3450,7 +3450,7 @@ func TestParseEnumDeclaration(t *testing.T) { StaticModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for enum case", @@ -3484,7 +3484,7 @@ func TestParseEnumDeclaration(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for enum case", @@ -3519,7 +3519,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseDeclarations("transaction { execute {} }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Execute: &ast.SpecialFunctionDeclaration{ @@ -3559,7 +3559,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Fields: nil, @@ -3595,7 +3595,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Fields: []*ast.FieldDeclaration{ @@ -3788,7 +3788,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Fields: []*ast.FieldDeclaration{ @@ -4027,7 +4027,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Fields: []*ast.FieldDeclaration{ @@ -4250,7 +4250,7 @@ func TestParseFunctionAndBlock(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -4296,7 +4296,7 @@ func TestParseFunctionParameterWithoutLabel(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -4354,7 +4354,7 @@ func TestParseFunctionParameterWithLabel(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -4423,7 +4423,7 @@ func TestParseStructure(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -4603,7 +4603,7 @@ func TestParseStructureWithConformances(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -4674,7 +4674,7 @@ func TestParsePreAndPostConditions(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -4824,7 +4824,7 @@ func TestParseConditionMessage(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -5045,7 +5045,7 @@ func TestParseInterface(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{test}, actual.Declarations(), ) @@ -5063,7 +5063,7 @@ func TestParsePragmaNoArguments(t *testing.T) { result, errs := testParseDeclarations(`#pedantic`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.PragmaDeclaration{ Expression: &ast.IdentifierExpression{ @@ -5093,7 +5093,7 @@ func TestParsePragmaNoArguments(t *testing.T) { StaticModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for pragma", @@ -5109,7 +5109,7 @@ func TestParsePragmaNoArguments(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("static #foo") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -5131,7 +5131,7 @@ func TestParsePragmaNoArguments(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for pragma", @@ -5147,7 +5147,7 @@ func TestParsePragmaNoArguments(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("native #foo") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -5167,7 +5167,7 @@ func TestParsePragmaArguments(t *testing.T) { actual, err := testParseProgram(code) require.NoError(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.PragmaDeclaration{ Expression: &ast.InvocationExpression{ @@ -5212,7 +5212,7 @@ func TestParseImportWithString(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -5238,7 +5238,7 @@ func TestParseImportWithAddress(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -5266,7 +5266,7 @@ func TestParseImportWithIdentifiers(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -5305,7 +5305,7 @@ func TestParseFieldWithFromIdentifier(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -5370,7 +5370,7 @@ func TestParseImportWithFromIdentifier(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -5415,7 +5415,7 @@ func TestParseResource(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -5445,7 +5445,7 @@ func TestParseEventDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -5531,7 +5531,7 @@ func TestParseEventEmitStatement(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -5617,7 +5617,7 @@ func TestParseResourceReturnType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -5666,7 +5666,7 @@ func TestParseMovingVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5702,7 +5702,7 @@ func TestParseResourceParameterType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -5761,7 +5761,7 @@ func TestParseMovingVariableDeclarationWithTypeAnnotation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5807,7 +5807,7 @@ func TestParseFieldDeclarationWithMoveTypeAnnotation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -5864,7 +5864,7 @@ func TestParseDestructor(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -5922,7 +5922,7 @@ func TestParseCompositeDeclarationWithSemicolonSeparatedMembers(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -6136,7 +6136,7 @@ func TestParsePreconditionWithUnaryNegation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -6215,7 +6215,7 @@ func TestParseInvalidAccessModifiers(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("pub #test") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid access modifier for pragma", @@ -6231,7 +6231,7 @@ func TestParseInvalidAccessModifiers(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("pub transaction {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid access modifier for transaction", @@ -6247,7 +6247,7 @@ func TestParseInvalidAccessModifiers(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("pub priv let x = 1") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid second access modifier", @@ -6277,7 +6277,7 @@ func TestParseInvalidImportWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for import", @@ -6296,7 +6296,7 @@ func TestParseInvalidImportWithModifier(t *testing.T) { static import x from 0x1 `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6321,7 +6321,7 @@ func TestParseInvalidImportWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for import", @@ -6340,7 +6340,7 @@ func TestParseInvalidImportWithModifier(t *testing.T) { native import x from 0x1 `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6370,7 +6370,7 @@ func TestParseInvalidEventWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for event", @@ -6389,7 +6389,7 @@ func TestParseInvalidEventWithModifier(t *testing.T) { static event Foo() `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6414,7 +6414,7 @@ func TestParseInvalidEventWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for event", @@ -6433,7 +6433,7 @@ func TestParseInvalidEventWithModifier(t *testing.T) { native event Foo() `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6464,7 +6464,7 @@ func TestParseCompositeWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for structure", @@ -6483,7 +6483,7 @@ func TestParseCompositeWithModifier(t *testing.T) { static struct Foo() `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6508,7 +6508,7 @@ func TestParseCompositeWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for structure", @@ -6527,7 +6527,7 @@ func TestParseCompositeWithModifier(t *testing.T) { native struct Foo() `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6557,7 +6557,7 @@ func TestParseTransactionWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for transaction", @@ -6576,7 +6576,7 @@ func TestParseTransactionWithModifier(t *testing.T) { static transaction {} `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6601,7 +6601,7 @@ func TestParseTransactionWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for transaction", @@ -6620,7 +6620,7 @@ func TestParseTransactionWithModifier(t *testing.T) { native transaction {} `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6661,7 +6661,7 @@ func TestParseNestedPragma(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for pragma", @@ -6678,7 +6678,7 @@ func TestParseNestedPragma(t *testing.T) { _, errs := parse("native #pragma", Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6699,7 +6699,7 @@ func TestParseNestedPragma(t *testing.T) { StaticModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for pragma", @@ -6719,7 +6719,7 @@ func TestParseNestedPragma(t *testing.T) { Config{}, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6741,7 +6741,7 @@ func TestParseNestedPragma(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for pragma", @@ -6761,7 +6761,7 @@ func TestParseNestedPragma(t *testing.T) { // For now, leading unknown identifiers are valid. // This will be rejected in Stable Cadence. - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -6784,7 +6784,7 @@ func TestParseNestedPragma(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier after native modifier", @@ -6801,7 +6801,7 @@ func TestParseNestedPragma(t *testing.T) { _, errs := parse("pub #pragma", Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid access modifier for pragma", @@ -6823,7 +6823,7 @@ func TestParseNestedPragma(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid access modifier for pragma", @@ -6843,7 +6843,7 @@ func TestParseNestedPragma(t *testing.T) { // For now, leading unknown identifiers are valid. // This will be rejected in Stable Cadence. - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -6880,7 +6880,7 @@ func TestParseMemberDocStrings(t *testing.T) { require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -6996,7 +6996,7 @@ func TestParseMemberDocStrings(t *testing.T) { require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -7093,7 +7093,7 @@ func TestParseInvalidSpecialFunctionReturnTypeAnnotation(t *testing.T) { init(): Int } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid return type for initializer", diff --git a/old_parser/expression_test.go b/old_parser/expression_test.go index c90f4702cf..a91ad7d4dc 100644 --- a/old_parser/expression_test.go +++ b/old_parser/expression_test.go @@ -34,7 +34,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/parser/lexer" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestParseSimpleInfixExpression(t *testing.T) { @@ -48,7 +48,7 @@ func TestParseSimpleInfixExpression(t *testing.T) { result, errs := testParseExpression("1+2*3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IntegerExpression{ @@ -93,7 +93,7 @@ func TestParseSimpleInfixExpression(t *testing.T) { result, errs := testParseExpression(" 1 + 2 * 3 ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IntegerExpression{ @@ -138,7 +138,7 @@ func TestParseSimpleInfixExpression(t *testing.T) { result, errs := testParseExpression("1 + 2 + 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.BinaryExpression{ @@ -183,7 +183,7 @@ func TestParseSimpleInfixExpression(t *testing.T) { result, errs := testParseExpression("1 ?? 2 ?? 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationNilCoalesce, Left: &ast.IntegerExpression{ @@ -233,7 +233,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("1 +- 2 -- 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMinus, Left: &ast.BinaryExpression{ @@ -278,7 +278,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("(1 + 2) * 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMul, Left: &ast.BinaryExpression{ @@ -369,7 +369,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("1 < 2 > 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationGreater, Left: &ast.BinaryExpression{ @@ -414,7 +414,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("a ? b : c ? d : e") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ConditionalExpression{ Test: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -460,7 +460,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("true + false") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.BoolExpression{ @@ -489,7 +489,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("(<-x)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationMove, Expression: &ast.IdentifierExpression{ @@ -517,7 +517,7 @@ func TestParseArrayExpression(t *testing.T) { result, errs := testParseExpression("[ 1,2 + 3, 4 , 5 ]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ArrayExpression{ Values: []ast.Expression{ &ast.IntegerExpression{ @@ -585,7 +585,7 @@ func TestParseArrayExpression(t *testing.T) { result, errs := testParseExpression("[ 1 , \n 2 \n , \n\n 3 \n\n\n]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ArrayExpression{ Values: []ast.Expression{ &ast.IntegerExpression{ @@ -632,7 +632,7 @@ func TestParseArrayExpression(t *testing.T) { result, errs := testParseExpression("[\n]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ArrayExpression{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 0, Offset: 0}, @@ -656,7 +656,7 @@ func TestParseDictionaryExpression(t *testing.T) { result, errs := testParseExpression("{ 1:2 + 3, 4 : 5 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryExpression{ Entries: []ast.DictionaryEntry{ { @@ -728,7 +728,7 @@ func TestParseDictionaryExpression(t *testing.T) { result, errs := testParseExpression("{ 1 : 2 , \n 3 \n : \n 4 \n , \n\n 5 \n\n : \n\n 6 \n\n }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryExpression{ Entries: []ast.DictionaryEntry{ { @@ -808,7 +808,7 @@ func TestParseDictionaryExpression(t *testing.T) { result, errs := testParseExpression("{\n}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryExpression{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 0, Offset: 0}, @@ -829,7 +829,7 @@ func TestParseIndexExpression(t *testing.T) { result, errs := testParseExpression("a[0]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IndexExpression{ TargetExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -861,7 +861,7 @@ func TestParseIndexExpression(t *testing.T) { result, errs := testParseExpression("a [ 0 ]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IndexExpression{ TargetExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -893,7 +893,7 @@ func TestParseIndexExpression(t *testing.T) { result, errs := testParseExpression("a [foo]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IndexExpression{ TargetExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -928,7 +928,7 @@ func TestParseIdentifier(t *testing.T) { result, errs := testParseExpression("a + 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IdentifierExpression{ @@ -959,7 +959,7 @@ func TestParsePath(t *testing.T) { result, errs := testParseExpression("/foo/bar") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.PathExpression{ Domain: ast.Identifier{ Identifier: "foo", @@ -986,7 +986,7 @@ func TestParseString(t *testing.T) { result, errs := testParseExpression("\"\"") assert.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "", Range: ast.Range{ @@ -1003,7 +1003,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of string literal: missing '\"'", @@ -1013,7 +1013,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "", Range: ast.Range{ @@ -1030,7 +1030,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"\n") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of string literal: missing '\"'", @@ -1040,7 +1040,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "", Range: ast.Range{ @@ -1056,7 +1056,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"t") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of string literal: missing '\"'", @@ -1066,7 +1066,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "t", Range: ast.Range{ @@ -1083,7 +1083,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"t\n") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of string literal: missing '\"'", @@ -1093,7 +1093,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "t", Range: ast.Range{ @@ -1110,7 +1110,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"\\") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "incomplete escape sequence: missing character after escape character", @@ -1124,7 +1124,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "", Range: ast.Range{ @@ -1143,7 +1143,7 @@ func TestParseString(t *testing.T) { result, errs := testParseExpression(`"te\tst\"te\u{1F3CE}\u{FE0F}xt"`) assert.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te\tst\"te\U0001F3CE\uFE0Fxt", Range: ast.Range{ @@ -1160,7 +1160,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\Xst"`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid escape character: 'X'", @@ -1170,7 +1170,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "test", Range: ast.Range{ @@ -1187,7 +1187,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\u`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "incomplete Unicode escape sequence: missing character '{' after escape character", @@ -1201,7 +1201,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te", Range: ast.Range{ @@ -1218,7 +1218,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\us`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid Unicode escape sequence: expected '{', got 's'", @@ -1232,7 +1232,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te", Range: ast.Range{ @@ -1249,7 +1249,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\u{`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "incomplete Unicode escape sequence: missing character '}' after escape character", @@ -1263,7 +1263,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te", Range: ast.Range{ @@ -1282,7 +1282,7 @@ func TestParseString(t *testing.T) { result, errs := testParseExpression(`"te\u{}"`) assert.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te", Range: ast.Range{ @@ -1309,7 +1309,7 @@ func TestParseString(t *testing.T) { ) assert.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "test JJJJ KKKK LLLL MMMM NNNN OOOO", Range: ast.Range{ @@ -1326,7 +1326,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\u{X}st"`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid Unicode escape sequence: expected hex digit, got 'X'", @@ -1336,7 +1336,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "test", Range: ast.Range{ @@ -1360,7 +1360,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1383,7 +1383,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f ()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1406,7 +1406,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f ( )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1429,7 +1429,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(1)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1466,7 +1466,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(label:1)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1505,7 +1505,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(1,2)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1555,7 +1555,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(a:1,b:2)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1607,7 +1607,7 @@ func TestParseInvocation(t *testing.T) { t.Parallel() _, errs := testParseExpression("f(,,)") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected argument or end of argument list, got ','", @@ -1623,7 +1623,7 @@ func TestParseInvocation(t *testing.T) { t.Parallel() _, errs := testParseExpression("f(1,,)") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected argument or end of argument list, got ','", @@ -1639,7 +1639,7 @@ func TestParseInvocation(t *testing.T) { t.Parallel() _, errs := testParseExpression("f(1 2)") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected argument in argument list (expecting delimiter or end of argument list)," + @@ -1658,7 +1658,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(1,g(2))") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1724,7 +1724,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(1,g(\"test\"))") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1793,7 +1793,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("f.n") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.MemberExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1818,7 +1818,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("f .n") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.MemberExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1841,7 +1841,7 @@ func TestParseMemberExpression(t *testing.T) { t.Parallel() result, errs := testParseExpression("f.") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected member name, got EOF", @@ -1851,7 +1851,7 @@ func TestParseMemberExpression(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.MemberExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1872,7 +1872,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("f.n * 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMul, Left: &ast.MemberExpression{ @@ -1909,7 +1909,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("3 * f.n") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMul, Left: &ast.IntegerExpression{ @@ -1946,7 +1946,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("f?.n") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.MemberExpression{ Optional: true, Expression: &ast.IdentifierExpression{ @@ -1975,7 +1975,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2020,7 +2020,7 @@ func TestParseBlockComment(t *testing.T) { result, errs := testParseExpression(" /* test foo/* bar */ asd*/ true") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BoolExpression{ Value: true, Range: ast.Range{ @@ -2039,7 +2039,7 @@ func TestParseBlockComment(t *testing.T) { result, errs := testParseExpression(" /*test foo*/ /* bar */ true") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BoolExpression{ Value: true, Range: ast.Range{ @@ -2058,7 +2058,7 @@ func TestParseBlockComment(t *testing.T) { result, errs := testParseExpression(" 1/*test foo*/+/* bar */ 2 ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IntegerExpression{ @@ -2089,7 +2089,7 @@ func TestParseBlockComment(t *testing.T) { t.Parallel() _, errs := testParseExpression(" /* test foo/* bar */ asd*/ true */ bar") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ // `true */ bar` is parsed as infix operation of path &SyntaxError{ @@ -2110,7 +2110,7 @@ func TestParseBlockComment(t *testing.T) { t.Parallel() _, errs := testParseExpression(" /* test foo/* bar */ asd true ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ // `true */ bar` is parsed as infix operation of path &SyntaxError{ @@ -2185,7 +2185,7 @@ func TestParseBlockComment(t *testing.T) { }, Config{}, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token identifier in block comment", @@ -2244,7 +2244,7 @@ func TestParseReference(t *testing.T) { result, errs := testParseExpression("& t as T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2265,7 +2265,7 @@ func TestParseReference(t *testing.T) { const code = `&y[z]` _, errs := testParseExpression(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected casting expression", @@ -2287,7 +2287,7 @@ func TestParseReference(t *testing.T) { const code = `&x[y]? as &Z?` _, errs := testParseExpression(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected casting expression", @@ -2312,7 +2312,7 @@ func TestParseNilCoelesceReference(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationNilCoalesce, Left: &ast.ReferenceExpression{ @@ -2394,7 +2394,7 @@ func TestParseCasts(t *testing.T) { result, errs := testParseExpression(" t as T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.CastingExpression{ Operation: ast.OperationCast, Expression: &ast.IdentifierExpression{ @@ -2424,7 +2424,7 @@ func TestParseCasts(t *testing.T) { result, errs := testParseExpression(" t as? T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.CastingExpression{ Operation: ast.OperationFailableCast, Expression: &ast.IdentifierExpression{ @@ -2455,7 +2455,7 @@ func TestParseCasts(t *testing.T) { result, errs := testParseExpression(" t as! T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.CastingExpression{ Operation: ast.OperationForceCast, Expression: &ast.IdentifierExpression{ @@ -2490,7 +2490,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseExpression("t!") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ForceExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2511,7 +2511,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseExpression(" t ! ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ForceExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2532,7 +2532,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseExpression("<-t!") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationMove, Expression: &ast.ForceExpression{ @@ -2557,7 +2557,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseExpression("10 * t!") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMul, Left: &ast.IntegerExpression{ @@ -2589,7 +2589,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseStatements("x\n!y") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.IdentifierExpression{ @@ -2623,7 +2623,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseStatements("x\n.y!") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.ForceExpression{ @@ -2653,7 +2653,7 @@ func TestParseForceExpression(t *testing.T) { t.Parallel() result, errs := testParseStatements("x. y") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid whitespace after '.'", @@ -2663,7 +2663,7 @@ func TestParseForceExpression(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.MemberExpression{ @@ -2697,7 +2697,7 @@ func TestParseCreate(t *testing.T) { result, errs := testParseExpression("create T()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.CreateExpression{ InvocationExpression: &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ @@ -2723,7 +2723,7 @@ func TestParseNil(t *testing.T) { result, errs := testParseExpression(" nil") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.NilExpression{ Pos: ast.Position{Line: 1, Column: 1, Offset: 1}, }, @@ -2742,7 +2742,7 @@ func TestParseDestroy(t *testing.T) { result, errs := testParseExpression("destroy t") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DestroyExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2768,7 +2768,7 @@ func TestParseAttach(t *testing.T) { result, errs := testParseExpression("attach E() to r") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.AttachExpression{ Base: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2797,7 +2797,7 @@ func TestParseAttach(t *testing.T) { t.Parallel() _, errs := testParseExpression("attach A to E") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '('", @@ -2815,7 +2815,7 @@ func TestParseAttach(t *testing.T) { result, errs := testParseExpression("attach A() to attach B() to r") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.AttachExpression{ Base: &ast.AttachExpression{ Base: &ast.IdentifierExpression{ @@ -2857,7 +2857,7 @@ func TestParseAttach(t *testing.T) { t.Parallel() _, errs := testParseExpression("attach A()") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected 'to', got EOF", @@ -2873,7 +2873,7 @@ func TestParseAttach(t *testing.T) { t.Parallel() _, errs := testParseExpression("attach E() to") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected end of program", @@ -2892,7 +2892,7 @@ func TestParseLineComment(t *testing.T) { result, errs := testParseExpression(" //// // this is a comment\n 1 / 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationDiv, Left: &ast.IntegerExpression{ @@ -2929,7 +2929,7 @@ func TestParseFunctionExpression(t *testing.T) { result, errs := testParseExpression("fun () { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionExpression{ ParameterList: &ast.ParameterList{ Parameters: nil, @@ -2959,7 +2959,7 @@ func TestParseFunctionExpression(t *testing.T) { result, errs := testParseExpression("fun (): X { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionExpression{ ParameterList: &ast.ParameterList{ Parameters: nil, @@ -3001,7 +3001,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0b`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing digits", @@ -3020,7 +3020,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b"), Value: new(big.Int), @@ -3041,7 +3041,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0b101010`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b101010"), Value: big.NewInt(42), @@ -3060,7 +3060,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0b001000`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b001000"), Value: big.NewInt(8), @@ -3081,7 +3081,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0b101010_101010`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b101010_101010"), Value: big.NewInt(2730), @@ -3100,7 +3100,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0b_101010_101010`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0b_101010_101010", @@ -3115,7 +3115,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b_101010_101010"), Value: big.NewInt(2730), @@ -3134,7 +3134,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0b101010_101010_`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0b101010_101010_", @@ -3149,7 +3149,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b101010_101010_"), Value: big.NewInt(2730), @@ -3168,7 +3168,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0o`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing digits", @@ -3187,7 +3187,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o"), Value: new(big.Int), @@ -3208,7 +3208,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0o32`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o32"), Value: big.NewInt(26), @@ -3229,7 +3229,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0o32_45`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o32_45"), Value: big.NewInt(1701), @@ -3248,7 +3248,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0o_32_45`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0o_32_45", @@ -3263,7 +3263,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o_32_45"), Value: big.NewInt(1701), @@ -3282,7 +3282,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0o32_45_`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0o32_45_", @@ -3297,7 +3297,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o32_45_"), Value: big.NewInt(1701), @@ -3318,7 +3318,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`1234567890`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("1234567890"), Value: big.NewInt(1234567890), @@ -3339,7 +3339,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`1_234_567_890`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("1_234_567_890"), Value: big.NewInt(1234567890), @@ -3358,7 +3358,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`1_234_567_890_`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "1_234_567_890_", @@ -3373,7 +3373,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("1_234_567_890_"), Value: big.NewInt(1234567890), @@ -3392,7 +3392,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0x`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing digits", @@ -3411,7 +3411,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0x"), Value: new(big.Int), @@ -3432,7 +3432,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0xf2`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0xf2"), Value: big.NewInt(242), @@ -3453,7 +3453,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0xf2_09`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0xf2_09"), Value: big.NewInt(61961), @@ -3472,7 +3472,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0x_f2_09`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0x_f2_09", @@ -3487,7 +3487,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0x_f2_09"), Value: big.NewInt(61961), @@ -3506,7 +3506,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0xf2_09_`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: `0xf2_09_`, @@ -3521,7 +3521,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0xf2_09_"), Value: big.NewInt(61961), @@ -3542,7 +3542,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0"), Value: big.NewInt(0), @@ -3563,7 +3563,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`01`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("01"), Value: big.NewInt(1), @@ -3584,7 +3584,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`09`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("09"), Value: big.NewInt(9), @@ -3605,7 +3605,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression("00123") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("00123"), Value: big.NewInt(123), @@ -3624,7 +3624,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0z123`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid number literal prefix: 'z'", @@ -3643,7 +3643,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0z123"), Value: new(big.Int), @@ -3664,7 +3664,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0_100`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0_100"), Value: big.NewInt(100), @@ -3685,7 +3685,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`1_100`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("1_100"), Value: big.NewInt(1100), @@ -3708,7 +3708,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`_100`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IdentifierExpression{ Identifier: ast.Identifier{ Identifier: "_100", @@ -3731,7 +3731,7 @@ func TestParseFixedPoint(t *testing.T) { result, errs := testParseExpression("1234_5678_90.0009_8765_4321") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FixedPointExpression{ PositiveLiteral: []byte("1234_5678_90.0009_8765_4321"), Negative: false, @@ -3754,7 +3754,7 @@ func TestParseFixedPoint(t *testing.T) { result, errs := testParseExpression("0.1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FixedPointExpression{ PositiveLiteral: []byte("0.1"), Negative: false, @@ -3775,7 +3775,7 @@ func TestParseFixedPoint(t *testing.T) { t.Parallel() result, errs := testParseExpression("0.") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing fractional digits", @@ -3785,7 +3785,7 @@ func TestParseFixedPoint(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FixedPointExpression{ PositiveLiteral: []byte("0."), Negative: false, @@ -3813,7 +3813,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("1 < 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationLess, Left: &ast.IntegerExpression{ @@ -3846,7 +3846,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a < > ()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -3870,7 +3870,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a < { K : V } > ( 1 )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -3930,7 +3930,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a < { K : V } , @R , [ S ] > ( 1 , 2 )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -4028,7 +4028,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("1 + a<>()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IntegerExpression{ @@ -4064,7 +4064,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a>()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -4114,7 +4114,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a >()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -4164,7 +4164,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("0 + 1 < 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationLess, Left: &ast.BinaryExpression{ @@ -4209,7 +4209,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("0 + 1 << 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationBitwiseLeftShift, Left: &ast.BinaryExpression{ @@ -4254,7 +4254,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("0 + 1 > 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationGreater, Left: &ast.BinaryExpression{ @@ -4299,7 +4299,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("0 + 1 >> 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationBitwiseRightShift, Left: &ast.BinaryExpression{ @@ -4348,7 +4348,7 @@ func TestParseBoolExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4385,7 +4385,7 @@ func TestParseIdentifierExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4421,7 +4421,7 @@ func TestParseArrayExpressionInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4476,7 +4476,7 @@ func TestParseDictionaryExpressionInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4549,7 +4549,7 @@ func TestParseInvocationExpressionWithoutLabels(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4617,7 +4617,7 @@ func TestParseInvocationExpressionWithLabels(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4704,7 +4704,7 @@ func TestParseOptionalMemberExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4748,7 +4748,7 @@ func TestParseIndexExpressionInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4799,7 +4799,7 @@ func TestParseUnaryExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4839,7 +4839,7 @@ func TestParseOrExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4886,7 +4886,7 @@ func TestParseAndExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4933,7 +4933,7 @@ func TestParseEqualityExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4980,7 +4980,7 @@ func TestParseRelationalExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5031,7 +5031,7 @@ func TestParseAdditiveExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5082,7 +5082,7 @@ func TestParseMultiplicativeExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5133,7 +5133,7 @@ func TestParseFunctionExpressionAndReturn(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5207,7 +5207,7 @@ func TestParseLeftAssociativity(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5270,7 +5270,7 @@ func TestParseNegativeInteger(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5309,7 +5309,7 @@ func TestParseNegativeFixedPoint(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5352,7 +5352,7 @@ func TestParseTernaryRightAssociativity(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5455,7 +5455,7 @@ func TestParseVoidLiteral(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5501,7 +5501,7 @@ func TestParseMissingReturnType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5643,7 +5643,7 @@ func TestParseExpression(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, actual) + AssertEqualWithDiff(t, expected, actual) } func TestParseStringEscapes(t *testing.T) { @@ -5671,7 +5671,7 @@ func TestParseStringEscapes(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, actual) + AssertEqualWithDiff(t, expected, actual) } func TestParseStringWithUnicode(t *testing.T) { @@ -5699,7 +5699,7 @@ func TestParseStringWithUnicode(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, actual) + AssertEqualWithDiff(t, expected, actual) } func TestParseNilCoalescing(t *testing.T) { @@ -5712,7 +5712,7 @@ func TestParseNilCoalescing(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5758,7 +5758,7 @@ func TestParseNilCoalescingRightAssociativity(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5861,7 +5861,7 @@ func TestParseFailableCasting(t *testing.T) { failableDowncast.ParentVariableDeclaration = variableDeclaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ variableDeclaration, }, @@ -5879,7 +5879,7 @@ func TestParseMoveOperator(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5937,7 +5937,7 @@ func TestParseFunctionExpressionWithResourceTypeAnnotation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ @@ -6046,7 +6046,7 @@ func TestParseFailableCastingResourceTypeAnnotation(t *testing.T) { failableDowncast.ParentVariableDeclaration = variableDeclaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ variableDeclaration, }, @@ -6100,7 +6100,7 @@ func TestParseCasting(t *testing.T) { cast.ParentVariableDeclaration = variableDeclaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ variableDeclaration, }, @@ -6131,7 +6131,7 @@ func TestParseReferenceInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6189,7 +6189,7 @@ func TestParseFixedPointExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6229,7 +6229,7 @@ func TestParseFixedPointExpressionZeroInteger(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6269,7 +6269,7 @@ func TestParsePathLiteral(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6309,7 +6309,7 @@ func TestParseBitwiseExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, diff --git a/old_parser/lexer/lexer_test.go b/old_parser/lexer/lexer_test.go index 1e48fed700..be9ee63f08 100644 --- a/old_parser/lexer/lexer_test.go +++ b/old_parser/lexer/lexer_test.go @@ -28,7 +28,7 @@ import ( "go.uber.org/goleak" "github.com/onflow/cadence/ast" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestMain(m *testing.M) { @@ -64,7 +64,7 @@ func testLex(t *testing.T, input string, expected []token) { bytes := []byte(input) withTokens(Lex(bytes, nil), func(actualTokens []Token) { - utils.AssertEqualWithDiff(t, expectedTokens, actualTokens) + AssertEqualWithDiff(t, expectedTokens, actualTokens) require.Len(t, actualTokens, len(expectedTokens)) for i, expectedToken := range expected { diff --git a/old_parser/parser_test.go b/old_parser/parser_test.go index 156ae7c286..ecff29407f 100644 --- a/old_parser/parser_test.go +++ b/old_parser/parser_test.go @@ -33,7 +33,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/parser/lexer" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestMain(m *testing.M) { @@ -240,7 +240,7 @@ func TestParseBuffering(t *testing.T) { Config{}, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token identifier with string value c", @@ -483,7 +483,7 @@ func TestParseBuffering(t *testing.T) { Config{}, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token identifier with string value d", @@ -511,7 +511,7 @@ func TestParseBuffering(t *testing.T) { } ` _, err := testParseProgram(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token identifier", @@ -536,7 +536,7 @@ func TestParseBuffering(t *testing.T) { ` _, err := testParseProgram(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token identifier", @@ -703,7 +703,7 @@ func TestParseArgumentList(t *testing.T) { t.Parallel() _, errs := testParseArgumentList(`xyz`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '('", @@ -722,7 +722,7 @@ func TestParseArgumentList(t *testing.T) { var expected ast.Arguments - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -747,7 +747,7 @@ func TestParseArgumentList(t *testing.T) { result, errs := testParseArgumentList(`(1, b: true)`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.Arguments{ { Label: "", @@ -832,7 +832,7 @@ func TestParseBufferedErrors(t *testing.T) { // there is another error (missing closing parenthesis after). _, errs := testParseExpression("a(") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing type annotation after comma", @@ -871,7 +871,7 @@ func TestParseExpressionDepthLimit(t *testing.T) { _, err := testParseProgram(code) require.Error(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ ExpressionDepthLimitReachedError{ Pos: ast.Position{ @@ -907,7 +907,7 @@ func TestParseTypeDepthLimit(t *testing.T) { _, err := testParseProgram(code) require.Error(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ TypeDepthLimitReachedError{ Pos: ast.Position{ @@ -933,7 +933,7 @@ func TestParseLocalReplayLimit(t *testing.T) { code := []byte(builder.String()) _, err := ParseProgram(nil, code, Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, Error{ Code: code, Errors: []error{ @@ -968,7 +968,7 @@ func TestParseGlobalReplayLimit(t *testing.T) { code := []byte(builder.String()) _, err := ParseProgram(nil, code, Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, Error{ Code: code, Errors: []error{ diff --git a/old_parser/statement_test.go b/old_parser/statement_test.go index e22d1c2b94..ce5d17d25d 100644 --- a/old_parser/statement_test.go +++ b/old_parser/statement_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/ast" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestParseReplInput(t *testing.T) { @@ -63,7 +63,7 @@ func TestParseReturnStatement(t *testing.T) { result, errs := testParseStatements("return") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ReturnStatement{ Range: ast.Range{ @@ -83,7 +83,7 @@ func TestParseReturnStatement(t *testing.T) { result, errs := testParseStatements("return 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ReturnStatement{ Expression: &ast.IntegerExpression{ @@ -112,7 +112,7 @@ func TestParseReturnStatement(t *testing.T) { result, errs := testParseStatements("return \n1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ReturnStatement{ Range: ast.Range{ @@ -143,7 +143,7 @@ func TestParseReturnStatement(t *testing.T) { result, errs := testParseStatements("return ;\n1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ReturnStatement{ Range: ast.Range{ @@ -179,7 +179,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -210,7 +210,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true { 1 ; 2 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -264,7 +264,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true { 1 \n 2 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -318,7 +318,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true { 1 } else { 2 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -380,7 +380,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true{1}else if true {2} else{3}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -514,7 +514,7 @@ func TestParseIfStatement(t *testing.T) { expected.Test.(*ast.VariableDeclaration).ParentIfStatement = expected - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ expected, }, @@ -564,7 +564,7 @@ func TestParseIfStatement(t *testing.T) { expected.Test.(*ast.VariableDeclaration).ParentIfStatement = expected - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ expected, }, @@ -585,7 +585,7 @@ func TestParseWhileStatement(t *testing.T) { result, errs := testParseStatements("while true { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.WhileStatement{ Test: &ast.BoolExpression{ @@ -621,7 +621,7 @@ func TestParseAssignmentStatement(t *testing.T) { result, errs := testParseStatements("x=1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.AssignmentStatement{ Target: &ast.IdentifierExpression{ @@ -656,7 +656,7 @@ func TestParseAssignmentStatement(t *testing.T) { result, errs := testParseStatements(" x = 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.AssignmentStatement{ Target: &ast.IdentifierExpression{ @@ -691,7 +691,7 @@ func TestParseAssignmentStatement(t *testing.T) { result, errs := testParseStatements(" x <- 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.AssignmentStatement{ Target: &ast.IdentifierExpression{ @@ -726,7 +726,7 @@ func TestParseAssignmentStatement(t *testing.T) { result, errs := testParseStatements(" x <-! 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.AssignmentStatement{ Target: &ast.IdentifierExpression{ @@ -766,7 +766,7 @@ func TestParseSwapStatement(t *testing.T) { result, errs := testParseStatements(" x <-> y") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.SwapStatement{ Left: &ast.IdentifierExpression{ @@ -799,7 +799,7 @@ func TestParseForStatement(t *testing.T) { result, errs := testParseStatements("for x in y { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ForStatement{ Identifier: ast.Identifier{ @@ -838,7 +838,7 @@ func TestParseForStatementIndexBinding(t *testing.T) { result, errs := testParseStatements("for i, x in y { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ForStatement{ Identifier: ast.Identifier{ @@ -874,7 +874,7 @@ func TestParseForStatementIndexBinding(t *testing.T) { t.Parallel() _, errs := testParseStatements("for i x in y { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected keyword \"in\", got identifier", @@ -894,7 +894,7 @@ func TestParseForStatementIndexBinding(t *testing.T) { t.Parallel() _, errs := testParseStatements("for in y { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected identifier, got keyword \"in\"", @@ -921,7 +921,7 @@ func TestParseEmit(t *testing.T) { result, errs := testParseStatements("emit T()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.EmitStatement{ InvocationExpression: &ast.InvocationExpression{ @@ -953,7 +953,7 @@ func TestParseFunctionStatementOrExpression(t *testing.T) { result, errs := testParseStatements("fun foo() {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -989,7 +989,7 @@ func TestParseFunctionStatementOrExpression(t *testing.T) { result, errs := testParseStatements("fun () {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.FunctionExpression{ @@ -1027,7 +1027,7 @@ func TestParseStatements(t *testing.T) { result, errs := testParseStatements("a + b < c\nd") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.BinaryExpression{ @@ -1073,7 +1073,7 @@ func TestParseStatements(t *testing.T) { t.Parallel() result, errs := testParseStatements(`assert true`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "statements on the same line must be separated with a semicolon", @@ -1083,7 +1083,7 @@ func TestParseStatements(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.IdentifierExpression{ @@ -1119,7 +1119,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { result, errs := testParseStatements("remove A from b") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.RemoveStatement{ Attachment: &ast.NominalType{ @@ -1148,7 +1148,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { result, errs := testParseStatements("remove Foo.E from b") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.RemoveStatement{ Attachment: &ast.NominalType{ @@ -1182,7 +1182,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { _, errs := testParseStatements("remove A") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected from keyword, got EOF", @@ -1203,7 +1203,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { _, errs := testParseStatements("remove A from") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected end of program", @@ -1220,7 +1220,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { _, errs := testParseStatements("remove [A] from e") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected attachment nominal type, got [A]", @@ -1238,7 +1238,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { result, errs := testParseStatements("remove A from foo()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.RemoveStatement{ Attachment: &ast.NominalType{ @@ -1276,7 +1276,7 @@ func TestParseSwitchStatement(t *testing.T) { result, errs := testParseStatements("switch true { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.SwitchStatement{ Expression: &ast.BoolExpression{ @@ -1304,7 +1304,7 @@ func TestParseSwitchStatement(t *testing.T) { result, errs := testParseStatements("switch x { case 1 :\n a\nb default : c\nd }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.SwitchStatement{ Expression: &ast.IdentifierExpression{ @@ -1402,7 +1402,7 @@ func TestParseIfStatementInFunctionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1604,7 +1604,7 @@ func TestParseIfStatementWithVariableDeclaration(t *testing.T) { ifStatement.Test = ifTestVariableDeclaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1650,7 +1650,7 @@ func TestParseIfStatementNoElse(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1722,7 +1722,7 @@ func TestParseWhileStatementInFunctionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1802,7 +1802,7 @@ func TestParseForStatementInFunctionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1864,7 +1864,7 @@ func TestParseAssignment(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1928,7 +1928,7 @@ func TestParseAccessAssignment(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2041,7 +2041,7 @@ func TestParseExpressionStatementWithAccess(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2143,7 +2143,7 @@ func TestParseMoveStatement(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2205,7 +2205,7 @@ func TestParseFunctionExpressionStatementAfterVariableDeclarationWithCreateExpre result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2308,7 +2308,7 @@ func TestParseExpressionStatementAfterReturnStatement(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2369,7 +2369,7 @@ func TestParseSwapStatementInFunctionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, diff --git a/old_parser/type_test.go b/old_parser/type_test.go index 814a51b813..7e9bcdf1dc 100644 --- a/old_parser/type_test.go +++ b/old_parser/type_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestParseNominalType(t *testing.T) { @@ -41,7 +41,7 @@ func TestParseNominalType(t *testing.T) { result, errs := testParseType("Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.NominalType{ Identifier: ast.Identifier{ Identifier: "Int", @@ -59,7 +59,7 @@ func TestParseNominalType(t *testing.T) { result, errs := testParseType("Foo.Bar") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.NominalType{ Identifier: ast.Identifier{ Identifier: "Foo", @@ -88,7 +88,7 @@ func TestParseArrayType(t *testing.T) { result, errs := testParseType("[Int]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.VariableSizedType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -112,7 +112,7 @@ func TestParseArrayType(t *testing.T) { result, errs := testParseType("[Int ; 2 ]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ConstantSizedType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -143,7 +143,7 @@ func TestParseArrayType(t *testing.T) { t.Parallel() result, errs := testParseType("[Int ; -2 ]") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: `expected positive integer size for constant sized type`, @@ -166,7 +166,7 @@ func TestParseArrayType(t *testing.T) { t.Parallel() result, errs := testParseType("[Int ; X ]") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: `expected positive integer size for constant sized type`, @@ -176,7 +176,7 @@ func TestParseArrayType(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.VariableSizedType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -206,7 +206,7 @@ func TestParseOptionalType(t *testing.T) { result, errs := testParseType("Int?") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.OptionalType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -227,7 +227,7 @@ func TestParseOptionalType(t *testing.T) { result, errs := testParseType("Int??") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.OptionalType{ Type: &ast.OptionalType{ Type: &ast.NominalType{ @@ -251,7 +251,7 @@ func TestParseOptionalType(t *testing.T) { result, errs := testParseType("Int???") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.OptionalType{ Type: &ast.OptionalType{ Type: &ast.OptionalType{ @@ -283,7 +283,7 @@ func TestParseReferenceType(t *testing.T) { result, errs := testParseType("&Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceType{ Authorization: nil, Type: &ast.NominalType{ @@ -305,7 +305,7 @@ func TestParseReferenceType(t *testing.T) { result, errs := testParseType("auth &Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceType{ Authorization: nil, LegacyAuthorized: true, @@ -333,7 +333,7 @@ func TestParseOptionalReferenceType(t *testing.T) { result, errs := testParseType("&Int?") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.OptionalType{ Type: &ast.ReferenceType{ Authorization: nil, @@ -363,7 +363,7 @@ func TestParseRestrictedType(t *testing.T) { result, errs := testParseType("T{}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntersectionType{ LegacyRestrictedType: &ast.NominalType{ NestedIdentifiers: nil, @@ -388,7 +388,7 @@ func TestParseRestrictedType(t *testing.T) { result, errs := testParseType("T{U}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntersectionType{ LegacyRestrictedType: &ast.NominalType{ NestedIdentifiers: nil, @@ -421,7 +421,7 @@ func TestParseRestrictedType(t *testing.T) { result, errs := testParseType("T{U , V }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntersectionType{ LegacyRestrictedType: &ast.NominalType{ NestedIdentifiers: nil, @@ -460,7 +460,7 @@ func TestParseRestrictedType(t *testing.T) { result, errs := testParseType("{}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntersectionType{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 0, Offset: 0}, @@ -478,7 +478,7 @@ func TestParseRestrictedType(t *testing.T) { result, errs := testParseType("{ T }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntersectionType{ Types: []*ast.NominalType{ { @@ -502,7 +502,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("{ T , }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing type after comma", @@ -512,7 +512,7 @@ func TestParseRestrictedType(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntersectionType{ Types: []*ast.NominalType{ { @@ -536,7 +536,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("{ T U }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected type", @@ -555,7 +555,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("{ T , U : V }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in restricted type", @@ -574,7 +574,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("T{U , V : W }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: `unexpected token: got ':', expected ',' or '}'`, @@ -593,7 +593,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("{[T]}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "non-nominal type in restriction list: [T]", @@ -612,7 +612,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("T{[U]}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected non-nominal type: [U]", @@ -631,7 +631,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("{T, [U]}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "non-nominal type in restriction list: [U]", @@ -650,7 +650,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("T{U, [V]}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected non-nominal type: [V]", @@ -669,7 +669,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("{") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected type", @@ -687,7 +687,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("T{") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected type", @@ -705,7 +705,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("{U") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected '}'", @@ -723,7 +723,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("T{U") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected '}'", @@ -741,7 +741,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("{U,") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected type", @@ -759,7 +759,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("T{U,") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected type", @@ -777,7 +777,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("{,}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected comma in restricted type", @@ -795,7 +795,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("T{,}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected comma", @@ -820,7 +820,7 @@ func TestParseDictionaryType(t *testing.T) { result, errs := testParseType("{T: U}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryType{ KeyType: &ast.NominalType{ Identifier: ast.Identifier{ @@ -848,7 +848,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing dictionary value type", @@ -858,7 +858,7 @@ func TestParseDictionaryType(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryType{ KeyType: &ast.NominalType{ Identifier: ast.Identifier{ @@ -881,7 +881,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{:}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in dictionary type", @@ -899,7 +899,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{:U}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in dictionary type", @@ -918,7 +918,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:U,}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected comma in dictionary type", @@ -937,7 +937,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:U:}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in dictionary type", @@ -956,7 +956,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T::U}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in dictionary type", @@ -975,7 +975,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected type", @@ -993,7 +993,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:U") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected '}'", @@ -1018,7 +1018,7 @@ func TestParseFunctionType(t *testing.T) { result, errs := testParseType("(():Void)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionType{ ParameterTypeAnnotations: nil, ReturnTypeAnnotation: &ast.TypeAnnotation{ @@ -1047,7 +1047,7 @@ func TestParseFunctionType(t *testing.T) { result, errs := testParseType("( ( String , Bool , @R ) : Int)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionType{ ParameterTypeAnnotations: []*ast.TypeAnnotation{ { @@ -1112,7 +1112,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T<>") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1134,7 +1134,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1168,7 +1168,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T< U >") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1202,7 +1202,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T< U , @V >") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1246,7 +1246,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1280,7 +1280,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T< U< V > >") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1334,7 +1334,7 @@ func TestParseParametersAndArrayTypes(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessAll, @@ -1483,7 +1483,7 @@ func TestParseDictionaryTypeInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -1805,7 +1805,7 @@ func TestParseIntegerTypes(t *testing.T) { StartPos: ast.Position{Offset: 137, Line: 9, Column: 2}, } - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{a, b, c, d, e, f, g, h}, result.Declarations(), ) @@ -1821,7 +1821,7 @@ func TestParseFunctionTypeInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -1899,7 +1899,7 @@ func TestParseFunctionArrayType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -1983,7 +1983,7 @@ func TestParseFunctionTypeWithArrayReturnType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2066,7 +2066,7 @@ func TestParseFunctionTypeWithFunctionReturnTypeInParentheses(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2156,7 +2156,7 @@ func TestParseFunctionTypeWithFunctionReturnType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2246,7 +2246,7 @@ func TestParseOptionalTypeDouble(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2301,7 +2301,7 @@ func TestParseFunctionTypeWithResourceTypeAnnotation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2358,7 +2358,7 @@ func TestParseReferenceTypeInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2419,7 +2419,7 @@ func TestParseOptionalReference(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2474,7 +2474,7 @@ func TestParseRestrictedReferenceTypeWithBaseType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2541,7 +2541,7 @@ func TestParseRestrictedReferenceTypeWithoutBaseType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2601,7 +2601,7 @@ func TestParseOptionalRestrictedType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2668,7 +2668,7 @@ func TestParseOptionalRestrictedTypeOnlyRestrictions(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2728,7 +2728,7 @@ func TestParseAuthorizedReferenceType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2783,7 +2783,7 @@ func TestParseInstantiationTypeInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2859,7 +2859,7 @@ func TestParseConstantSizedSizedArrayWithTrailingUnderscoreSize(t *testing.T) { let T:[d;0_]=0 `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0_", diff --git a/parser/declaration_test.go b/parser/declaration_test.go index 2f27396cbd..681d5cb593 100644 --- a/parser/declaration_test.go +++ b/parser/declaration_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestParseVariableDeclaration(t *testing.T) { @@ -43,7 +43,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations("var x = 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -79,7 +79,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations(" access(all) var x = 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Value: &ast.IntegerExpression{ @@ -136,7 +136,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations("let x = 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -172,7 +172,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations("let x <- 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -208,7 +208,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations("let r2: @R <- r") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -251,7 +251,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseStatements("var x <- y <- z") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -292,7 +292,7 @@ func TestParseVariableDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("view var x = 1") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid view modifier for variable", @@ -314,7 +314,7 @@ func TestParseVariableDeclaration(t *testing.T) { StaticModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for variable", @@ -330,7 +330,7 @@ func TestParseVariableDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("static var x = 1") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -352,7 +352,7 @@ func TestParseVariableDeclaration(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for variable", @@ -368,7 +368,7 @@ func TestParseVariableDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("native var x = 1") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -402,7 +402,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse("()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 0, Offset: 0}, @@ -420,7 +420,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse(" ( )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 1, Offset: 1}, @@ -438,7 +438,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse("( a : Int )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Parameters: []*ast.Parameter{ { @@ -476,7 +476,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse("( a b : Int )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Parameters: []*ast.Parameter{ { @@ -514,7 +514,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse("( a b : Int , c : Int )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Parameters: []*ast.Parameter{ { @@ -568,7 +568,7 @@ func TestParseParameterList(t *testing.T) { t.Parallel() _, errs := parse("( a b : Int c : Int )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &MissingCommaInParameterListError{ Pos: ast.Position{Offset: 14, Line: 1, Column: 14}, @@ -590,7 +590,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("fun foo () { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -628,7 +628,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("access(all) fun foo () { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ ParameterList: &ast.ParameterList{ @@ -688,7 +688,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("fun foo (): X { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -747,7 +747,7 @@ func TestParseFunctionDeclaration(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -870,7 +870,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("/// Test\nfun foo() {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -908,7 +908,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("\n /// First line\n \n/// Second line\n\n\nfun foo() {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -946,7 +946,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("\n /** Cool dogs.\n\n Cool cats!! */\n\n\nfun foo() {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -989,7 +989,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("fun main(): Int{ return 1 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1052,7 +1052,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("view fun foo (): X { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1105,7 +1105,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1154,7 +1154,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("native fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1178,7 +1178,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1215,7 +1215,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("static fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1240,7 +1240,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1277,7 +1277,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("static native fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1300,7 +1300,7 @@ func TestParseFunctionDeclaration(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier after native modifier", @@ -1317,7 +1317,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("native static fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1342,7 +1342,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Purity: 0, @@ -1408,7 +1408,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("access(all) static native fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1436,7 +1436,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1486,7 +1486,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1543,7 +1543,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1608,7 +1608,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected '(' as start of parameter list, got '<'", @@ -1631,7 +1631,7 @@ func TestParseFunctionDeclaration(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing '>' at end of type parameter list", @@ -1654,7 +1654,7 @@ func TestParseFunctionDeclaration(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &MissingCommaInParameterListError{ Pos: ast.Position{Offset: 13, Line: 1, Column: 13}, @@ -1686,7 +1686,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( all )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessAll, result, ) @@ -1699,7 +1699,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( account )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessAccount, result, ) @@ -1712,7 +1712,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( contract )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessContract, result, ) @@ -1725,7 +1725,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( self )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessSelf, result, ) @@ -1736,7 +1736,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected keyword \"all\", \"account\", \"contract\", or \"self\", got EOF", @@ -1746,7 +1746,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1757,7 +1757,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( self ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token ')'", @@ -1767,7 +1767,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1780,7 +1780,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( foo )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.EntitlementAccess{ EntitlementSet: &ast.ConjunctiveEntitlementSet{ Elements: []*ast.NominalType{ @@ -1804,7 +1804,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( foo , bar )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.EntitlementAccess{ EntitlementSet: &ast.ConjunctiveEntitlementSet{ Elements: []*ast.NominalType{ @@ -1834,7 +1834,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( foo | bar )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.EntitlementAccess{ EntitlementSet: &ast.DisjunctiveEntitlementSet{ Elements: []*ast.NominalType{ @@ -1862,7 +1862,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( foo | bar , baz )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: got ',', expected '|' or ')'", @@ -1872,7 +1872,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1883,7 +1883,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( foo , bar | baz )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: got '|', expected ',' or ')'", @@ -1893,7 +1893,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1904,7 +1904,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( self , bar )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token ')'", @@ -1914,7 +1914,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1925,7 +1925,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( self | bar )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token ')'", @@ -1935,7 +1935,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1946,7 +1946,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( foo , self )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected non-nominal type: self", @@ -1956,7 +1956,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1967,7 +1967,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( foo | self )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected non-nominal type: self", @@ -1977,7 +1977,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1988,7 +1988,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( foo bar )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected entitlement separator identifier", @@ -1998,7 +1998,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -2009,7 +2009,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( foo & bar )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected entitlement separator '&'", @@ -2019,7 +2019,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -2032,7 +2032,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( mapping foo )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.MappedAccess{ EntitlementMap: &ast.NominalType{ Identifier: ast.Identifier{ @@ -2051,7 +2051,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( mapping )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in type: ')'", @@ -2061,7 +2061,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -2078,7 +2078,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected end in import declaration: expected string, address, or identifier", @@ -2090,7 +2090,7 @@ func TestParseImportDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -2103,7 +2103,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import "foo"`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -2126,7 +2126,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import 0x42`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -2149,7 +2149,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import 0x10000000000000001`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "address too large", @@ -2173,7 +2173,7 @@ func TestParseImportDeclaration(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -2184,7 +2184,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import 1`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in import declaration: " + @@ -2197,7 +2197,7 @@ func TestParseImportDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -2211,7 +2211,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import foo from "bar"`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -2237,7 +2237,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import foo "bar"`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in import declaration: " + @@ -2250,7 +2250,7 @@ func TestParseImportDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -2263,7 +2263,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import foo , bar , baz from 0x42`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -2299,7 +2299,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import foo , bar , from 0x42`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: `expected identifier, got keyword "from"`, @@ -2311,7 +2311,7 @@ func TestParseImportDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -2321,7 +2321,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(`import foo, , bar from 0xaaaa`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 12, Offset: 12}, @@ -2332,7 +2332,7 @@ func TestParseImportDeclaration(t *testing.T) { ) var expected []ast.Declaration - utils.AssertEqualWithDiff(t, expected, result) + AssertEqualWithDiff(t, expected, result) }) t.Run("no identifiers, identifier location", func(t *testing.T) { @@ -2342,7 +2342,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import foo`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -2363,7 +2363,7 @@ func TestParseImportDeclaration(t *testing.T) { _, errs := testParseDeclarations(`import foo, bar, baz, @ from 0x42`) - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 22, Offset: 22}, Message: `unexpected token in import declaration: got '@', expected keyword "from" or ','`, @@ -2381,7 +2381,7 @@ func TestParseImportDeclaration(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -2444,7 +2444,7 @@ func TestParseEvent(t *testing.T) { result, errs := testParseDeclarations("event E()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -2487,7 +2487,7 @@ func TestParseEvent(t *testing.T) { result, errs := testParseDeclarations(" access(self) event E2 ( a : Int , b : String )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Members: ast.NewUnmeteredMembers( @@ -2620,7 +2620,7 @@ func TestParseEvent(t *testing.T) { result, errs := testParseDeclarations(` access(all) event ResourceDestroyed ( a : String = "foo")`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Members: ast.NewUnmeteredMembers( @@ -2735,7 +2735,7 @@ func TestParseEvent(t *testing.T) { _, errs := testParseDeclarations(" access(all) event ResourceDestroyed ( a : Int )") - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 47, Offset: 47}, Message: "expected a default argument after type annotation, got ')'", @@ -2749,7 +2749,7 @@ func TestParseEvent(t *testing.T) { _, errs := testParseDeclarations(" access(all) event Foo ( a : Int = 3)") - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 33, Offset: 33}, Message: "cannot use a default argument for this function", @@ -2760,7 +2760,7 @@ func TestParseEvent(t *testing.T) { t.Run("invalid event name", func(t *testing.T) { _, errs := testParseDeclarations(`event continue {}`) - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 6, Offset: 6}, Message: "expected identifier after start of event declaration, got keyword continue", @@ -2798,7 +2798,7 @@ func TestParseFieldWithVariableKind(t *testing.T) { result, errs := parse("var x : Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, VariableKind: ast.VariableKindVariable, @@ -2832,7 +2832,7 @@ func TestParseFieldWithVariableKind(t *testing.T) { result, errs := parse("let x : Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, VariableKind: ast.VariableKindConstant, @@ -2890,7 +2890,7 @@ func TestParseField(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, Flags: ast.FieldDeclarationFlagsIsNative, @@ -2923,7 +2923,7 @@ func TestParseField(t *testing.T) { _, errs := parse("native let foo: Int", Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -2946,7 +2946,7 @@ func TestParseField(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, Flags: ast.FieldDeclarationFlagsIsStatic, @@ -2982,7 +2982,7 @@ func TestParseField(t *testing.T) { Config{}, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -3006,7 +3006,7 @@ func TestParseField(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, Flags: ast.FieldDeclarationFlagsIsStatic | ast.FieldDeclarationFlagsIsNative, @@ -3039,7 +3039,7 @@ func TestParseField(t *testing.T) { _, errs := parse("static native let foo: Int", Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -3062,7 +3062,7 @@ func TestParseField(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier after native modifier", @@ -3086,7 +3086,7 @@ func TestParseField(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ TypeAnnotation: &ast.TypeAnnotation{ Type: &ast.NominalType{ @@ -3140,7 +3140,7 @@ func TestParseField(t *testing.T) { _, errs := parse("access(all) static native let foo: Int", Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -3164,7 +3164,7 @@ func TestParseCompositeDeclaration(t *testing.T) { result, errs := testParseDeclarations(" access(all) struct S { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Members: ast.NewUnmeteredMembers(nil), @@ -3203,7 +3203,7 @@ func TestParseCompositeDeclaration(t *testing.T) { result, errs := testParseDeclarations(" access(all) resource R : RI { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessAll, @@ -3251,7 +3251,7 @@ func TestParseCompositeDeclaration(t *testing.T) { require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Members: ast.NewUnmeteredMembers( @@ -3579,7 +3579,7 @@ func TestParseCompositeDeclaration(t *testing.T) { }`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -3632,7 +3632,7 @@ func TestParseCompositeDeclaration(t *testing.T) { }`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -3687,7 +3687,7 @@ func TestParseCompositeDeclaration(t *testing.T) { view foo: Int }`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid view modifier for variable", @@ -3720,7 +3720,7 @@ func TestParseInvalidCompositeFunctionWithSelfParameter(t *testing.T) { _, err := testParseDeclarations(code) - utils.AssertEqualWithDiff( + AssertEqualWithDiff( t, []error{ &SyntaxError{ @@ -3739,7 +3739,7 @@ func TestParseInvalidParameterWithoutLabel(t *testing.T) { _, errs := testParseDeclarations(`access(all) fun foo(continue: Int) {}`) - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 20, Offset: 20}, Message: "expected identifier for argument label or parameter name, got keyword continue", @@ -3752,7 +3752,7 @@ func TestParseParametersWithExtraLabels(t *testing.T) { _, errs := testParseDeclarations(`access(all) fun foo(_ foo: String, label fable table: Int) {}`) - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 47, Offset: 47}, Message: "expected ':' after parameter name, got identifier", @@ -3771,7 +3771,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { result, errs := testParseDeclarations("access(all) attachment E for S {} ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.AttachmentDeclaration{ Access: ast.AccessAll, @@ -3806,7 +3806,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { }`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -3852,7 +3852,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("attachment E {} ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected 'for', got '{'", @@ -3870,7 +3870,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { result, errs := testParseDeclarations("access(all) attachment E for S: I {} ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.AttachmentDeclaration{ Access: ast.AccessAll, @@ -3912,7 +3912,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { result, errs := testParseDeclarations("access(all) attachment E for S: I1, I2 {} ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.AttachmentDeclaration{ Access: ast.AccessAll, @@ -3986,7 +3986,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { }`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.AttachmentDeclaration{ Access: ast.AccessAll, @@ -4193,7 +4193,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { _, errs := testParseDeclarations(`access(all) attachment E for S { require entitlement X }`) - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 2, Column: 3, Offset: 36}, Message: "unexpected identifier", @@ -4210,7 +4210,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { }`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.AttachmentDeclaration{ Access: ast.AccessAll, @@ -4323,7 +4323,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { result, errs := testParseDeclarations(" access(all) struct interface S { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.InterfaceDeclaration{ Access: ast.AccessAll, @@ -4348,7 +4348,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(" access(all) struct interface interface { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected interface name, got keyword \"interface\"", @@ -4360,7 +4360,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -4384,7 +4384,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.InterfaceDeclaration{ Members: ast.NewUnmeteredMembers( @@ -4647,7 +4647,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { t.Run("invalid interface name", func(t *testing.T) { _, errs := testParseDeclarations(`access(all) struct interface continue {}`) - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 29, Offset: 29}, Message: "expected identifier following struct declaration, got keyword continue", @@ -4664,7 +4664,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { }`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.InterfaceDeclaration{ Access: ast.AccessNotSpecified, @@ -4720,7 +4720,7 @@ func TestParseEnumDeclaration(t *testing.T) { result, errs := testParseDeclarations(" access(all) enum E { case c ; access(all) case d }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessAll, @@ -4764,7 +4764,7 @@ func TestParseEnumDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" enum E { view case e }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid view modifier for enum case", @@ -4786,7 +4786,7 @@ func TestParseEnumDeclaration(t *testing.T) { StaticModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for enum case", @@ -4803,7 +4803,7 @@ func TestParseEnumDeclaration(t *testing.T) { _, errs := testParseDeclarations(" enum E { static case e }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -4825,7 +4825,7 @@ func TestParseEnumDeclaration(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for enum case", @@ -4842,7 +4842,7 @@ func TestParseEnumDeclaration(t *testing.T) { _, errs := testParseDeclarations(" enum E { native case e }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -4865,7 +4865,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseDeclarations("transaction { execute {} }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Execute: &ast.SpecialFunctionDeclaration{ @@ -4905,7 +4905,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Fields: nil, @@ -4941,7 +4941,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Fields: []*ast.FieldDeclaration{ @@ -5141,7 +5141,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Fields: []*ast.FieldDeclaration{ @@ -5388,7 +5388,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Fields: []*ast.FieldDeclaration{ @@ -5628,7 +5628,7 @@ func TestParseTransactionDeclaration(t *testing.T) { _, errs := testParseDeclarations(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, `unexpected identifier, expected keyword "prepare" or "execute", got "uwu"`, errs[0].Error(), ) @@ -5644,7 +5644,7 @@ func TestParseFunctionAndBlock(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -5690,7 +5690,7 @@ func TestParseFunctionParameterWithoutLabel(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -5748,7 +5748,7 @@ func TestParseFunctionParameterWithLabel(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -5817,7 +5817,7 @@ func TestParseStructure(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Members: ast.NewUnmeteredMembers( @@ -6144,7 +6144,7 @@ func TestParseStructureWithConformances(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -6205,7 +6205,7 @@ func TestParseInvalidMember(t *testing.T) { IgnoreLeadingIdentifierEnabled: false, }) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -6236,7 +6236,7 @@ func TestParsePreAndPostConditions(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -6393,7 +6393,7 @@ func TestParseConditionMessage(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -6507,7 +6507,7 @@ func TestParseInvalidEmitConditionNonInvocation(t *testing.T) { } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '('", @@ -6530,7 +6530,7 @@ func TestParseInvalidEmitConditionNonInvocation(t *testing.T) { } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '('", @@ -6562,7 +6562,7 @@ func TestParseEmitAndTestCondition(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -6833,7 +6833,7 @@ func TestParseInterface(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{test}, actual.Declarations(), ) @@ -6851,7 +6851,7 @@ func TestParsePragmaNoArguments(t *testing.T) { result, errs := testParseDeclarations(`#pedantic`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.PragmaDeclaration{ Expression: &ast.IdentifierExpression{ @@ -6875,7 +6875,7 @@ func TestParsePragmaNoArguments(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("view #foo") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid view modifier for pragma", @@ -6897,7 +6897,7 @@ func TestParsePragmaNoArguments(t *testing.T) { StaticModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for pragma", @@ -6913,7 +6913,7 @@ func TestParsePragmaNoArguments(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("static #foo") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6935,7 +6935,7 @@ func TestParsePragmaNoArguments(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for pragma", @@ -6951,7 +6951,7 @@ func TestParsePragmaNoArguments(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("native #foo") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6971,7 +6971,7 @@ func TestParsePragmaArguments(t *testing.T) { actual, err := testParseProgram(code) require.NoError(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.PragmaDeclaration{ Expression: &ast.InvocationExpression{ @@ -7016,7 +7016,7 @@ func TestParseImportWithString(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -7042,7 +7042,7 @@ func TestParseImportWithAddress(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -7070,7 +7070,7 @@ func TestParseImportWithIdentifiers(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -7109,7 +7109,7 @@ func TestParseFieldWithFromIdentifier(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -7174,7 +7174,7 @@ func TestParseImportWithFromIdentifier(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -7206,7 +7206,7 @@ func TestParseInvalidImportWithPurity(t *testing.T) { ` _, errs := testParseDeclarations(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid view modifier for import", @@ -7227,7 +7227,7 @@ func TestParseInvalidDefaultArgument(t *testing.T) { _, errs := testParseDeclarations(" access(all) fun foo ( a : Int = 3) { } ") - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 31, Offset: 31}, Message: "cannot use a default argument for this function", @@ -7241,7 +7241,7 @@ func TestParseInvalidDefaultArgument(t *testing.T) { _, errs := testParseDeclarations(" let foo = fun ( a : Int = 3) { } ") - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 25, Offset: 25}, Message: "cannot use a default argument for this function", @@ -7259,7 +7259,7 @@ func TestParseInvalidEventWithPurity(t *testing.T) { ` _, errs := testParseDeclarations(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid view modifier for event", @@ -7279,7 +7279,7 @@ func TestParseInvalidCompositeWithPurity(t *testing.T) { ` _, errs := testParseDeclarations(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid view modifier for struct", @@ -7299,7 +7299,7 @@ func TestParseInvalidTransactionWithPurity(t *testing.T) { ` _, errs := testParseDeclarations(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid view modifier for transaction", @@ -7332,7 +7332,7 @@ func TestParseResource(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -7362,7 +7362,7 @@ func TestParseEventDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -7448,7 +7448,7 @@ func TestParseEventEmitStatement(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -7534,7 +7534,7 @@ func TestParseResourceReturnType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -7583,7 +7583,7 @@ func TestParseMovingVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -7619,7 +7619,7 @@ func TestParseResourceParameterType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -7678,7 +7678,7 @@ func TestParseMovingVariableDeclarationWithTypeAnnotation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -7724,7 +7724,7 @@ func TestParseFieldDeclarationWithMoveTypeAnnotation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -7779,7 +7779,7 @@ func TestParseDestructor(t *testing.T) { } ` _, errs := testParseDeclarations(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &CustomDestructorError{ Pos: ast.Position{Offset: 37, Line: 3, Column: 12}, @@ -7799,7 +7799,7 @@ func TestParseCompositeDeclarationWithSemicolonSeparatedMembers(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -7965,7 +7965,7 @@ func TestParseInvalidCompositeFunctionNames(t *testing.T) { assert.True(t, ok, "Parser error does not conform to parser.Error") syntaxErr := errs.Errors[0].(*SyntaxError) - utils.AssertEqualWithDiff( + AssertEqualWithDiff( t, "expected identifier after start of function declaration, got keyword init", syntaxErr.Message, @@ -8075,7 +8075,7 @@ func TestParsePreconditionWithUnaryNegation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -8157,7 +8157,7 @@ func TestParseInvalidAccessModifiers(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("access(all) #test") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid access modifier for pragma", @@ -8173,7 +8173,7 @@ func TestParseInvalidAccessModifiers(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("access(all) transaction {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid access modifier for transaction", @@ -8189,7 +8189,7 @@ func TestParseInvalidAccessModifiers(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("access(all) access(self) let x = 1") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid second access modifier", @@ -8219,7 +8219,7 @@ func TestParseInvalidImportWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for import", @@ -8238,7 +8238,7 @@ func TestParseInvalidImportWithModifier(t *testing.T) { static import x from 0x1 `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8263,7 +8263,7 @@ func TestParseInvalidImportWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for import", @@ -8282,7 +8282,7 @@ func TestParseInvalidImportWithModifier(t *testing.T) { native import x from 0x1 `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8312,7 +8312,7 @@ func TestParseInvalidEventWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for event", @@ -8331,7 +8331,7 @@ func TestParseInvalidEventWithModifier(t *testing.T) { static event Foo() `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8356,7 +8356,7 @@ func TestParseInvalidEventWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for event", @@ -8375,7 +8375,7 @@ func TestParseInvalidEventWithModifier(t *testing.T) { native event Foo() `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8406,7 +8406,7 @@ func TestParseCompositeWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for structure", @@ -8425,7 +8425,7 @@ func TestParseCompositeWithModifier(t *testing.T) { static struct Foo() `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8450,7 +8450,7 @@ func TestParseCompositeWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for structure", @@ -8469,7 +8469,7 @@ func TestParseCompositeWithModifier(t *testing.T) { native struct Foo() `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8499,7 +8499,7 @@ func TestParseTransactionWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for transaction", @@ -8518,7 +8518,7 @@ func TestParseTransactionWithModifier(t *testing.T) { static transaction {} `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8543,7 +8543,7 @@ func TestParseTransactionWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for transaction", @@ -8562,7 +8562,7 @@ func TestParseTransactionWithModifier(t *testing.T) { native transaction {} `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8603,7 +8603,7 @@ func TestParseNestedPragma(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for pragma", @@ -8620,7 +8620,7 @@ func TestParseNestedPragma(t *testing.T) { _, errs := parse("native #pragma", Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8641,7 +8641,7 @@ func TestParseNestedPragma(t *testing.T) { StaticModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for pragma", @@ -8661,7 +8661,7 @@ func TestParseNestedPragma(t *testing.T) { Config{}, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8683,7 +8683,7 @@ func TestParseNestedPragma(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for pragma", @@ -8700,7 +8700,7 @@ func TestParseNestedPragma(t *testing.T) { _, errs := parse("static native #pragma", Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -8723,7 +8723,7 @@ func TestParseNestedPragma(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier after native modifier", @@ -8740,7 +8740,7 @@ func TestParseNestedPragma(t *testing.T) { _, errs := parse("access(all) #pragma", Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid access modifier for pragma", @@ -8762,7 +8762,7 @@ func TestParseNestedPragma(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid access modifier for pragma", @@ -8779,7 +8779,7 @@ func TestParseNestedPragma(t *testing.T) { _, errs := parse("access(all) static native #pragma", Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -8803,7 +8803,7 @@ func TestParseEntitlementDeclaration(t *testing.T) { result, errs := testParseDeclarations(" access(all) entitlement ABC ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.EntitlementDeclaration{ Access: ast.AccessAll, @@ -8834,7 +8834,7 @@ func TestParseEntitlementDeclaration(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Members: ast.NewUnmeteredMembers( @@ -8897,7 +8897,7 @@ func TestParseEntitlementDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" access(all) entitlement") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected identifier, got EOF", @@ -8913,7 +8913,7 @@ func TestParseEntitlementDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" access(all) view entitlement E") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid view modifier for entitlement", @@ -8949,7 +8949,7 @@ func TestParseMemberDocStrings(t *testing.T) { require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -9062,7 +9062,7 @@ func TestParseMemberDocStrings(t *testing.T) { require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -9134,7 +9134,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { result, errs := testParseDeclarations(" access(all) entitlement mapping M { } ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.EntitlementMappingDeclaration{ Access: ast.AccessAll, @@ -9162,7 +9162,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { } `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.EntitlementMappingDeclaration{ Access: ast.AccessAll, @@ -9251,7 +9251,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { } `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.EntitlementMappingDeclaration{ Access: ast.AccessAll, @@ -9356,7 +9356,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { } `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.EntitlementMappingDeclaration{ Access: ast.AccessAll, @@ -9437,7 +9437,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" access(all) mapping M {} ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -9453,7 +9453,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" access(all) entitlement M {} ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: '{'", @@ -9469,7 +9469,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" access(all) entitlement mapping M ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '{'", @@ -9485,7 +9485,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" access(all) entitlement mapping M {") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '}'", @@ -9501,7 +9501,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" access(all) entitlement mapping M }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '{'", @@ -9517,7 +9517,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" access(all) entitlement mapping {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected identifier following entitlement mapping declaration, got '{'", @@ -9536,7 +9536,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { &A -> B } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected nominal type, got &A", @@ -9555,7 +9555,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { A -> [B] } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected nominal type, got [B]", @@ -9574,7 +9574,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { A B } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '->'", @@ -9593,7 +9593,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { A - B } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '->'", @@ -9612,7 +9612,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { include &A } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected nominal type, got &A", @@ -9631,7 +9631,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { include -> B } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in type: '->'", @@ -9653,7 +9653,7 @@ func TestParseInvalidSpecialFunctionReturnTypeAnnotation(t *testing.T) { init(): Int } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid return type for initializer", @@ -9709,7 +9709,7 @@ func TestSoftKeywordsInFunctionDeclaration(t *testing.T) { }, }, } - utils.AssertEqualWithDiff(t, expected, result) + AssertEqualWithDiff(t, expected, result) }) } @@ -9728,7 +9728,7 @@ func TestParseDeprecatedAccessModifiers(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" pub fun foo ( ) { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxErrorWithSuggestedReplacement{ Message: "`pub` is no longer a valid access keyword", @@ -9749,7 +9749,7 @@ func TestParseDeprecatedAccessModifiers(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" priv fun foo ( ) { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxErrorWithSuggestedReplacement{ Message: "`priv` is no longer a valid access keyword", @@ -9770,7 +9770,7 @@ func TestParseDeprecatedAccessModifiers(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" pub(set) fun foo ( ) { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "`pub(set)` is no longer a valid access keyword", diff --git a/parser/expression_test.go b/parser/expression_test.go index 7acb0ac4eb..28e92f6404 100644 --- a/parser/expression_test.go +++ b/parser/expression_test.go @@ -34,7 +34,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/parser/lexer" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestParseSimpleInfixExpression(t *testing.T) { @@ -48,7 +48,7 @@ func TestParseSimpleInfixExpression(t *testing.T) { result, errs := testParseExpression("1+2*3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IntegerExpression{ @@ -93,7 +93,7 @@ func TestParseSimpleInfixExpression(t *testing.T) { result, errs := testParseExpression(" 1 + 2 * 3 ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IntegerExpression{ @@ -138,7 +138,7 @@ func TestParseSimpleInfixExpression(t *testing.T) { result, errs := testParseExpression("1 + 2 + 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.BinaryExpression{ @@ -183,7 +183,7 @@ func TestParseSimpleInfixExpression(t *testing.T) { result, errs := testParseExpression("1 ?? 2 ?? 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationNilCoalesce, Left: &ast.IntegerExpression{ @@ -233,7 +233,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("1 +- 2 -- 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMinus, Left: &ast.BinaryExpression{ @@ -278,7 +278,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("(1 + 2) * 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMul, Left: &ast.BinaryExpression{ @@ -356,7 +356,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("1 < 2 > 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationGreater, Left: &ast.BinaryExpression{ @@ -401,7 +401,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("a ? b : c ? d : e") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ConditionalExpression{ Test: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -447,7 +447,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("true + false") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.BoolExpression{ @@ -476,7 +476,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("(<-x)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationMove, Expression: &ast.IdentifierExpression{ @@ -498,7 +498,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("<-x as! @T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationMove, Expression: &ast.CastingExpression{ @@ -533,7 +533,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("<-x as? @T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationMove, Expression: &ast.CastingExpression{ @@ -568,7 +568,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("<-x as @T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationMove, Expression: &ast.CastingExpression{ @@ -609,7 +609,7 @@ func TestParseArrayExpression(t *testing.T) { result, errs := testParseExpression("[ 1,2 + 3, 4 , 5 ]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ArrayExpression{ Values: []ast.Expression{ &ast.IntegerExpression{ @@ -677,7 +677,7 @@ func TestParseArrayExpression(t *testing.T) { result, errs := testParseExpression("[ 1 , \n 2 \n , \n\n 3 \n\n\n]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ArrayExpression{ Values: []ast.Expression{ &ast.IntegerExpression{ @@ -724,7 +724,7 @@ func TestParseArrayExpression(t *testing.T) { result, errs := testParseExpression("[\n]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ArrayExpression{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 0, Offset: 0}, @@ -748,7 +748,7 @@ func TestParseDictionaryExpression(t *testing.T) { result, errs := testParseExpression("{ 1:2 + 3, 4 : 5 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryExpression{ Entries: []ast.DictionaryEntry{ { @@ -820,7 +820,7 @@ func TestParseDictionaryExpression(t *testing.T) { result, errs := testParseExpression("{ 1 : 2 , \n 3 \n : \n 4 \n , \n\n 5 \n\n : \n\n 6 \n\n }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryExpression{ Entries: []ast.DictionaryEntry{ { @@ -900,7 +900,7 @@ func TestParseDictionaryExpression(t *testing.T) { result, errs := testParseExpression("{\n}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryExpression{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 0, Offset: 0}, @@ -921,7 +921,7 @@ func TestParseIndexExpression(t *testing.T) { result, errs := testParseExpression("a[0]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IndexExpression{ TargetExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -953,7 +953,7 @@ func TestParseIndexExpression(t *testing.T) { result, errs := testParseExpression("a [ 0 ]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IndexExpression{ TargetExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -985,7 +985,7 @@ func TestParseIndexExpression(t *testing.T) { result, errs := testParseExpression("a [foo]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IndexExpression{ TargetExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1020,7 +1020,7 @@ func TestParseIdentifier(t *testing.T) { result, errs := testParseExpression("a + 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IdentifierExpression{ @@ -1051,7 +1051,7 @@ func TestParsePath(t *testing.T) { result, errs := testParseExpression("/foo/bar") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.PathExpression{ Domain: ast.Identifier{ Identifier: "foo", @@ -1078,7 +1078,7 @@ func TestParseString(t *testing.T) { result, errs := testParseExpression("\"\"") assert.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "", Range: ast.Range{ @@ -1095,7 +1095,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of string literal: missing '\"'", @@ -1105,7 +1105,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "", Range: ast.Range{ @@ -1122,7 +1122,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"\n") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of string literal: missing '\"'", @@ -1132,7 +1132,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "", Range: ast.Range{ @@ -1148,7 +1148,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"t") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of string literal: missing '\"'", @@ -1158,7 +1158,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "t", Range: ast.Range{ @@ -1175,7 +1175,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"t\n") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of string literal: missing '\"'", @@ -1185,7 +1185,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "t", Range: ast.Range{ @@ -1202,7 +1202,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"\\") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "incomplete escape sequence: missing character after escape character", @@ -1216,7 +1216,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "", Range: ast.Range{ @@ -1235,7 +1235,7 @@ func TestParseString(t *testing.T) { result, errs := testParseExpression(`"te\tst\"te\u{1F3CE}\u{FE0F}xt"`) assert.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te\tst\"te\U0001F3CE\uFE0Fxt", Range: ast.Range{ @@ -1252,7 +1252,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\Xst"`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid escape character: 'X'", @@ -1262,7 +1262,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "test", Range: ast.Range{ @@ -1279,7 +1279,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\u`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "incomplete Unicode escape sequence: missing character '{' after escape character", @@ -1293,7 +1293,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te", Range: ast.Range{ @@ -1310,7 +1310,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\us`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid Unicode escape sequence: expected '{', got 's'", @@ -1324,7 +1324,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te", Range: ast.Range{ @@ -1341,7 +1341,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\u{`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "incomplete Unicode escape sequence: missing character '}' after escape character", @@ -1355,7 +1355,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te", Range: ast.Range{ @@ -1374,7 +1374,7 @@ func TestParseString(t *testing.T) { result, errs := testParseExpression(`"te\u{}"`) assert.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te", Range: ast.Range{ @@ -1401,7 +1401,7 @@ func TestParseString(t *testing.T) { ) assert.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "test JJJJ KKKK LLLL MMMM NNNN OOOO", Range: ast.Range{ @@ -1418,7 +1418,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\u{X}st"`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid Unicode escape sequence: expected hex digit, got 'X'", @@ -1428,7 +1428,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "test", Range: ast.Range{ @@ -1452,7 +1452,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1475,7 +1475,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f ()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1498,7 +1498,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f ( )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1521,7 +1521,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(1)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1558,7 +1558,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(label:1)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1597,7 +1597,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(1,2)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1647,7 +1647,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(a:1,b:2)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1699,7 +1699,7 @@ func TestParseInvocation(t *testing.T) { t.Parallel() _, errs := testParseExpression("f(,,)") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected argument or end of argument list, got ','", @@ -1715,7 +1715,7 @@ func TestParseInvocation(t *testing.T) { t.Parallel() _, errs := testParseExpression("f(1,,)") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected argument or end of argument list, got ','", @@ -1731,7 +1731,7 @@ func TestParseInvocation(t *testing.T) { t.Parallel() _, errs := testParseExpression("f(1 2)") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected argument in argument list (expecting delimiter or end of argument list)," + @@ -1750,7 +1750,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(1,g(2))") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1816,7 +1816,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(1,g(\"test\"))") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1885,7 +1885,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("f.n") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.MemberExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1910,7 +1910,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("f .n") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.MemberExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1933,7 +1933,7 @@ func TestParseMemberExpression(t *testing.T) { t.Parallel() result, errs := testParseExpression("f.") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected member name, got EOF", @@ -1943,7 +1943,7 @@ func TestParseMemberExpression(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.MemberExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1964,7 +1964,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("f.n * 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMul, Left: &ast.MemberExpression{ @@ -2001,7 +2001,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("3 * f.n") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMul, Left: &ast.IntegerExpression{ @@ -2038,7 +2038,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("f?.n") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.MemberExpression{ Optional: true, Expression: &ast.IdentifierExpression{ @@ -2067,7 +2067,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2112,7 +2112,7 @@ func TestParseBlockComment(t *testing.T) { result, errs := testParseExpression(" /* test foo/* bar */ asd*/ true") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BoolExpression{ Value: true, Range: ast.Range{ @@ -2131,7 +2131,7 @@ func TestParseBlockComment(t *testing.T) { result, errs := testParseExpression(" /*test foo*/ /* bar */ true") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BoolExpression{ Value: true, Range: ast.Range{ @@ -2150,7 +2150,7 @@ func TestParseBlockComment(t *testing.T) { result, errs := testParseExpression(" 1/*test foo*/+/* bar */ 2 ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IntegerExpression{ @@ -2181,7 +2181,7 @@ func TestParseBlockComment(t *testing.T) { t.Parallel() _, errs := testParseExpression(" /* test foo/* bar */ asd*/ true */ bar") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ // `true */ bar` is parsed as infix operation of path &SyntaxError{ @@ -2202,7 +2202,7 @@ func TestParseBlockComment(t *testing.T) { t.Parallel() _, errs := testParseExpression(" /* test foo/* bar */ asd true ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ // `true */ bar` is parsed as infix operation of path &SyntaxError{ @@ -2277,7 +2277,7 @@ func TestParseBlockComment(t *testing.T) { }, Config{}, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token identifier in block comment", @@ -2300,7 +2300,7 @@ func TestParseMulInfixExpression(t *testing.T) { result, errs := testParseExpression(" 1 ** 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMul, Left: &ast.IntegerExpression{ @@ -2373,7 +2373,7 @@ func TestParseReference(t *testing.T) { result, errs := testParseExpression("& t") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2396,7 +2396,7 @@ func TestParseReference(t *testing.T) { result, errs := testParseExpression(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceExpression{ Expression: &ast.IndexExpression{ TargetExpression: &ast.IdentifierExpression{ @@ -2429,7 +2429,7 @@ func TestParseReference(t *testing.T) { const code = `&x[y]? as &Z?` _, errs := testParseExpression(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected end of program", @@ -2454,7 +2454,7 @@ func TestParseNilCoelesceReference(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationNilCoalesce, Left: &ast.CastingExpression{ @@ -2570,7 +2570,7 @@ func TestParseCasts(t *testing.T) { result, errs := testParseExpression(" t as T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.CastingExpression{ Operation: ast.OperationCast, Expression: &ast.IdentifierExpression{ @@ -2600,7 +2600,7 @@ func TestParseCasts(t *testing.T) { result, errs := testParseExpression(" t as? T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.CastingExpression{ Operation: ast.OperationFailableCast, Expression: &ast.IdentifierExpression{ @@ -2631,7 +2631,7 @@ func TestParseCasts(t *testing.T) { result, errs := testParseExpression(" t as! T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.CastingExpression{ Operation: ast.OperationForceCast, Expression: &ast.IdentifierExpression{ @@ -2666,7 +2666,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseExpression("t!") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ForceExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2687,7 +2687,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseExpression(" t ! ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ForceExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2708,7 +2708,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseExpression("<-t!") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationMove, Expression: &ast.ForceExpression{ @@ -2733,7 +2733,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseExpression("10 * t!") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMul, Left: &ast.IntegerExpression{ @@ -2765,7 +2765,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseStatements("x\n!y") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.IdentifierExpression{ @@ -2799,7 +2799,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseStatements("x\n.y!") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.ForceExpression{ @@ -2829,7 +2829,7 @@ func TestParseForceExpression(t *testing.T) { t.Parallel() result, errs := testParseStatements("x. y") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid whitespace after '.'", @@ -2839,7 +2839,7 @@ func TestParseForceExpression(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.MemberExpression{ @@ -2873,7 +2873,7 @@ func TestParseCreate(t *testing.T) { result, errs := testParseExpression("create T()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.CreateExpression{ InvocationExpression: &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ @@ -2899,7 +2899,7 @@ func TestParseNil(t *testing.T) { result, errs := testParseExpression(" nil") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.NilExpression{ Pos: ast.Position{Line: 1, Column: 1, Offset: 1}, }, @@ -2918,7 +2918,7 @@ func TestParseDestroy(t *testing.T) { result, errs := testParseExpression("destroy t") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DestroyExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2944,7 +2944,7 @@ func TestParseAttach(t *testing.T) { result, errs := testParseExpression("attach E() to r") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.AttachExpression{ Base: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2973,7 +2973,7 @@ func TestParseAttach(t *testing.T) { t.Parallel() _, errs := testParseExpression("attach E() to r with (X)") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -2991,7 +2991,7 @@ func TestParseAttach(t *testing.T) { result, errs := testParseExpression("attach A() to attach B() to r") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.AttachExpression{ Base: &ast.AttachExpression{ Base: &ast.IdentifierExpression{ @@ -3033,7 +3033,7 @@ func TestParseAttach(t *testing.T) { t.Parallel() _, errs := testParseExpression("attach A()") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected 'to', got EOF", @@ -3049,7 +3049,7 @@ func TestParseAttach(t *testing.T) { t.Parallel() _, errs := testParseExpression("attach E() to") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected end of program", @@ -3068,7 +3068,7 @@ func TestParseLineComment(t *testing.T) { result, errs := testParseExpression(" //// // this is a comment\n 1 / 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationDiv, Left: &ast.IntegerExpression{ @@ -3105,7 +3105,7 @@ func TestParseFunctionExpression(t *testing.T) { result, errs := testParseExpression("fun () { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionExpression{ ParameterList: &ast.ParameterList{ Parameters: nil, @@ -3135,7 +3135,7 @@ func TestParseFunctionExpression(t *testing.T) { result, errs := testParseExpression("fun (): X { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionExpression{ ParameterList: &ast.ParameterList{ Parameters: nil, @@ -3174,7 +3174,7 @@ func TestParseFunctionExpression(t *testing.T) { result, errs := testParseExpression("view fun (): X { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionExpression{ Purity: 1, ParameterList: &ast.ParameterList{ @@ -3212,7 +3212,7 @@ func TestParseFunctionExpression(t *testing.T) { t.Parallel() _, errs := testParseExpression("view for (): X { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -3255,7 +3255,7 @@ func TestParseAdjacentViewKeyword(t *testing.T) { }, StartPos: ast.Position{Line: 2, Column: 2, Offset: 3}, } - utils.AssertEqualWithDiff(t, expected, result) + AssertEqualWithDiff(t, expected, result) } @@ -3268,7 +3268,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0b`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing digits", @@ -3287,7 +3287,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b"), Value: new(big.Int), @@ -3308,7 +3308,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0b101010`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b101010"), Value: big.NewInt(42), @@ -3327,7 +3327,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0b001000`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b001000"), Value: big.NewInt(8), @@ -3348,7 +3348,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0b101010_101010`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b101010_101010"), Value: big.NewInt(2730), @@ -3367,7 +3367,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0b_101010_101010`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0b_101010_101010", @@ -3382,7 +3382,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b_101010_101010"), Value: big.NewInt(2730), @@ -3401,7 +3401,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0b101010_101010_`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0b101010_101010_", @@ -3416,7 +3416,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b101010_101010_"), Value: big.NewInt(2730), @@ -3435,7 +3435,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0o`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing digits", @@ -3454,7 +3454,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o"), Value: new(big.Int), @@ -3475,7 +3475,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0o32`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o32"), Value: big.NewInt(26), @@ -3496,7 +3496,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0o32_45`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o32_45"), Value: big.NewInt(1701), @@ -3515,7 +3515,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0o_32_45`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0o_32_45", @@ -3530,7 +3530,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o_32_45"), Value: big.NewInt(1701), @@ -3549,7 +3549,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0o32_45_`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0o32_45_", @@ -3564,7 +3564,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o32_45_"), Value: big.NewInt(1701), @@ -3585,7 +3585,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`1234567890`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("1234567890"), Value: big.NewInt(1234567890), @@ -3606,7 +3606,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`1_234_567_890`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("1_234_567_890"), Value: big.NewInt(1234567890), @@ -3625,7 +3625,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`1_234_567_890_`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "1_234_567_890_", @@ -3640,7 +3640,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("1_234_567_890_"), Value: big.NewInt(1234567890), @@ -3659,7 +3659,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0x`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing digits", @@ -3678,7 +3678,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0x"), Value: new(big.Int), @@ -3699,7 +3699,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0xf2`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0xf2"), Value: big.NewInt(242), @@ -3720,7 +3720,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0xf2_09`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0xf2_09"), Value: big.NewInt(61961), @@ -3739,7 +3739,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0x_f2_09`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0x_f2_09", @@ -3754,7 +3754,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0x_f2_09"), Value: big.NewInt(61961), @@ -3773,7 +3773,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0xf2_09_`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: `0xf2_09_`, @@ -3788,7 +3788,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0xf2_09_"), Value: big.NewInt(61961), @@ -3809,7 +3809,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0"), Value: big.NewInt(0), @@ -3830,7 +3830,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`01`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("01"), Value: big.NewInt(1), @@ -3851,7 +3851,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`09`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("09"), Value: big.NewInt(9), @@ -3872,7 +3872,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression("00123") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("00123"), Value: big.NewInt(123), @@ -3891,7 +3891,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0z123`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid number literal prefix: 'z'", @@ -3910,7 +3910,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0z123"), Value: new(big.Int), @@ -3931,7 +3931,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0_100`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0_100"), Value: big.NewInt(100), @@ -3952,7 +3952,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`1_100`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("1_100"), Value: big.NewInt(1100), @@ -3975,7 +3975,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`_100`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IdentifierExpression{ Identifier: ast.Identifier{ Identifier: "_100", @@ -3998,7 +3998,7 @@ func TestParseFixedPoint(t *testing.T) { result, errs := testParseExpression("1234_5678_90.0009_8765_4321") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FixedPointExpression{ PositiveLiteral: []byte("1234_5678_90.0009_8765_4321"), Negative: false, @@ -4021,7 +4021,7 @@ func TestParseFixedPoint(t *testing.T) { result, errs := testParseExpression("0.1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FixedPointExpression{ PositiveLiteral: []byte("0.1"), Negative: false, @@ -4042,7 +4042,7 @@ func TestParseFixedPoint(t *testing.T) { t.Parallel() result, errs := testParseExpression("0.") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing fractional digits", @@ -4052,7 +4052,7 @@ func TestParseFixedPoint(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FixedPointExpression{ PositiveLiteral: []byte("0."), Negative: false, @@ -4080,7 +4080,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("1 < 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationLess, Left: &ast.IntegerExpression{ @@ -4113,7 +4113,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a < > ()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -4137,7 +4137,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a < { K : V } > ( 1 )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -4197,7 +4197,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a < { K : V } , @R , [ S ] > ( 1 , 2 )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -4295,7 +4295,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("1 + a<>()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IntegerExpression{ @@ -4331,7 +4331,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a>()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -4381,7 +4381,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a >()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -4431,7 +4431,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("0 + 1 < 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationLess, Left: &ast.BinaryExpression{ @@ -4476,7 +4476,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("0 + 1 << 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationBitwiseLeftShift, Left: &ast.BinaryExpression{ @@ -4521,7 +4521,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("0 + 1 > 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationGreater, Left: &ast.BinaryExpression{ @@ -4566,7 +4566,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("0 + 1 >> 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationBitwiseRightShift, Left: &ast.BinaryExpression{ @@ -4609,7 +4609,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { t.Parallel() _, errs := testParseExpression("foo") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &RestrictedTypeError{ Range: ast.Range{ @@ -4633,7 +4633,7 @@ func TestParseBoolExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4670,7 +4670,7 @@ func TestParseIdentifierExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4706,7 +4706,7 @@ func TestParseArrayExpressionInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4761,7 +4761,7 @@ func TestParseDictionaryExpressionInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4834,7 +4834,7 @@ func TestParseInvocationExpressionWithoutLabels(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4902,7 +4902,7 @@ func TestParseInvocationExpressionWithLabels(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4989,7 +4989,7 @@ func TestParseOptionalMemberExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5033,7 +5033,7 @@ func TestParseIndexExpressionInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5087,7 +5087,7 @@ func TestParseUnaryExpression(t *testing.T) { result, errs := testParseExpression(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationMinus, Expression: &ast.IdentifierExpression{ @@ -5111,7 +5111,7 @@ func TestParseUnaryExpression(t *testing.T) { result, errs := testParseExpression(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationNegate, Expression: &ast.IdentifierExpression{ @@ -5135,7 +5135,7 @@ func TestParseUnaryExpression(t *testing.T) { result, errs := testParseExpression(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationMul, Expression: &ast.IdentifierExpression{ @@ -5157,7 +5157,7 @@ func TestParseUnaryExpression(t *testing.T) { const code = ` % boo` _, errs := testParseExpression(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in expression: '%'", @@ -5179,7 +5179,7 @@ func TestParseOrExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5226,7 +5226,7 @@ func TestParseAndExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5273,7 +5273,7 @@ func TestParseEqualityExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5320,7 +5320,7 @@ func TestParseRelationalExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5371,7 +5371,7 @@ func TestParseAdditiveExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5422,7 +5422,7 @@ func TestParseMultiplicativeExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5473,7 +5473,7 @@ func TestParseFunctionExpressionAndReturn(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5547,7 +5547,7 @@ func TestParseLeftAssociativity(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5610,7 +5610,7 @@ func TestParseNegativeInteger(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5649,7 +5649,7 @@ func TestParseNegativeFixedPoint(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5692,7 +5692,7 @@ func TestParseTernaryRightAssociativity(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5795,7 +5795,7 @@ func TestParseVoidLiteral(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5841,7 +5841,7 @@ func TestParseMissingReturnType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5983,7 +5983,7 @@ func TestParseExpression(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, actual) + AssertEqualWithDiff(t, expected, actual) } func TestParseStringEscapes(t *testing.T) { @@ -6011,7 +6011,7 @@ func TestParseStringEscapes(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, actual) + AssertEqualWithDiff(t, expected, actual) } func TestParseStringWithUnicode(t *testing.T) { @@ -6039,7 +6039,7 @@ func TestParseStringWithUnicode(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, actual) + AssertEqualWithDiff(t, expected, actual) } func TestParseNilCoalescing(t *testing.T) { @@ -6052,7 +6052,7 @@ func TestParseNilCoalescing(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6098,7 +6098,7 @@ func TestParseNilCoalescingRightAssociativity(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6201,7 +6201,7 @@ func TestParseFailableCasting(t *testing.T) { failableDowncast.ParentVariableDeclaration = variableDeclaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ variableDeclaration, }, @@ -6219,7 +6219,7 @@ func TestParseMoveOperator(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6277,7 +6277,7 @@ func TestParseFunctionExpressionWithResourceTypeAnnotation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ @@ -6386,7 +6386,7 @@ func TestParseFailableCastingResourceTypeAnnotation(t *testing.T) { failableDowncast.ParentVariableDeclaration = variableDeclaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ variableDeclaration, }, @@ -6440,7 +6440,7 @@ func TestParseCasting(t *testing.T) { cast.ParentVariableDeclaration = variableDeclaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ variableDeclaration, }, @@ -6484,7 +6484,7 @@ func TestParseHardKeywords(t *testing.T) { t.Parallel() testParseIdentifiersWith(t, HardKeywords, func(t *testing.T, keyword string, err error) { - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 4, Offset: 4}, @@ -6573,7 +6573,7 @@ func TestParseReferenceInVariableDeclaration(t *testing.T) { expected.Value.(*ast.CastingExpression).ParentVariableDeclaration = expected - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ expected, }, @@ -6591,7 +6591,7 @@ func TestParseFixedPointExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6631,7 +6631,7 @@ func TestParseFixedPointExpressionZeroInteger(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6671,7 +6671,7 @@ func TestParsePathLiteral(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6711,7 +6711,7 @@ func TestParseBitwiseExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, diff --git a/parser/lexer/lexer_test.go b/parser/lexer/lexer_test.go index d6562fdebd..c529b750ce 100644 --- a/parser/lexer/lexer_test.go +++ b/parser/lexer/lexer_test.go @@ -28,7 +28,7 @@ import ( "go.uber.org/goleak" "github.com/onflow/cadence/ast" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestMain(m *testing.M) { @@ -67,7 +67,7 @@ func testLex(t *testing.T, input string, expected []token) { require.NoError(t, err) withTokens(tokenStream, func(actualTokens []Token) { - utils.AssertEqualWithDiff(t, expectedTokens, actualTokens) + AssertEqualWithDiff(t, expectedTokens, actualTokens) require.Len(t, actualTokens, len(expectedTokens)) for i, expectedToken := range expected { diff --git a/parser/parser_test.go b/parser/parser_test.go index 93bc5f4918..3629ac6b43 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -33,7 +33,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/parser/lexer" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestMain(m *testing.M) { @@ -240,7 +240,7 @@ func TestParseBuffering(t *testing.T) { Config{}, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token identifier with string value c", @@ -483,7 +483,7 @@ func TestParseBuffering(t *testing.T) { Config{}, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token identifier with string value d", @@ -511,7 +511,7 @@ func TestParseBuffering(t *testing.T) { } ` _, err := testParseProgram(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token identifier", @@ -536,7 +536,7 @@ func TestParseBuffering(t *testing.T) { ` _, err := testParseProgram(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &RestrictedTypeError{ Range: ast.Range{ @@ -705,7 +705,7 @@ func TestParseArgumentList(t *testing.T) { t.Parallel() _, errs := testParseArgumentList(`xyz`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '('", @@ -724,7 +724,7 @@ func TestParseArgumentList(t *testing.T) { var expected ast.Arguments - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -750,7 +750,7 @@ func TestParseArgumentList(t *testing.T) { result, errs := testParseArgumentList(`(1, b: true)`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.Arguments{ { Label: "", @@ -835,7 +835,7 @@ func TestParseBufferedErrors(t *testing.T) { // there is another error (missing closing parenthesis after). _, errs := testParseExpression("a(") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing type annotation after comma", @@ -874,7 +874,7 @@ func TestParseExpressionDepthLimit(t *testing.T) { _, err := testParseProgram(code) require.Error(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ ExpressionDepthLimitReachedError{ Pos: ast.Position{ @@ -910,7 +910,7 @@ func TestParseTypeDepthLimit(t *testing.T) { _, err := testParseProgram(code) require.Error(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ TypeDepthLimitReachedError{ Pos: ast.Position{ @@ -936,7 +936,7 @@ func TestParseLocalReplayLimit(t *testing.T) { code := []byte(builder.String()) _, err := ParseProgram(nil, code, Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, Error{ Code: code, Errors: []error{ @@ -971,7 +971,7 @@ func TestParseGlobalReplayLimit(t *testing.T) { code := []byte(builder.String()) _, err := ParseProgram(nil, code, Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, Error{ Code: code, Errors: []error{ diff --git a/parser/statement_test.go b/parser/statement_test.go index 8e3b6762cb..397fd3c19d 100644 --- a/parser/statement_test.go +++ b/parser/statement_test.go @@ -27,7 +27,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/ast" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestParseReplInput(t *testing.T) { @@ -65,7 +65,7 @@ func TestParseReturnStatement(t *testing.T) { result, errs := testParseStatements("return") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ReturnStatement{ Range: ast.Range{ @@ -85,7 +85,7 @@ func TestParseReturnStatement(t *testing.T) { result, errs := testParseStatements("return 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ReturnStatement{ Expression: &ast.IntegerExpression{ @@ -114,7 +114,7 @@ func TestParseReturnStatement(t *testing.T) { result, errs := testParseStatements("return \n1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ReturnStatement{ Range: ast.Range{ @@ -145,7 +145,7 @@ func TestParseReturnStatement(t *testing.T) { result, errs := testParseStatements("return ;\n1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ReturnStatement{ Range: ast.Range{ @@ -181,7 +181,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -212,7 +212,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true { 1 ; 2 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -266,7 +266,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true { 1 \n 2 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -320,7 +320,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true { 1 } else { 2 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -382,7 +382,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true{1}else if true {2} else{3}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -516,7 +516,7 @@ func TestParseIfStatement(t *testing.T) { expected.Test.(*ast.VariableDeclaration).ParentIfStatement = expected - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ expected, }, @@ -566,7 +566,7 @@ func TestParseIfStatement(t *testing.T) { expected.Test.(*ast.VariableDeclaration).ParentIfStatement = expected - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ expected, }, @@ -587,7 +587,7 @@ func TestParseWhileStatement(t *testing.T) { result, errs := testParseStatements("while true { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.WhileStatement{ Test: &ast.BoolExpression{ @@ -623,7 +623,7 @@ func TestParseAssignmentStatement(t *testing.T) { result, errs := testParseStatements("x=1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.AssignmentStatement{ Target: &ast.IdentifierExpression{ @@ -658,7 +658,7 @@ func TestParseAssignmentStatement(t *testing.T) { result, errs := testParseStatements(" x = 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.AssignmentStatement{ Target: &ast.IdentifierExpression{ @@ -693,7 +693,7 @@ func TestParseAssignmentStatement(t *testing.T) { result, errs := testParseStatements(" x <- 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.AssignmentStatement{ Target: &ast.IdentifierExpression{ @@ -728,7 +728,7 @@ func TestParseAssignmentStatement(t *testing.T) { result, errs := testParseStatements(" x <-! 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.AssignmentStatement{ Target: &ast.IdentifierExpression{ @@ -768,7 +768,7 @@ func TestParseSwapStatement(t *testing.T) { result, errs := testParseStatements(" x <-> y") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.SwapStatement{ Left: &ast.IdentifierExpression{ @@ -801,7 +801,7 @@ func TestParseForStatement(t *testing.T) { result, errs := testParseStatements("for x in y { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ForStatement{ Identifier: ast.Identifier{ @@ -840,7 +840,7 @@ func TestParseForStatementIndexBinding(t *testing.T) { result, errs := testParseStatements("for i, x in y { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ForStatement{ Identifier: ast.Identifier{ @@ -876,7 +876,7 @@ func TestParseForStatementIndexBinding(t *testing.T) { t.Parallel() _, errs := testParseStatements("for i x in y { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected keyword \"in\", got identifier", @@ -896,7 +896,7 @@ func TestParseForStatementIndexBinding(t *testing.T) { t.Parallel() _, errs := testParseStatements("for in y { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected identifier, got keyword \"in\"", @@ -923,7 +923,7 @@ func TestParseEmit(t *testing.T) { result, errs := testParseStatements("emit T()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.EmitStatement{ InvocationExpression: &ast.InvocationExpression{ @@ -955,7 +955,7 @@ func TestParseFunctionStatementOrExpression(t *testing.T) { result, errs := testParseStatements("fun foo() {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -991,7 +991,7 @@ func TestParseFunctionStatementOrExpression(t *testing.T) { result, errs := testParseStatements("view fun () {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.FunctionExpression{ @@ -1025,7 +1025,7 @@ func TestParseFunctionStatementOrExpression(t *testing.T) { result, errs := testParseStatements("view fun foo() {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.FunctionDeclaration{ Purity: ast.FunctionPurityView, @@ -1062,7 +1062,7 @@ func TestParseFunctionStatementOrExpression(t *testing.T) { result, errs := testParseStatements("fun () {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.FunctionExpression{ @@ -1095,7 +1095,7 @@ func TestParseFunctionStatementOrExpression(t *testing.T) { require.Empty(t, result) - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected identifier after start of function declaration, got keyword continue", Pos: ast.Position{Line: 1, Column: 4, Offset: 4}, @@ -1110,7 +1110,7 @@ func TestParseFunctionStatementOrExpression(t *testing.T) { require.Empty(t, result) - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected identifier after start of function declaration, got keyword break", Pos: ast.Position{Line: 1, Column: 9, Offset: 9}, @@ -1123,7 +1123,7 @@ func TestParseViewNonFunction(t *testing.T) { t.Parallel() _, errs := testParseStatements("view return 3") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "statements on the same line must be separated with a semicolon", @@ -1145,7 +1145,7 @@ func TestParseStatements(t *testing.T) { result, errs := testParseStatements("a + b < c\nd") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.BinaryExpression{ @@ -1191,7 +1191,7 @@ func TestParseStatements(t *testing.T) { t.Parallel() result, errs := testParseStatements(`assert true`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "statements on the same line must be separated with a semicolon", @@ -1201,7 +1201,7 @@ func TestParseStatements(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.IdentifierExpression{ @@ -1237,7 +1237,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { result, errs := testParseStatements("remove A from b") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.RemoveStatement{ Attachment: &ast.NominalType{ @@ -1266,7 +1266,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { result, errs := testParseStatements("remove Foo.E from b") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.RemoveStatement{ Attachment: &ast.NominalType{ @@ -1300,7 +1300,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { _, errs := testParseStatements("remove A") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected from keyword, got EOF", @@ -1321,7 +1321,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { _, errs := testParseStatements("remove A from") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected end of program", @@ -1338,7 +1338,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { _, errs := testParseStatements("remove [A] from e") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected attachment nominal type, got [A]", @@ -1356,7 +1356,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { result, errs := testParseStatements("remove A from foo()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.RemoveStatement{ Attachment: &ast.NominalType{ @@ -1394,7 +1394,7 @@ func TestParseSwitchStatement(t *testing.T) { result, errs := testParseStatements("switch true { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.SwitchStatement{ Expression: &ast.BoolExpression{ @@ -1422,7 +1422,7 @@ func TestParseSwitchStatement(t *testing.T) { result, errs := testParseStatements("switch x { case 1 :\n a\nb default : c\nd }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.SwitchStatement{ Expression: &ast.IdentifierExpression{ @@ -1503,7 +1503,7 @@ func TestParseSwitchStatement(t *testing.T) { t.Run("Invalid identifiers in switch cases", func(t *testing.T) { code := "switch 1 {AAAAA: break; case 3: break; default: break}" _, errs := testParseStatements(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, `unexpected token: got identifier, expected "case" or "default"`, errs[0].Error(), ) @@ -1529,7 +1529,7 @@ func TestParseIfStatementInFunctionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1731,7 +1731,7 @@ func TestParseIfStatementWithVariableDeclaration(t *testing.T) { ifStatement.Test = ifTestVariableDeclaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1777,7 +1777,7 @@ func TestParseIfStatementNoElse(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1849,7 +1849,7 @@ func TestParseWhileStatementInFunctionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1929,7 +1929,7 @@ func TestParseForStatementInFunctionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1991,7 +1991,7 @@ func TestParseAssignment(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2055,7 +2055,7 @@ func TestParseAccessAssignment(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2168,7 +2168,7 @@ func TestParseExpressionStatementWithAccess(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2270,7 +2270,7 @@ func TestParseMoveStatement(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2332,7 +2332,7 @@ func TestParseFunctionExpressionStatementAfterVariableDeclarationWithCreateExpre result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2435,7 +2435,7 @@ func TestParseExpressionStatementAfterReturnStatement(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2496,7 +2496,7 @@ func TestParseSwapStatementInFunctionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2622,7 +2622,7 @@ func TestParseReferenceExpressionStatement(t *testing.T) { castingExpression.ParentVariableDeclaration = expectedVariableDeclaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ expectedVariableDeclaration, &ast.ExpressionStatement{ @@ -2685,7 +2685,7 @@ func TestSoftKeywordsInStatement(t *testing.T) { }, }, } - utils.AssertEqualWithDiff(t, expected, result) + AssertEqualWithDiff(t, expected, result) }) } diff --git a/parser/type_test.go b/parser/type_test.go index 5a741dc03d..e5efe9d92d 100644 --- a/parser/type_test.go +++ b/parser/type_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestParseNominalType(t *testing.T) { @@ -41,7 +41,7 @@ func TestParseNominalType(t *testing.T) { result, errs := testParseType("Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.NominalType{ Identifier: ast.Identifier{ Identifier: "Int", @@ -59,7 +59,7 @@ func TestParseNominalType(t *testing.T) { result, errs := testParseType("Foo.Bar") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.NominalType{ Identifier: ast.Identifier{ Identifier: "Foo", @@ -88,7 +88,7 @@ func TestParseArrayType(t *testing.T) { result, errs := testParseType("[Int]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.VariableSizedType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -112,7 +112,7 @@ func TestParseArrayType(t *testing.T) { result, errs := testParseType("[Int ; 2 ]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ConstantSizedType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -143,7 +143,7 @@ func TestParseArrayType(t *testing.T) { t.Parallel() result, errs := testParseType("[Int ; -2 ]") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: `expected positive integer size for constant sized type`, @@ -166,7 +166,7 @@ func TestParseArrayType(t *testing.T) { t.Parallel() result, errs := testParseType("[Int ; X ]") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: `expected positive integer size for constant sized type`, @@ -176,7 +176,7 @@ func TestParseArrayType(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.VariableSizedType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -206,7 +206,7 @@ func TestParseOptionalType(t *testing.T) { result, errs := testParseType("Int?") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.OptionalType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -227,7 +227,7 @@ func TestParseOptionalType(t *testing.T) { result, errs := testParseType("Int??") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.OptionalType{ Type: &ast.OptionalType{ Type: &ast.NominalType{ @@ -251,7 +251,7 @@ func TestParseOptionalType(t *testing.T) { result, errs := testParseType("Int???") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.OptionalType{ Type: &ast.OptionalType{ Type: &ast.OptionalType{ @@ -283,7 +283,7 @@ func TestParseReferenceType(t *testing.T) { result, errs := testParseType("&Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -302,7 +302,7 @@ func TestParseReferenceType(t *testing.T) { t.Parallel() _, errs := testParseType("auth &Int") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected authorization (entitlement list)", @@ -320,7 +320,7 @@ func TestParseReferenceType(t *testing.T) { result, errs := testParseType("auth(X) &Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceType{ Authorization: &ast.ConjunctiveEntitlementSet{ Elements: []*ast.NominalType{ @@ -351,7 +351,7 @@ func TestParseReferenceType(t *testing.T) { result, errs := testParseType("auth(X, Y) &Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceType{ Authorization: &ast.ConjunctiveEntitlementSet{ Elements: []*ast.NominalType{ @@ -388,7 +388,7 @@ func TestParseReferenceType(t *testing.T) { result, errs := testParseType("auth(X| Y) &Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceType{ Authorization: &ast.DisjunctiveEntitlementSet{ Elements: []*ast.NominalType{ @@ -424,7 +424,7 @@ func TestParseReferenceType(t *testing.T) { _, errs := testParseType("auth() &Int") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in type: ')'", @@ -440,7 +440,7 @@ func TestParseReferenceType(t *testing.T) { t.Parallel() _, errs := testParseType("auth(X, Y | Z) &Int") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: got '|', expected ',' or ')'", @@ -456,7 +456,7 @@ func TestParseReferenceType(t *testing.T) { t.Parallel() _, errs := testParseType("auth(X | Y, Z) &Int") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: got ',', expected '|' or ')'", @@ -474,7 +474,7 @@ func TestParseReferenceType(t *testing.T) { result, errs := testParseType("auth ( mapping X ) & Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceType{ Authorization: &ast.MappedAccess{ EntitlementMap: &ast.NominalType{ @@ -502,7 +502,7 @@ func TestParseReferenceType(t *testing.T) { t.Parallel() _, errs := testParseType("auth( mapping ) &Int") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in type: ')'", @@ -525,7 +525,7 @@ func TestParseOptionalReferenceType(t *testing.T) { result, errs := testParseType("&Int?") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.OptionalType{ Type: &ast.ReferenceType{ Type: &ast.NominalType{ @@ -553,7 +553,7 @@ func TestParseIntersectionType(t *testing.T) { _, errs := testParseType("T{}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &RestrictedTypeError{ Range: ast.Range{ @@ -571,7 +571,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() _, errs := testParseType("T{U}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &RestrictedTypeError{ Range: ast.Range{ @@ -589,7 +589,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() _, errs := testParseType("T{U , V }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &RestrictedTypeError{ Range: ast.Range{ @@ -609,7 +609,7 @@ func TestParseIntersectionType(t *testing.T) { result, errs := testParseType("{}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntersectionType{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 0, Offset: 0}, @@ -627,7 +627,7 @@ func TestParseIntersectionType(t *testing.T) { result, errs := testParseType("{ T }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntersectionType{ Types: []*ast.NominalType{ { @@ -651,7 +651,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{ T , }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing type after comma", @@ -661,7 +661,7 @@ func TestParseIntersectionType(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntersectionType{ Types: []*ast.NominalType{ { @@ -685,7 +685,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{ T U }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected type", @@ -704,7 +704,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{ T , U : V }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in intersection type", @@ -723,7 +723,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{U , V : W }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: `unexpected colon in intersection type`, @@ -742,7 +742,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{[T]}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "non-nominal type in intersection list: [T]", @@ -761,7 +761,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{T, [U]}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "non-nominal type in intersection list: [U]", @@ -780,7 +780,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected type", @@ -798,7 +798,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{U") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected '}'", @@ -816,7 +816,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{U,") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected type", @@ -834,7 +834,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{,}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected comma in intersection type", @@ -859,7 +859,7 @@ func TestParseDictionaryType(t *testing.T) { result, errs := testParseType("{T: U}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryType{ KeyType: &ast.NominalType{ Identifier: ast.Identifier{ @@ -887,7 +887,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing dictionary value type", @@ -897,7 +897,7 @@ func TestParseDictionaryType(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryType{ KeyType: &ast.NominalType{ Identifier: ast.Identifier{ @@ -920,7 +920,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{:}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in dictionary type", @@ -938,7 +938,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{:U}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in dictionary type", @@ -957,7 +957,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:U,}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected comma in dictionary type", @@ -976,7 +976,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:U:}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in dictionary type", @@ -995,7 +995,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T::U}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in dictionary type", @@ -1014,7 +1014,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected type", @@ -1032,7 +1032,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:U") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected '}'", @@ -1057,7 +1057,7 @@ func TestParseFunctionType(t *testing.T) { result, errs := testParseType("fun():Void") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionType{ PurityAnnotation: ast.FunctionPurityUnspecified, ParameterTypeAnnotations: nil, @@ -1087,7 +1087,7 @@ func TestParseFunctionType(t *testing.T) { result, errs := testParseType("view fun ():Void") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionType{ PurityAnnotation: ast.FunctionPurityView, ParameterTypeAnnotations: nil, @@ -1117,7 +1117,7 @@ func TestParseFunctionType(t *testing.T) { result, errs := testParseType("fun( String , Bool , @R ) : Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionType{ ParameterTypeAnnotations: []*ast.TypeAnnotation{ { @@ -1182,7 +1182,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T<>") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1204,7 +1204,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1238,7 +1238,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T< U >") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1272,7 +1272,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T< U , @V >") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1316,7 +1316,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1350,7 +1350,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T< U< V > >") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1404,7 +1404,7 @@ func TestParseParametersAndArrayTypes(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ ParameterList: &ast.ParameterList{ @@ -1696,7 +1696,7 @@ func TestParseDictionaryTypeInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2018,7 +2018,7 @@ func TestParseIntegerTypes(t *testing.T) { StartPos: ast.Position{Offset: 137, Line: 9, Column: 2}, } - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{a, b, c, d, e, f, g, h}, result.Declarations(), ) @@ -2034,7 +2034,7 @@ func TestParseFunctionTypeInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2112,7 +2112,7 @@ func TestParseFunctionArrayType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2196,7 +2196,7 @@ func TestParseFunctionTypeWithArrayReturnType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2291,7 +2291,7 @@ func TestParseFunctionTypeWithFunctionReturnType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2451,7 +2451,7 @@ func TestParseViewFunctionTypeWithNewSyntax(t *testing.T) { StartPos: ast.Position{Offset: 3, Line: 2, Column: 2}, }, } - utils.AssertEqualWithDiff(t, expected, result.Declarations()) + AssertEqualWithDiff(t, expected, result.Declarations()) } func TestParseNewSyntaxFunctionType(t *testing.T) { @@ -2534,7 +2534,7 @@ func TestParseNewSyntaxFunctionType(t *testing.T) { StartPos: ast.Position{Offset: 3, Line: 2, Column: 2}, }, } - utils.AssertEqualWithDiff(t, expected, result.Declarations()) + AssertEqualWithDiff(t, expected, result.Declarations()) } func TestParseOptionalTypeDouble(t *testing.T) { @@ -2547,7 +2547,7 @@ func TestParseOptionalTypeDouble(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2602,7 +2602,7 @@ func TestParseFunctionTypeWithResourceTypeAnnotation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2659,7 +2659,7 @@ func TestParseReferenceTypeInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2720,7 +2720,7 @@ func TestParseOptionalReference(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2775,7 +2775,7 @@ func TestParseIntersectionReferenceType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2835,7 +2835,7 @@ func TestParseOptionalIntersectionType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2894,7 +2894,7 @@ func TestParseAuthorizedReferenceTypeWithNoEntitlements(t *testing.T) { ` _, errs := testParseProgram(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected authorization (entitlement list)", @@ -2915,7 +2915,7 @@ func TestParseInstantiationTypeInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2991,7 +2991,7 @@ func TestParseConstantSizedSizedArrayWithTrailingUnderscoreSize(t *testing.T) { let T:[d;0_]=0 `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0_", @@ -3044,7 +3044,7 @@ func TestParseParenthesizedTypes(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, prog.Declarations()) + AssertEqualWithDiff(t, expected, prog.Declarations()) } func TestParseNestedParenthesizedTypes(t *testing.T) { @@ -3084,5 +3084,5 @@ func TestParseNestedParenthesizedTypes(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, prog.Declarations()) + AssertEqualWithDiff(t, expected, prog.Declarations()) } diff --git a/runtime/account_test.go b/runtime/account_test.go index 371cbba4cb..0d65fa3ecd 100644 --- a/runtime/account_test.go +++ b/runtime/account_test.go @@ -35,10 +35,10 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestRuntimeAccountKeyConstructor(t *testing.T) { @@ -998,7 +998,7 @@ func TestRuntimePublicAccountKeys(t *testing.T) { value, err := test.executeScript(testEnv.runtime, testEnv.runtimeInterface) require.NoError(t, err) - utils.AssertEqualWithDiff(t, cadence.Void{}, value) + AssertEqualWithDiff(t, cadence.Void{}, value) keys := make(map[int]*AccountKey, len(testEnv.storage.keys)) for _, key := range testEnv.storage.keys { @@ -1043,7 +1043,7 @@ func TestRuntimePublicAccountKeys(t *testing.T) { value, err := test.executeScript(testEnv.runtime, testEnv.runtimeInterface) require.NoError(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, cadence.NewOptional(cadence.String("Optional.map")), value, ) diff --git a/runtime/attachments_test.go b/runtime/attachments_test.go index e03c72dc22..4d3d400d1b 100644 --- a/runtime/attachments_test.go +++ b/runtime/attachments_test.go @@ -28,8 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeAccountAttachmentSaveAndLoad(t *testing.T) { diff --git a/runtime/capabilities_test.go b/runtime/capabilities_test.go index ade86c8d24..3e76980213 100644 --- a/runtime/capabilities_test.go +++ b/runtime/capabilities_test.go @@ -27,8 +27,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeCapability_borrowAndCheck(t *testing.T) { diff --git a/runtime/capabilitycontrollers_test.go b/runtime/capabilitycontrollers_test.go index fbb0d924cc..fc6f692fe4 100644 --- a/runtime/capabilitycontrollers_test.go +++ b/runtime/capabilitycontrollers_test.go @@ -32,8 +32,8 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeCapabilityControllers(t *testing.T) { diff --git a/runtime/contract_test.go b/runtime/contract_test.go index 6cd2b4caaa..2bb89a2cb5 100644 --- a/runtime/contract_test.go +++ b/runtime/contract_test.go @@ -33,9 +33,10 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestRuntimeContract(t *testing.T) { diff --git a/runtime/contract_update_test.go b/runtime/contract_update_test.go index c032eb7124..48a0ec8e48 100644 --- a/runtime/contract_update_test.go +++ b/runtime/contract_update_test.go @@ -29,8 +29,8 @@ import ( "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeContractUpdateWithDependencies(t *testing.T) { diff --git a/runtime/contract_update_validation_test.go b/runtime/contract_update_validation_test.go index f4e77b8c85..74afc1c447 100644 --- a/runtime/contract_update_validation_test.go +++ b/runtime/contract_update_validation_test.go @@ -33,8 +33,8 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func newContractDeployTransaction(function, name, code string) string { diff --git a/runtime/convertTypes_test.go b/runtime/convertTypes_test.go index fea1f8a697..3e50371edd 100644 --- a/runtime/convertTypes_test.go +++ b/runtime/convertTypes_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestRuntimeExportRecursiveType(t *testing.T) { @@ -36,7 +36,7 @@ func TestRuntimeExportRecursiveType(t *testing.T) { t.Parallel() ty := &sema.CompositeType{ - Location: utils.TestLocation, + Location: TestLocation, Identifier: "Foo", Kind: common.CompositeKindResource, Members: &sema.StringMemberOrderedMap{}, @@ -60,7 +60,7 @@ func TestRuntimeExportRecursiveType(t *testing.T) { } expected := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", fields, nil, @@ -94,7 +94,7 @@ func BenchmarkExportType(b *testing.B) { b.Run("composite type", func(b *testing.B) { ty := &sema.CompositeType{ - Location: utils.TestLocation, + Location: TestLocation, Identifier: "Foo", Kind: common.CompositeKindResource, Members: &sema.StringMemberOrderedMap{}, @@ -118,7 +118,7 @@ func BenchmarkExportType(b *testing.B) { } expected := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", fields, nil, diff --git a/runtime/convertValues_test.go b/runtime/convertValues_test.go index bebbf750ca..f6cf51fcb2 100644 --- a/runtime/convertValues_test.go +++ b/runtime/convertValues_test.go @@ -37,8 +37,9 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeExportValue(t *testing.T) { diff --git a/runtime/coverage_test.go b/runtime/coverage_test.go index 2c244b4c4d..5f5f746113 100644 --- a/runtime/coverage_test.go +++ b/runtime/coverage_test.go @@ -31,8 +31,7 @@ import ( "github.com/onflow/cadence/parser" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeNewLocationCoverage(t *testing.T) { @@ -1816,7 +1815,7 @@ func TestRuntimeCoverageWithNoStatements(t *testing.T) { } coverageReport.ExcludeLocation(txLocation) - deploy := utils.DeploymentTransaction("FooContract", contract) + deploy := DeploymentTransaction("FooContract", contract) err := runtime.ExecuteTransaction( Script{ Source: deploy, diff --git a/runtime/crypto_test.go b/runtime/crypto_test.go index 71da0b283a..fcce37cf8b 100644 --- a/runtime/crypto_test.go +++ b/runtime/crypto_test.go @@ -33,7 +33,7 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeHashAlgorithm_hash(t *testing.T) { diff --git a/runtime/debugger_test.go b/runtime/debugger_test.go index 7d5d5f8907..b9d060775e 100644 --- a/runtime/debugger_test.go +++ b/runtime/debugger_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeDebugger(t *testing.T) { diff --git a/runtime/deployedcontract_test.go b/runtime/deployedcontract_test.go index b73b16f71d..bae773da2e 100644 --- a/runtime/deployedcontract_test.go +++ b/runtime/deployedcontract_test.go @@ -26,8 +26,7 @@ import ( "github.com/onflow/cadence" "github.com/onflow/cadence/common" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeDeployedContracts(t *testing.T) { @@ -104,7 +103,7 @@ func TestRuntimeDeployedContracts(t *testing.T) { // deploy the contract err := rt.ExecuteTransaction( Script{ - Source: utils.DeploymentTransaction("Test", []byte(contractCode)), + Source: DeploymentTransaction("Test", []byte(contractCode)), }, newContext(), ) diff --git a/runtime/deployment_test.go b/runtime/deployment_test.go index 6b6cbe83bd..4d1ab95280 100644 --- a/runtime/deployment_test.go +++ b/runtime/deployment_test.go @@ -34,8 +34,9 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeTransactionWithContractDeployment(t *testing.T) { diff --git a/runtime/entitlements_test.go b/runtime/entitlements_test.go index d241cb6c4d..428e56615d 100644 --- a/runtime/entitlements_test.go +++ b/runtime/entitlements_test.go @@ -28,9 +28,8 @@ import ( "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestRuntimeAccountEntitlementSaveAndLoadSuccess(t *testing.T) { diff --git a/runtime/error_test.go b/runtime/error_test.go index a27aecbcf2..4d74c390c1 100644 --- a/runtime/error_test.go +++ b/runtime/error_test.go @@ -31,7 +31,7 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeError(t *testing.T) { diff --git a/runtime/ft_test.go b/runtime/ft_test.go index 5d7d78b5e6..b9374d986e 100644 --- a/runtime/ft_test.go +++ b/runtime/ft_test.go @@ -31,8 +31,9 @@ import ( "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/runtime_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) const modifiedFungibleTokenContractInterface = ` @@ -627,7 +628,7 @@ func BenchmarkRuntimeFungibleTokenTransfer(b *testing.B) { err := runtime.ExecuteTransaction( Script{ - Source: utils.DeploymentTransaction( + Source: DeploymentTransaction( "FungibleToken", []byte(modifiedFungibleTokenContractInterface), ), @@ -644,7 +645,7 @@ func BenchmarkRuntimeFungibleTokenTransfer(b *testing.B) { err = runtime.ExecuteTransaction( Script{ - Source: utils.DeploymentTransaction("FlowToken", []byte(modifiedFlowContract)), + Source: DeploymentTransaction("FlowToken", []byte(modifiedFlowContract)), }, Context{ Interface: runtimeInterface, @@ -767,7 +768,7 @@ func BenchmarkRuntimeFungibleTokenTransfer(b *testing.B) { sum = sum.Plus(inter, value, interpreter.EmptyLocationRange).(interpreter.UFix64Value) } - utils.RequireValuesEqual(b, nil, mintAmountValue, sum) + RequireValuesEqual(b, nil, mintAmountValue, sum) } const oldExampleToken = ` @@ -1043,7 +1044,7 @@ func TestRuntimeBrokenFungibleTokenRecovery(t *testing.T) { err := runtime.ExecuteTransaction( Script{ - Source: utils.DeploymentTransaction( + Source: DeploymentTransaction( "FungibleToken", []byte(modifiedFungibleTokenContractInterface), ), @@ -1222,7 +1223,7 @@ func TestRuntimeBrokenFungibleTokenRecovery(t *testing.T) { Environment: environment, }, ) - utils.RequireError(t, err) + RequireError(t, err) require.ErrorContains(t, err, "Vault.withdraw is not available in recovered program") t.Log(err.Error()) diff --git a/runtime/import_test.go b/runtime/import_test.go index 295353b5f6..cbc92d7401 100644 --- a/runtime/import_test.go +++ b/runtime/import_test.go @@ -30,9 +30,9 @@ import ( "github.com/onflow/cadence/encoding/json" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestRuntimeCyclicImport(t *testing.T) { diff --git a/runtime/imported_values_memory_metering_test.go b/runtime/imported_values_memory_metering_test.go index c3e7a882a8..d7620f27e9 100644 --- a/runtime/imported_values_memory_metering_test.go +++ b/runtime/imported_values_memory_metering_test.go @@ -29,8 +29,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/encoding/json" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func testUseMemory(meter map[common.MemoryKind]uint64) func(common.MemoryUsage) error { @@ -628,7 +628,7 @@ func TestRuntimeScriptDecodedLocationMetering(t *testing.T) { }, ) - utils.RequireError(t, err) + RequireError(t, err) var entryPointErr *InvalidEntryPointArgumentError require.ErrorAs(t, err, &entryPointErr) diff --git a/runtime/inbox_test.go b/runtime/inbox_test.go index 00380e23e4..7017e4a5d9 100644 --- a/runtime/inbox_test.go +++ b/runtime/inbox_test.go @@ -30,7 +30,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/encoding/json" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeAccountInboxPublishUnpublish(t *testing.T) { diff --git a/runtime/literal_test.go b/runtime/literal_test.go index e35033b250..6109662007 100644 --- a/runtime/literal_test.go +++ b/runtime/literal_test.go @@ -29,8 +29,8 @@ import ( "github.com/onflow/cadence/common" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestRuntimeParseLiteral(t *testing.T) { diff --git a/runtime/predeclaredvalues_test.go b/runtime/predeclaredvalues_test.go index c60d3efb5b..9b916a3c0f 100644 --- a/runtime/predeclaredvalues_test.go +++ b/runtime/predeclaredvalues_test.go @@ -33,9 +33,9 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestRuntimePredeclaredValues(t *testing.T) { diff --git a/runtime/program_params_validation_test.go b/runtime/program_params_validation_test.go index 2e1a7f3ec1..5cc5485f9d 100644 --- a/runtime/program_params_validation_test.go +++ b/runtime/program_params_validation_test.go @@ -30,9 +30,9 @@ import ( "github.com/onflow/cadence/encoding/json" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestRuntimeScriptParameterTypeValidation(t *testing.T) { diff --git a/runtime/resource_duplicate_test.go b/runtime/resource_duplicate_test.go index 5f5f12c666..9304dfb07a 100644 --- a/runtime/resource_duplicate_test.go +++ b/runtime/resource_duplicate_test.go @@ -29,8 +29,8 @@ import ( "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeResourceDuplicationWithContractTransferInTransaction(t *testing.T) { diff --git a/runtime/resourcedictionary_test.go b/runtime/resourcedictionary_test.go index 088d4e977f..a1a5100423 100644 --- a/runtime/resourcedictionary_test.go +++ b/runtime/resourcedictionary_test.go @@ -29,8 +29,7 @@ import ( "github.com/onflow/cadence" "github.com/onflow/cadence/common" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) const resourceDictionaryContract = ` @@ -94,7 +93,7 @@ func TestRuntimeResourceDictionaryValues(t *testing.T) { contract := []byte(resourceDictionaryContract) - deploy := utils.DeploymentTransaction("Test", contract) + deploy := DeploymentTransaction("Test", contract) setupTx := []byte(` import Test from 0xCADE @@ -450,7 +449,7 @@ func TestRuntimeResourceDictionaryValues_Nested(t *testing.T) { } `) - deploy := utils.DeploymentTransaction("Test", contract) + deploy := DeploymentTransaction("Test", contract) setupTx := []byte(` import Test from 0xCADE @@ -754,7 +753,7 @@ func TestRuntimeResourceDictionaryValues_Removal(t *testing.T) { contract := []byte(resourceDictionaryContract) - deployTx := utils.DeploymentTransaction("Test", contract) + deployTx := DeploymentTransaction("Test", contract) setupTx := []byte(` import Test from 0x1 @@ -883,7 +882,7 @@ func TestRuntimeResourceDictionaryValues_Destruction(t *testing.T) { contract := []byte(resourceDictionaryContract) - deployTx := utils.DeploymentTransaction("Test", contract) + deployTx := DeploymentTransaction("Test", contract) setupTx := []byte(` import Test from 0x1 @@ -996,7 +995,7 @@ func TestRuntimeResourceDictionaryValues_Insertion(t *testing.T) { contract := []byte(resourceDictionaryContract) - deployTx := utils.DeploymentTransaction("Test", contract) + deployTx := DeploymentTransaction("Test", contract) setupTx := []byte(` import Test from 0x1 @@ -1137,7 +1136,7 @@ func TestRuntimeResourceDictionaryValues_ValueTransferAndDestroy(t *testing.T) { contract := []byte(resourceDictionaryContract) - deployTx := utils.DeploymentTransaction("Test", contract) + deployTx := DeploymentTransaction("Test", contract) setupTx := []byte(` import Test from 0x1 @@ -1330,7 +1329,7 @@ func BenchmarkRuntimeResourceDictionaryValues(b *testing.B) { } `) - deploy := utils.DeploymentTransaction("Test", contract) + deploy := DeploymentTransaction("Test", contract) setupTx := []byte(` import Test from 0xCADE diff --git a/runtime/rlp_test.go b/runtime/rlp_test.go index 17582dceee..93cfaa1ed6 100644 --- a/runtime/rlp_test.go +++ b/runtime/rlp_test.go @@ -28,8 +28,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/encoding/json" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeRLPDecodeString(t *testing.T) { diff --git a/runtime/runtime_memory_metering_test.go b/runtime/runtime_memory_metering_test.go index f7e91fd7bf..d6d389ff73 100644 --- a/runtime/runtime_memory_metering_test.go +++ b/runtime/runtime_memory_metering_test.go @@ -31,8 +31,8 @@ import ( "github.com/onflow/cadence/encoding/json" "github.com/onflow/cadence/errors" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) type testMemoryGauge struct { diff --git a/runtime/runtime_test.go b/runtime/runtime_test.go index 07e76ce395..91b7bcdc86 100644 --- a/runtime/runtime_test.go +++ b/runtime/runtime_test.go @@ -43,9 +43,9 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestRuntimeImport(t *testing.T) { diff --git a/runtime/sharedstate_test.go b/runtime/sharedstate_test.go index 660c439b1c..3008c85fff 100644 --- a/runtime/sharedstate_test.go +++ b/runtime/sharedstate_test.go @@ -28,8 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeSharedState(t *testing.T) { diff --git a/runtime/storage_test.go b/runtime/storage_test.go index b82b77a2cb..5a7bb60bc9 100644 --- a/runtime/storage_test.go +++ b/runtime/storage_test.go @@ -36,8 +36,9 @@ import ( "github.com/onflow/cadence/encoding/json" "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func withWritesToStorage( diff --git a/runtime/type_test.go b/runtime/type_test.go index 2ae870e408..c96a705675 100644 --- a/runtime/type_test.go +++ b/runtime/type_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence" "github.com/onflow/cadence/common" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeTypeStorage(t *testing.T) { diff --git a/runtime/validation_test.go b/runtime/validation_test.go index 980654b941..db212f8547 100644 --- a/runtime/validation_test.go +++ b/runtime/validation_test.go @@ -28,8 +28,8 @@ import ( "github.com/onflow/cadence/encoding/json" "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) // TestRuntimeArgumentImportMissingType tests if errors produced while validating diff --git a/sema/accesses_test.go b/sema/accesses_test.go index eaa4dc16a9..976e30811e 100644 --- a/sema/accesses_test.go +++ b/sema/accesses_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func expectSuccess(t *testing.T, err error) { diff --git a/sema/account_test.go b/sema/account_test.go index e993ed7303..6084a5042b 100644 --- a/sema/account_test.go +++ b/sema/account_test.go @@ -27,8 +27,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckAccountStorageSave(t *testing.T) { @@ -888,7 +888,7 @@ func TestCheckAccountStorageBorrow(t *testing.T) { sema.NewEntitlementSetAccess( []*sema.EntitlementType{ { - Location: utils.TestLocation, + Location: TestLocation, Identifier: "X", }, }, diff --git a/sema/any_test.go b/sema/any_test.go index 6e35846d12..c9c0c76222 100644 --- a/sema/any_test.go +++ b/sema/any_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckAnyStruct(t *testing.T) { diff --git a/sema/arrays_dictionaries_test.go b/sema/arrays_dictionaries_test.go index 20a306fe04..6e5a512d05 100644 --- a/sema/arrays_dictionaries_test.go +++ b/sema/arrays_dictionaries_test.go @@ -30,7 +30,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckDictionary(t *testing.T) { diff --git a/sema/assert_test.go b/sema/assert_test.go index 2912bf380b..0c19bdc57e 100644 --- a/sema/assert_test.go +++ b/sema/assert_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckAssertWithoutMessage(t *testing.T) { diff --git a/sema/assignment_test.go b/sema/assignment_test.go index 3d415c16ee..96494ccde0 100644 --- a/sema/assignment_test.go +++ b/sema/assignment_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidUnknownDeclarationAssignment(t *testing.T) { diff --git a/sema/attachments_test.go b/sema/attachments_test.go index c1609e8e0b..d7d5e62447 100644 --- a/sema/attachments_test.go +++ b/sema/attachments_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckAttachmentBasic(t *testing.T) { diff --git a/sema/boolean_test.go b/sema/boolean_test.go index 6d4e0cde0d..7c6202a5c2 100644 --- a/sema/boolean_test.go +++ b/sema/boolean_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckBoolean(t *testing.T) { diff --git a/sema/builtinfunctions_test.go b/sema/builtinfunctions_test.go index 41a956d1d1..07ca190593 100644 --- a/sema/builtinfunctions_test.go +++ b/sema/builtinfunctions_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckToString(t *testing.T) { diff --git a/sema/capability_controller_test.go b/sema/capability_controller_test.go index d2ab30eda3..994f600999 100644 --- a/sema/capability_controller_test.go +++ b/sema/capability_controller_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckStorageCapabilityController(t *testing.T) { diff --git a/sema/capability_test.go b/sema/capability_test.go index 155442dc12..cb430f7b82 100644 --- a/sema/capability_test.go +++ b/sema/capability_test.go @@ -22,13 +22,12 @@ import ( "fmt" "testing" - "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - . "github.com/onflow/cadence/tests/sema_utils" + "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckCapability(t *testing.T) { @@ -94,7 +93,7 @@ func TestCheckCapability_borrow(t *testing.T) { for _, auth := range []sema.Access{sema.UnauthorizedAccess, sema.NewEntitlementSetAccess([]*sema.EntitlementType{{ - Location: utils.TestLocation, + Location: TestLocation, Identifier: "X", }}, sema.Conjunction), } { @@ -321,7 +320,7 @@ func TestCheckCapability_check(t *testing.T) { for _, auth := range []sema.Access{sema.UnauthorizedAccess, sema.NewEntitlementSetAccess([]*sema.EntitlementType{{ - Location: utils.TestLocation, + Location: TestLocation, Identifier: "X", }}, sema.Conjunction), } { diff --git a/sema/casting_test.go b/sema/casting_test.go index e107a4615b..b77dbdc466 100644 --- a/sema/casting_test.go +++ b/sema/casting_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckCastingIntLiteralToIntegerType(t *testing.T) { diff --git a/sema/character_test.go b/sema/character_test.go index 318b101dbc..7b7c664e95 100644 --- a/sema/character_test.go +++ b/sema/character_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckCharacterLiteral(t *testing.T) { diff --git a/sema/composite_test.go b/sema/composite_test.go index 6598505d98..dc6c8dc927 100644 --- a/sema/composite_test.go +++ b/sema/composite_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/errors" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidCompositeRedeclaringType(t *testing.T) { diff --git a/sema/conditional_test.go b/sema/conditional_test.go index 98ec1a75a7..c4db51acd5 100644 --- a/sema/conditional_test.go +++ b/sema/conditional_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckConditionalExpressionTest(t *testing.T) { diff --git a/sema/conditions_test.go b/sema/conditions_test.go index d845c52c1d..afcc7762fc 100644 --- a/sema/conditions_test.go +++ b/sema/conditions_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckFunctionTestConditions(t *testing.T) { diff --git a/sema/conformance_test.go b/sema/conformance_test.go index 6109516c58..d2f873cab5 100644 --- a/sema/conformance_test.go +++ b/sema/conformance_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckEventNonTypeRequirementConformance(t *testing.T) { diff --git a/sema/contract_test.go b/sema/contract_test.go index 2de30e7d68..e21b6d7873 100644 --- a/sema/contract_test.go +++ b/sema/contract_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidContractAccountField(t *testing.T) { diff --git a/sema/crypto_test.go b/sema/crypto_test.go index 91397e95ea..e6f751395d 100644 --- a/sema/crypto_test.go +++ b/sema/crypto_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckHashAlgorithmCases(t *testing.T) { diff --git a/sema/declaration_test.go b/sema/declaration_test.go index 738c4c6d34..139ae9e332 100644 --- a/sema/declaration_test.go +++ b/sema/declaration_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckConstantAndVariableDeclarations(t *testing.T) { diff --git a/sema/dictionary_test.go b/sema/dictionary_test.go index 900c53860e..edd9dd83cb 100644 --- a/sema/dictionary_test.go +++ b/sema/dictionary_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckIncompleteDictionaryType(t *testing.T) { diff --git a/sema/dynamic_casting_test.go b/sema/dynamic_casting_test.go index 15861bc8e7..da02975b35 100644 --- a/sema/dynamic_casting_test.go +++ b/sema/dynamic_casting_test.go @@ -28,8 +28,8 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) var dynamicCastingOperations = []ast.Operation{ @@ -1207,7 +1207,7 @@ func TestCheckDynamicCastingCapability(t *testing.T) { t.Parallel() structType := &sema.CompositeType{ - Location: utils.TestLocation, + Location: TestLocation, Identifier: "S", Kind: common.CompositeKindStructure, } diff --git a/sema/entitlements_test.go b/sema/entitlements_test.go index caa5dd36e4..3b47df81b3 100644 --- a/sema/entitlements_test.go +++ b/sema/entitlements_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckBasicEntitlementDeclaration(t *testing.T) { diff --git a/sema/entrypoint_test.go b/sema/entrypoint_test.go index ac76190b26..e3bc9ab1a1 100644 --- a/sema/entrypoint_test.go +++ b/sema/entrypoint_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckEntryPointParameters(t *testing.T) { diff --git a/sema/enum_test.go b/sema/enum_test.go index 2fc3233336..96d092297c 100644 --- a/sema/enum_test.go +++ b/sema/enum_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidNonEnumCompositeEnumCases(t *testing.T) { diff --git a/sema/error_handling_test.go b/sema/error_handling_test.go index cc84b43316..a7cb4923c2 100644 --- a/sema/error_handling_test.go +++ b/sema/error_handling_test.go @@ -27,8 +27,8 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckErrorShortCircuiting(t *testing.T) { @@ -82,7 +82,7 @@ func TestCheckErrorShortCircuiting(t *testing.T) { access(all) let y = Y `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, Config: &sema.Config{ ErrorShortCircuitingEnabled: true, }, diff --git a/sema/events_test.go b/sema/events_test.go index d1c588392f..e3d6cdbbea 100644 --- a/sema/events_test.go +++ b/sema/events_test.go @@ -29,8 +29,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckEventDeclaration(t *testing.T) { @@ -295,7 +295,7 @@ func TestCheckEmitEvent(t *testing.T) { access(all) event Transfer(to: Int, from: Int) `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) require.NoError(t, err) diff --git a/sema/external_mutation_test.go b/sema/external_mutation_test.go index 3eabd29a5a..96936fa073 100644 --- a/sema/external_mutation_test.go +++ b/sema/external_mutation_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckArrayUpdateIndexAccess(t *testing.T) { diff --git a/sema/fixedpoint_test.go b/sema/fixedpoint_test.go index a1f0eb15e5..bb537432b8 100644 --- a/sema/fixedpoint_test.go +++ b/sema/fixedpoint_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/format" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckFixedPointLiteralTypeConversionInVariableDeclaration(t *testing.T) { diff --git a/sema/for_test.go b/sema/for_test.go index 8e2f68dcb8..7a92fc90a8 100644 --- a/sema/for_test.go +++ b/sema/for_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckForVariableSized(t *testing.T) { diff --git a/sema/force_test.go b/sema/force_test.go index c3d0f41f5c..63b93013d8 100644 --- a/sema/force_test.go +++ b/sema/force_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckForce(t *testing.T) { diff --git a/sema/function_expression_test.go b/sema/function_expression_test.go index 5bb0467941..3ba5f2e6b4 100644 --- a/sema/function_expression_test.go +++ b/sema/function_expression_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidFunctionExpressionReturnValue(t *testing.T) { diff --git a/sema/function_test.go b/sema/function_test.go index 334f1ee2c7..1f823f9a23 100644 --- a/sema/function_test.go +++ b/sema/function_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckReferenceInFunction(t *testing.T) { diff --git a/sema/gen/golden_test.go b/sema/gen/golden_test.go index 0053427d45..62555c9176 100644 --- a/sema/gen/golden_test.go +++ b/sema/gen/golden_test.go @@ -43,7 +43,7 @@ import ( _ "github.com/onflow/cadence/sema/gen/testdata/simple_struct" _ "github.com/onflow/cadence/sema/gen/testdata/storable" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestConstructor(t *testing.T) { diff --git a/sema/genericfunction_test.go b/sema/genericfunction_test.go index 6b3e443db1..f88e9ac00a 100644 --- a/sema/genericfunction_test.go +++ b/sema/genericfunction_test.go @@ -30,7 +30,7 @@ import ( "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func parseAndCheckWithTestValue(t *testing.T, code string, ty sema.Type) (*sema.Checker, error) { diff --git a/sema/hashable_struct_test.go b/sema/hashable_struct_test.go index 51f432bf25..82875b9f95 100644 --- a/sema/hashable_struct_test.go +++ b/sema/hashable_struct_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckHashableStruct(t *testing.T) { diff --git a/sema/if_test.go b/sema/if_test.go index 0674d66d97..6fd1e517c7 100644 --- a/sema/if_test.go +++ b/sema/if_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckIfStatementTest(t *testing.T) { diff --git a/sema/import_test.go b/sema/import_test.go index 9e92714fa9..c5bf92d36e 100644 --- a/sema/import_test.go +++ b/sema/import_test.go @@ -30,8 +30,8 @@ import ( "github.com/onflow/cadence/errors" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidImport(t *testing.T) { @@ -57,7 +57,7 @@ func TestCheckRepeatedImport(t *testing.T) { access(all) let y = 2 `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) require.NoError(t, err) @@ -170,7 +170,7 @@ func TestCheckInvalidRepeatedImport(t *testing.T) { access(all) let x = 1 `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) @@ -288,7 +288,7 @@ func TestCheckImportAll(t *testing.T) { } `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) @@ -323,7 +323,7 @@ func TestCheckInvalidImportUnexported(t *testing.T) { access(all) let x = 1 `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) @@ -364,7 +364,7 @@ func TestCheckImportSome(t *testing.T) { access(all) let x = 1 `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) @@ -447,7 +447,7 @@ func TestCheckImportTypes(t *testing.T) { body, ), ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) @@ -553,7 +553,7 @@ func TestCheckInvalidImportCycleSelf(t *testing.T) { return err } - err = check(code, utils.TestLocation) + err = check(code, TestLocation) errs := RequireCheckerErrors(t, err, 1) @@ -740,7 +740,7 @@ func TestCheckImportContract(t *testing.T) { } }`, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) @@ -788,7 +788,7 @@ func TestCheckImportContract(t *testing.T) { } }`, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) diff --git a/sema/indexing_test.go b/sema/indexing_test.go index 5eabac65ff..1979e67610 100644 --- a/sema/indexing_test.go +++ b/sema/indexing_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckArrayIndexingWithInteger(t *testing.T) { diff --git a/sema/initialization_test.go b/sema/initialization_test.go index 832bb2724e..a4656a2e3c 100644 --- a/sema/initialization_test.go +++ b/sema/initialization_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) // TODO: test multiple initializers once overloading is supported diff --git a/sema/integer_test.go b/sema/integer_test.go index 1fdcf5963f..5f53f7b0ed 100644 --- a/sema/integer_test.go +++ b/sema/integer_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) var allIntegerTypesAndAddressType = common.Concat( diff --git a/sema/interface_test.go b/sema/interface_test.go index b43b4f7573..48fc511f4a 100644 --- a/sema/interface_test.go +++ b/sema/interface_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func constructorArguments(compositeKind common.CompositeKind) string { diff --git a/sema/intersection_test.go b/sema/intersection_test.go index 763d16f1b4..e0965d843a 100644 --- a/sema/intersection_test.go +++ b/sema/intersection_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckIntersectionType(t *testing.T) { diff --git a/sema/invalid_test.go b/sema/invalid_test.go index 87e85d7a28..51ea254984 100644 --- a/sema/invalid_test.go +++ b/sema/invalid_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckSpuriousIdentifierAssignmentInvalidValueTypeMismatch(t *testing.T) { diff --git a/sema/invocation_test.go b/sema/invocation_test.go index 11abdd4073..1d0543b2cb 100644 --- a/sema/invocation_test.go +++ b/sema/invocation_test.go @@ -28,8 +28,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidFunctionCallWithTooFewArguments(t *testing.T) { @@ -375,7 +375,7 @@ func TestCheckArgumentLabels(t *testing.T) { fun test(foo bar: Int, baz: String) {} `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) @@ -436,7 +436,7 @@ func TestCheckArgumentLabels(t *testing.T) { } `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) @@ -497,7 +497,7 @@ func TestCheckArgumentLabels(t *testing.T) { } `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) @@ -562,7 +562,7 @@ func TestCheckArgumentLabels(t *testing.T) { } `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) diff --git a/sema/member_test.go b/sema/member_test.go index 94fd50858b..9d8706dbbe 100644 --- a/sema/member_test.go +++ b/sema/member_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckOptionalChainingNonOptionalFieldRead(t *testing.T) { diff --git a/sema/metatype_test.go b/sema/metatype_test.go index fcf185510f..3f5455b0a0 100644 --- a/sema/metatype_test.go +++ b/sema/metatype_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckMetaType(t *testing.T) { diff --git a/sema/move_test.go b/sema/move_test.go index 0791f6f744..d772f2f293 100644 --- a/sema/move_test.go +++ b/sema/move_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidMoves(t *testing.T) { diff --git a/sema/nesting_test.go b/sema/nesting_test.go index 184e566224..cd0cd659cf 100644 --- a/sema/nesting_test.go +++ b/sema/nesting_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckCompositeDeclarationNesting(t *testing.T) { diff --git a/sema/never_test.go b/sema/never_test.go index 5195786007..ee3ba85b1c 100644 --- a/sema/never_test.go +++ b/sema/never_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckNever(t *testing.T) { diff --git a/sema/nil_coalescing_test.go b/sema/nil_coalescing_test.go index 0f7c0364fd..2e6d505cfb 100644 --- a/sema/nil_coalescing_test.go +++ b/sema/nil_coalescing_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckNilCoalescingNilIntToOptional(t *testing.T) { diff --git a/sema/occurrences_test.go b/sema/occurrences_test.go index a1854e5cef..cb4454e170 100644 --- a/sema/occurrences_test.go +++ b/sema/occurrences_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) // TODO: implement occurrences for type references diff --git a/sema/operations_test.go b/sema/operations_test.go index c5f460bc28..319e3ee5f3 100644 --- a/sema/operations_test.go +++ b/sema/operations_test.go @@ -30,7 +30,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidUnaryBooleanNegationOfInteger(t *testing.T) { diff --git a/sema/optional_test.go b/sema/optional_test.go index ea92b679e3..98e797855e 100644 --- a/sema/optional_test.go +++ b/sema/optional_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckOptional(t *testing.T) { diff --git a/sema/overloading_test.go b/sema/overloading_test.go index 77cdea966b..dfe464e1b9 100644 --- a/sema/overloading_test.go +++ b/sema/overloading_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidCompositeInitializerOverloading(t *testing.T) { diff --git a/sema/path_test.go b/sema/path_test.go index 0b3fcd1215..5aceafd85e 100644 --- a/sema/path_test.go +++ b/sema/path_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckPath(t *testing.T) { diff --git a/sema/pragma_test.go b/sema/pragma_test.go index 1795e86df7..1ee6e070bb 100644 --- a/sema/pragma_test.go +++ b/sema/pragma_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckPragmaExpression(t *testing.T) { diff --git a/sema/predeclaredvalues_test.go b/sema/predeclaredvalues_test.go index b402b49c80..046ea7435a 100644 --- a/sema/predeclaredvalues_test.go +++ b/sema/predeclaredvalues_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckPredeclaredValues(t *testing.T) { diff --git a/sema/purity_test.go b/sema/purity_test.go index 2df908b4cd..76a79255d9 100644 --- a/sema/purity_test.go +++ b/sema/purity_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckPuritySubtyping(t *testing.T) { diff --git a/sema/range_test.go b/sema/range_test.go index 752cb93f64..94919757fd 100644 --- a/sema/range_test.go +++ b/sema/range_test.go @@ -27,8 +27,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckRange(t *testing.T) { @@ -96,7 +96,7 @@ func TestCheckRange(t *testing.T) { // assert that the unordered repr of expected matches that of ranges assertSetsEqual := func(t *testing.T, expected []sema.Range, ranges map[sema.Range]int) { bag := getCounts(expected) - utils.AssertEqualWithDiff(t, bag, ranges) + AssertEqualWithDiff(t, bag, ranges) } barTypeVariable, ok := checker.Elaboration.GetGlobalType("_TEST_Bar") diff --git a/sema/range_value_test.go b/sema/range_value_test.go index 1598aee163..12929896b5 100644 --- a/sema/range_value_test.go +++ b/sema/range_value_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) type inclusiveRangeConstructionTest struct { diff --git a/sema/reference_test.go b/sema/reference_test.go index b05629424f..0914180f30 100644 --- a/sema/reference_test.go +++ b/sema/reference_test.go @@ -28,8 +28,8 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckReference(t *testing.T) { @@ -1067,7 +1067,7 @@ func TestCheckReferenceExpressionReferenceType(t *testing.T) { refValueType := RequireGlobalValue(t, checker.Elaboration, "ref") xType := RequireGlobalType(t, checker.Elaboration, "X").(*sema.EntitlementType) - var access sema.Access = sema.UnauthorizedAccess + var access = sema.UnauthorizedAccess if !auth.Equal(sema.UnauthorizedAccess) { access = sema.NewEntitlementSetAccess([]*sema.EntitlementType{xType}, sema.Conjunction) } @@ -1089,7 +1089,7 @@ func TestCheckReferenceExpressionReferenceType(t *testing.T) { for _, auth := range []sema.Access{ sema.UnauthorizedAccess, sema.NewEntitlementSetAccess([]*sema.EntitlementType{{ - Location: utils.TestLocation, + Location: TestLocation, Identifier: "X", }}, sema.Conjunction), } { @@ -1930,7 +1930,7 @@ func TestCheckInvalidatedReferenceUse(t *testing.T) { } `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) diff --git a/sema/resource_test.go b/sema/resource_test.go index 1bfe40da3b..f46d1d08a7 100644 --- a/sema/resource_test.go +++ b/sema/resource_test.go @@ -25,12 +25,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + . "github.com/onflow/cadence/test_utils/sema_utils" + "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestCheckFailableCastingWithResourceAnnotation(t *testing.T) { diff --git a/sema/return_test.go b/sema/return_test.go index 5f9b20ed5b..61f7f54835 100644 --- a/sema/return_test.go +++ b/sema/return_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidReturnValue(t *testing.T) { diff --git a/sema/rlp_test.go b/sema/rlp_test.go index b079b03c33..216c1829fb 100644 --- a/sema/rlp_test.go +++ b/sema/rlp_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckRLPDecodeString(t *testing.T) { diff --git a/sema/runtimetype_test.go b/sema/runtimetype_test.go index 8d8b444c70..22a46b6248 100644 --- a/sema/runtimetype_test.go +++ b/sema/runtimetype_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckOptionalTypeConstructor(t *testing.T) { diff --git a/sema/storable_test.go b/sema/storable_test.go index 3720107e70..23c0b96722 100644 --- a/sema/storable_test.go +++ b/sema/storable_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckStorable(t *testing.T) { diff --git a/sema/string_test.go b/sema/string_test.go index 23c0ff8001..5faa94b3d9 100644 --- a/sema/string_test.go +++ b/sema/string_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckCharacter(t *testing.T) { diff --git a/sema/swap_test.go b/sema/swap_test.go index 63fb658906..9f39ffdff5 100644 --- a/sema/swap_test.go +++ b/sema/swap_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidUnknownDeclarationSwap(t *testing.T) { diff --git a/sema/switch_test.go b/sema/switch_test.go index 38328f1645..197e1dd5d5 100644 --- a/sema/switch_test.go +++ b/sema/switch_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckSwitchStatementTest(t *testing.T) { diff --git a/sema/transactions_test.go b/sema/transactions_test.go index 79b362d918..dd80079ecd 100644 --- a/sema/transactions_test.go +++ b/sema/transactions_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckTransactions(t *testing.T) { diff --git a/sema/type_inference_test.go b/sema/type_inference_test.go index 85a338eaf3..db3dcb247d 100644 --- a/sema/type_inference_test.go +++ b/sema/type_inference_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckArrayElementTypeInference(t *testing.T) { diff --git a/sema/typeargument_test.go b/sema/typeargument_test.go index 66895844d4..cbb85a5ff5 100644 --- a/sema/typeargument_test.go +++ b/sema/typeargument_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckTypeArguments(t *testing.T) { diff --git a/sema/utils_test.go b/sema/utils_test.go index d65f31264d..f19512f82b 100644 --- a/sema/utils_test.go +++ b/sema/utils_test.go @@ -24,7 +24,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func ParseAndCheckWithPanic(t *testing.T, code string) (*sema.Checker, error) { diff --git a/sema/while_test.go b/sema/while_test.go index 9d40353678..3922b94315 100644 --- a/sema/while_test.go +++ b/sema/while_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidWhileTest(t *testing.T) { diff --git a/stdlib/account_test.go b/stdlib/account_test.go index 0fbd4f1164..2429663cc2 100644 --- a/stdlib/account_test.go +++ b/stdlib/account_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestSemaCheckPathLiteralForInternalStorageDomains(t *testing.T) { @@ -75,7 +75,7 @@ func TestCanBorrow(t *testing.T) { `) typeID := func(qualifiedIdentifier string) sema.TypeID { - return utils.TestLocation.TypeID(nil, qualifiedIdentifier) + return TestLocation.TypeID(nil, qualifiedIdentifier) } entitlementE := inter.Program.Elaboration.EntitlementType(typeID("E")) diff --git a/stdlib/builtin_test.go b/stdlib/builtin_test.go index 46bbed8071..9ac63b1ff5 100644 --- a/stdlib/builtin_test.go +++ b/stdlib/builtin_test.go @@ -21,17 +21,16 @@ package stdlib import ( "testing" - "github.com/onflow/cadence/activations" - "github.com/onflow/cadence/common" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/onflow/cadence/activations" + "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func newUnmeteredInMemoryStorage() interpreter.InMemoryStorage { @@ -53,7 +52,7 @@ func newInterpreter(t *testing.T, code string, valueDeclarations ...StandardLibr checker, err := sema.NewChecker( program, - utils.TestLocation, + TestLocation, nil, &sema.Config{ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { @@ -184,7 +183,7 @@ func TestInterpretAssert(t *testing.T) { Err: AssertionError{ Message: "oops", }, - Location: utils.TestLocation, + Location: TestLocation, }, err, ) @@ -195,7 +194,7 @@ func TestInterpretAssert(t *testing.T) { Err: AssertionError{ Message: "", }, - Location: utils.TestLocation, + Location: TestLocation, }, err) @@ -278,7 +277,7 @@ func TestInterpretPanic(t *testing.T) { Err: PanicError{ Message: "oops", }, - Location: utils.TestLocation, + Location: TestLocation, }, err, ) diff --git a/stdlib/cadence_v0.42_to_v1_contract_upgrade_validation_test.go b/stdlib/cadence_v0.42_to_v1_contract_upgrade_validation_test.go index 365f0eeaf8..3aa074687b 100644 --- a/stdlib/cadence_v0.42_to_v1_contract_upgrade_validation_test.go +++ b/stdlib/cadence_v0.42_to_v1_contract_upgrade_validation_test.go @@ -33,8 +33,8 @@ import ( "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/runtime_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func testContractUpdate(t *testing.T, oldCode string, newCode string) error { @@ -46,7 +46,7 @@ func testContractUpdate(t *testing.T, oldCode string, newCode string) error { checker, err := sema.NewChecker( newProgram, - utils.TestLocation, + TestLocation, nil, &sema.Config{ AccessCheckMode: sema.AccessCheckModeStrict, @@ -59,13 +59,13 @@ func testContractUpdate(t *testing.T, oldCode string, newCode string) error { program := interpreter.ProgramFromChecker(checker) upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( - utils.TestLocation, + TestLocation, "Test", - &runtime_utils.TestRuntimeInterface{}, + &TestRuntimeInterface{}, oldProgram, program, map[common.Location]*sema.Elaboration{ - utils.TestLocation: checker.Elaboration, + TestLocation: checker.Elaboration, }) return upgradeValidator.Validate() } @@ -87,7 +87,7 @@ func testContractUpdateWithImports( upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -744,7 +744,7 @@ func TestContractUpgradeFieldType(t *testing.T) { upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -818,7 +818,7 @@ func TestContractUpgradeFieldType(t *testing.T) { upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -896,7 +896,7 @@ func TestContractUpgradeFieldType(t *testing.T) { upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -919,7 +919,7 @@ func TestContractUpgradeFieldType(t *testing.T) { // This should be an error. // If there are custom rules, they MUST be followed. - utils.RequireError(t, err) + RequireError(t, err) cause := getSingleContractUpdateErrorCause(t, err, "Test") var fieldMismatchError *stdlib.FieldMismatchError @@ -1031,7 +1031,7 @@ func TestContractUpgradeFieldType(t *testing.T) { upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -1161,7 +1161,7 @@ func TestContractUpgradeFieldType(t *testing.T) { upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -1257,7 +1257,7 @@ func TestContractUpgradeFieldType(t *testing.T) { upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -2443,7 +2443,7 @@ func TestInterfaceConformanceChange(t *testing.T) { upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -2528,7 +2528,7 @@ func TestInterfaceConformanceChange(t *testing.T) { upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -2602,7 +2602,7 @@ func TestInterfaceConformanceChange(t *testing.T) { upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -2626,7 +2626,7 @@ func TestInterfaceConformanceChange(t *testing.T) { // This should be an error. // If there are custom rules, they MUST be followed. - utils.RequireError(t, err) + RequireError(t, err) cause := getSingleContractUpdateErrorCause(t, err, "Test") var conformanceMismatchError *stdlib.ConformanceMismatchError @@ -2742,7 +2742,7 @@ func TestEnumUpdates(t *testing.T) { ` err := testContractUpdate(t, oldCode, newCode) - utils.RequireError(t, err) + RequireError(t, err) cause := getSingleContractUpdateErrorCause(t, err, "Test") var conformanceMismatchError *stdlib.ConformanceMismatchError @@ -2773,7 +2773,7 @@ func TestEnumUpdates(t *testing.T) { ` err := testContractUpdate(t, oldCode, newCode) - utils.RequireError(t, err) + RequireError(t, err) cause := getSingleContractUpdateErrorCause(t, err, "Test") var missingEnumCasesError *stdlib.MissingEnumCasesError diff --git a/stdlib/rlp/rlp_test.go b/stdlib/rlp/rlp_test.go index f707026356..ce07309d82 100644 --- a/stdlib/rlp/rlp_test.go +++ b/stdlib/rlp/rlp_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/stdlib/rlp" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestRLPReadSize(t *testing.T) { diff --git a/stdlib/test_test.go b/stdlib/test_test.go index 47592a0de2..9e602af451 100644 --- a/stdlib/test_test.go +++ b/stdlib/test_test.go @@ -34,8 +34,8 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func newTestContractInterpreter(t *testing.T, code string) (*interpreter.Interpreter, error) { @@ -65,7 +65,7 @@ func newTestContractInterpreterWithTestFramework( checker, err := sema.NewChecker( program, - utils.TestLocation, + TestLocation, nil, &sema.Config{ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { diff --git a/test_utils/common_utils/utils.go b/test_utils/common_utils/utils.go new file mode 100644 index 0000000000..009494e373 --- /dev/null +++ b/test_utils/common_utils/utils.go @@ -0,0 +1,112 @@ +/* + * Cadence - The resource-oriented smart contract programming language + * + * Copyright Flow Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package common_utils + +import ( + "strings" + "testing" + + "github.com/k0kubun/pp" + "github.com/kr/pretty" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/onflow/cadence/ast" + "github.com/onflow/cadence/errors" + + "github.com/onflow/cadence/common" +) + +func init() { + pp.ColoringEnabled = false +} + +// TestLocation is used as the default location for programs in tests. +const TestLocation = common.StringLocation("test") + +// ImportedLocation is used as the default location for imported programs in tests. +const ImportedLocation = common.StringLocation("imported") + +// AssertEqualWithDiff asserts that two objects are equal. +// +// If the objects are not equal, this function prints a human-readable diff. +func AssertEqualWithDiff(t *testing.T, expected, actual any) { + + // the maximum levels of a struct to recurse into + // this prevents infinite recursion from circular references + diff := pretty.Diff(expected, actual) + + if len(diff) != 0 { + s := strings.Builder{} + + for i, d := range diff { + if i == 0 { + s.WriteString("diff : ") + } else { + s.WriteString(" ") + } + + s.WriteString(d) + s.WriteString("\n") + } + + t.Errorf( + "Not equal: \n"+ + "expected: %s\n"+ + "actual : %s\n\n"+ + "%s", + pp.Sprint(expected), + pp.Sprint(actual), + s.String(), + ) + } +} + +// RequireError is a wrapper around require.Error which also ensures +// that the error message, the secondary message (if any), +// and the error notes' (if any) messages can be successfully produced +func RequireError(t *testing.T, err error) { + require.Error(t, err) + + _ = err.Error() + + if hasImportLocation, ok := err.(common.HasLocation); ok { + location := hasImportLocation.ImportLocation() + assert.NotNil(t, location) + } + + if hasPosition, ok := err.(ast.HasPosition); ok { + _ = hasPosition.StartPosition() + _ = hasPosition.EndPosition(nil) + } + + if hasErrorNotes, ok := err.(errors.ErrorNotes); ok { + for _, note := range hasErrorNotes.ErrorNotes() { + _ = note.Message() + } + } + + if hasSecondaryError, ok := err.(errors.SecondaryError); ok { + _ = hasSecondaryError.SecondaryError() + } + + if hasSuggestedFixes, ok := err.(errors.HasSuggestedFixes[ast.TextEdit]); ok { + _ = hasSuggestedFixes.SuggestFixes("") + } +} diff --git a/tests/runtime_utils/interpreter.go b/test_utils/interpreter_utils/interpreter.go similarity index 92% rename from tests/runtime_utils/interpreter.go rename to test_utils/interpreter_utils/interpreter.go index e7458be09b..46a8182023 100644 --- a/tests/runtime_utils/interpreter.go +++ b/test_utils/interpreter_utils/interpreter.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package runtime_utils +package interpreter_utils import ( "testing" @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/interpreter" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func NewTestInterpreter(tb testing.TB) *interpreter.Interpreter { @@ -32,7 +32,7 @@ func NewTestInterpreter(tb testing.TB) *interpreter.Interpreter { inter, err := interpreter.NewInterpreter( nil, - utils.TestLocation, + TestLocation, &interpreter.Config{ Storage: storage, AtreeValueValidationEnabled: true, diff --git a/tests/utils/utils.go b/test_utils/interpreter_utils/values.go similarity index 56% rename from tests/utils/utils.go rename to test_utils/interpreter_utils/values.go index 1c6d840712..f271ba944b 100644 --- a/tests/utils/utils.go +++ b/test_utils/interpreter_utils/values.go @@ -16,113 +16,37 @@ * limitations under the License. */ -package utils +package interpreter_utils import ( - "encoding/hex" "fmt" "strings" "testing" - "github.com/k0kubun/pp" "github.com/kr/pretty" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/onflow/cadence/ast" - "github.com/onflow/cadence/errors" "github.com/onflow/cadence/interpreter" - - "github.com/onflow/cadence/common" ) -func init() { - pp.ColoringEnabled = false +func RequireValuesEqual(t testing.TB, inter *interpreter.Interpreter, expected, actual interpreter.Value) { + if !AssertValuesEqual(t, inter, expected, actual) { + t.FailNow() + } } -// TestLocation is used as the default location for programs in tests. -const TestLocation = common.StringLocation("test") - -// ImportedLocation is used as the default location for imported programs in tests. -const ImportedLocation = common.StringLocation("imported") - -// AssertEqualWithDiff asserts that two objects are equal. -// -// If the objects are not equal, this function prints a human-readable diff. -func AssertEqualWithDiff(t *testing.T, expected, actual any) { - - // the maximum levels of a struct to recurse into - // this prevents infinite recursion from circular references - diff := pretty.Diff(expected, actual) - - if len(diff) != 0 { - s := strings.Builder{} - - for i, d := range diff { - if i == 0 { - s.WriteString("diff : ") - } else { - s.WriteString(" ") - } +func AssertValueSlicesEqual(t testing.TB, inter *interpreter.Interpreter, expected, actual []interpreter.Value) bool { + if !assert.Equal(t, len(expected), len(actual)) { + return false + } - s.WriteString(d) - s.WriteString("\n") + for i, value := range expected { + if !AssertValuesEqual(t, inter, value, actual[i]) { + return false } - - t.Errorf( - "Not equal: \n"+ - "expected: %s\n"+ - "actual : %s\n\n"+ - "%s", - pp.Sprint(expected), - pp.Sprint(actual), - s.String(), - ) } -} - -func DeploymentTransaction(name string, contract []byte) []byte { - return []byte(fmt.Sprintf( - ` - transaction { - - prepare(signer: auth(Contracts) &Account) { - signer.contracts.add(name: "%s", code: "%s".decodeHex()) - } - } - `, - name, - hex.EncodeToString(contract), - )) -} - -func RemovalTransaction(name string) []byte { - return []byte(fmt.Sprintf( - ` - transaction { - prepare(signer: auth(Contracts) &Account) { - signer.contracts.remove(name: "%s") - } - } - `, - name, - )) -} - -func UpdateTransaction(name string, contract []byte) []byte { - return []byte(fmt.Sprintf( - ` - transaction { - - prepare(signer: auth(Contracts) &Account) { - signer.contracts.update(name: "%s", code: "%s".decodeHex()) - } - } - `, - name, - hex.EncodeToString(contract), - )) + return true } func ValuesAreEqual(inter *interpreter.Interpreter, expected, actual interpreter.Value) bool { @@ -173,59 +97,6 @@ func AssertValuesEqual(t testing.TB, interpreter *interpreter.Interpreter, expec return true } -func RequireValuesEqual(t testing.TB, inter *interpreter.Interpreter, expected, actual interpreter.Value) { - if !AssertValuesEqual(t, inter, expected, actual) { - t.FailNow() - } -} - -func AssertValueSlicesEqual(t testing.TB, inter *interpreter.Interpreter, expected, actual []interpreter.Value) bool { - if !assert.Equal(t, len(expected), len(actual)) { - return false - } - - for i, value := range expected { - if !AssertValuesEqual(t, inter, value, actual[i]) { - return false - } - } - - return true -} - -// RequireError is a wrapper around require.Error which also ensures -// that the error message, the secondary message (if any), -// and the error notes' (if any) messages can be successfully produced -func RequireError(t *testing.T, err error) { - require.Error(t, err) - - _ = err.Error() - - if hasImportLocation, ok := err.(common.HasLocation); ok { - location := hasImportLocation.ImportLocation() - assert.NotNil(t, location) - } - - if hasPosition, ok := err.(ast.HasPosition); ok { - _ = hasPosition.StartPosition() - _ = hasPosition.EndPosition(nil) - } - - if hasErrorNotes, ok := err.(errors.ErrorNotes); ok { - for _, note := range hasErrorNotes.ErrorNotes() { - _ = note.Message() - } - } - - if hasSecondaryError, ok := err.(errors.SecondaryError); ok { - _ = hasSecondaryError.SecondaryError() - } - - if hasSuggestedFixes, ok := err.(errors.HasSuggestedFixes[ast.TextEdit]); ok { - _ = hasSuggestedFixes.SuggestFixes("") - } -} - func ArrayElements(inter *interpreter.Interpreter, array *interpreter.ArrayValue) []interpreter.Value { count := array.Count() result := make([]interpreter.Value, count) diff --git a/tests/runtime_utils/location.go b/test_utils/runtime_utils/location.go similarity index 100% rename from tests/runtime_utils/location.go rename to test_utils/runtime_utils/location.go diff --git a/tests/runtime_utils/testinterface.go b/test_utils/runtime_utils/testinterface.go similarity index 100% rename from tests/runtime_utils/testinterface.go rename to test_utils/runtime_utils/testinterface.go diff --git a/tests/runtime_utils/testledger.go b/test_utils/runtime_utils/testledger.go similarity index 100% rename from tests/runtime_utils/testledger.go rename to test_utils/runtime_utils/testledger.go diff --git a/tests/runtime_utils/testruntime.go b/test_utils/runtime_utils/testruntime.go similarity index 100% rename from tests/runtime_utils/testruntime.go rename to test_utils/runtime_utils/testruntime.go diff --git a/test_utils/runtime_utils/transactions.go b/test_utils/runtime_utils/transactions.go new file mode 100644 index 0000000000..72f8af976c --- /dev/null +++ b/test_utils/runtime_utils/transactions.go @@ -0,0 +1,68 @@ +/* + * Cadence - The resource-oriented smart contract programming language + * + * Copyright Flow Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package runtime_utils + +import ( + "encoding/hex" + "fmt" +) + +func DeploymentTransaction(name string, contract []byte) []byte { + return []byte(fmt.Sprintf( + ` + transaction { + + prepare(signer: auth(Contracts) &Account) { + signer.contracts.add(name: "%s", code: "%s".decodeHex()) + } + } + `, + name, + hex.EncodeToString(contract), + )) +} + +func RemovalTransaction(name string) []byte { + return []byte(fmt.Sprintf( + ` + transaction { + + prepare(signer: auth(Contracts) &Account) { + signer.contracts.remove(name: "%s") + } + } + `, + name, + )) +} + +func UpdateTransaction(name string, contract []byte) []byte { + return []byte(fmt.Sprintf( + ` + transaction { + + prepare(signer: auth(Contracts) &Account) { + signer.contracts.update(name: "%s", code: "%s".decodeHex()) + } + } + `, + name, + hex.EncodeToString(contract), + )) +} diff --git a/tests/sema_utils/utils.go b/test_utils/sema_utils/utils.go similarity index 97% rename from tests/sema_utils/utils.go rename to test_utils/sema_utils/utils.go index 23d1e7756e..220d0e653f 100644 --- a/tests/sema_utils/utils.go +++ b/test_utils/sema_utils/utils.go @@ -25,7 +25,6 @@ import ( "testing" gopretty "github.com/kr/pretty" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -33,7 +32,7 @@ import ( "github.com/onflow/cadence/parser" "github.com/onflow/cadence/pretty" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func ParseAndCheck(t testing.TB, code string) (*sema.Checker, error) { @@ -69,7 +68,7 @@ func ParseAndCheckWithOptionsAndMemoryMetering( ) (*sema.Checker, error) { if options.Location == nil { - options.Location = utils.TestLocation + options.Location = TestLocation } program, err := parser.ParseProgram(memoryGauge, []byte(code), options.ParseOptions) @@ -170,7 +169,7 @@ func RequireCheckerErrors(t *testing.T, err error, count int) []error { return nil } - utils.RequireError(t, err) + RequireError(t, err) var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) @@ -182,7 +181,7 @@ func RequireCheckerErrors(t *testing.T, err error, count int) []error { // Get the error message, to check that it can be successfully generated for _, checkerErr := range errs { - utils.RequireError(t, checkerErr) + RequireError(t, checkerErr) } return errs diff --git a/tools/analysis/analysis_test.go b/tools/analysis/analysis_test.go index 0baebceefa..da09e6dd74 100644 --- a/tools/analysis/analysis_test.go +++ b/tools/analysis/analysis_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" "github.com/onflow/cadence/tools/analysis" ) diff --git a/tools/compatibility-check/contracts_checker.go b/tools/compatibility-check/contracts_checker.go index 887cb02a0c..99bd2149c4 100644 --- a/tools/compatibility-check/contracts_checker.go +++ b/tools/compatibility-check/contracts_checker.go @@ -19,14 +19,13 @@ package compatibility_check import ( + "encoding/csv" "fmt" "io" "log" "reflect" "strings" - "encoding/csv" - "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/parser" diff --git a/types_test.go b/types_test.go index 27f0edd4c9..45412ae7c5 100644 --- a/types_test.go +++ b/types_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestType_ID(t *testing.T) { @@ -85,7 +85,7 @@ func TestType_ID(t *testing.T) { }, { &StructType{ - Location: utils.TestLocation, + Location: TestLocation, QualifiedIdentifier: "Foo", }, "S.test.Foo", @@ -98,7 +98,7 @@ func TestType_ID(t *testing.T) { }, { &StructInterfaceType{ - Location: utils.TestLocation, + Location: TestLocation, QualifiedIdentifier: "FooI", }, "S.test.FooI", @@ -111,7 +111,7 @@ func TestType_ID(t *testing.T) { }, { &ResourceType{ - Location: utils.TestLocation, + Location: TestLocation, QualifiedIdentifier: "Bar", }, "S.test.Bar", @@ -124,7 +124,7 @@ func TestType_ID(t *testing.T) { }, { &ResourceInterfaceType{ - Location: utils.TestLocation, + Location: TestLocation, QualifiedIdentifier: "BarI", }, "S.test.BarI", @@ -133,7 +133,7 @@ func TestType_ID(t *testing.T) { &IntersectionType{ Types: []Type{ &ResourceInterfaceType{ - Location: utils.TestLocation, + Location: TestLocation, QualifiedIdentifier: "FooI", }, }, @@ -167,7 +167,7 @@ func TestType_ID(t *testing.T) { }, { &EventType{ - Location: utils.TestLocation, + Location: TestLocation, QualifiedIdentifier: "Event", }, "S.test.Event", @@ -180,7 +180,7 @@ func TestType_ID(t *testing.T) { }, { &EnumType{ - Location: utils.TestLocation, + Location: TestLocation, QualifiedIdentifier: "Enum", }, "S.test.Enum", @@ -193,7 +193,7 @@ func TestType_ID(t *testing.T) { }, { &ContractType{ - Location: utils.TestLocation, + Location: TestLocation, QualifiedIdentifier: "Contract", }, "S.test.Contract", @@ -206,7 +206,7 @@ func TestType_ID(t *testing.T) { }, { &ContractInterfaceType{ - Location: utils.TestLocation, + Location: TestLocation, QualifiedIdentifier: "ContractI", }, "S.test.ContractI", @@ -2287,7 +2287,7 @@ func TestDecodeFields(t *testing.T) { NewStruct([]Value{ NewInt(42), }).WithType(NewStructType( - utils.TestLocation, + TestLocation, "NestedStruct", []Field{ { @@ -2299,7 +2299,7 @@ func TestDecodeFields(t *testing.T) { )), }, ).WithType(NewEventType( - utils.TestLocation, + TestLocation, "SimpleEvent", []Field{ { diff --git a/values_test.go b/values_test.go index d70200a911..ac5ea3b067 100644 --- a/values_test.go +++ b/values_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) type valueTestCase struct { @@ -242,7 +242,7 @@ func newValueTestCases() map[string]valueTestCase { "struct": { value: NewStruct([]Value{String("bar")}), exampleType: NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []Field{ { @@ -260,7 +260,7 @@ func newValueTestCases() map[string]valueTestCase { "resource": { value: NewResource([]Value{NewInt(1)}), exampleType: NewResourceType( - utils.TestLocation, + TestLocation, "FooResource", []Field{ { @@ -283,7 +283,7 @@ func newValueTestCases() map[string]valueTestCase { }, ), exampleType: NewEventType( - utils.TestLocation, + TestLocation, "FooEvent", []Field{ { @@ -305,7 +305,7 @@ func newValueTestCases() map[string]valueTestCase { "contract": { value: NewContract([]Value{String("bar")}), exampleType: NewContractType( - utils.TestLocation, + TestLocation, "FooContract", []Field{ { @@ -323,7 +323,7 @@ func newValueTestCases() map[string]valueTestCase { "enum": { value: NewEnum([]Value{UInt8(1)}), exampleType: NewEnumType( - utils.TestLocation, + TestLocation, "FooEnum", nil, []Field{ @@ -342,7 +342,7 @@ func newValueTestCases() map[string]valueTestCase { "attachment": { value: NewAttachment([]Value{NewInt(1)}), exampleType: NewAttachmentType( - utils.TestLocation, + TestLocation, "FooAttachment", nil, []Field{ @@ -960,7 +960,7 @@ func TestEvent_GetFieldByName(t *testing.T) { assert.Nil(t, SearchFieldByName(simpleEvent, "a")) simpleEventWithType := simpleEvent.WithType(NewEventType( - utils.TestLocation, + TestLocation, "SimpleEvent", []Field{ {