diff --git a/Makefile b/Makefile index c14880b9f5..16b7bd328f 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,7 @@ ci: # test all packages go test -coverprofile=coverage.txt -covermode=atomic -parallel 8 -race -coverpkg $(COVERPKGS) ./... # run interpreter smoke tests. results from run above are reused, so no tests runs are duplicated - go test -count=5 ./tests/interpreter/... -runSmokeTests=true -validateAtree=false + go test -count=5 ./interpreter/... -runSmokeTests=true -validateAtree=false # remove coverage of empty functions from report sed -i -e 's/^.* 0 0$$//' coverage.txt diff --git a/cmd/info/main.go b/cmd/info/main.go index 5f737ba99c..62a91f8a6c 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/checker" + "github.com/onflow/cadence/tests/sema_utils" ) type command struct { @@ -80,7 +80,7 @@ var commands = map[string]command{ func dumpBuiltinTypes() { - allBaseSemaTypes := checker.AllBaseSemaTypes() + allBaseSemaTypes := sema_utils.AllBaseSemaTypes() types := make([]sema.Type, 0, len(allBaseSemaTypes)) @@ -239,7 +239,7 @@ func dumpBuiltinValues() { ty sema.Type } - allBaseSemaValueTypes := checker.AllBaseSemaValueTypes() + allBaseSemaValueTypes := sema_utils.AllBaseSemaValueTypes() standardLibraryValues := stdlib.DefaultScriptStandardLibraryValues(nil) valueTypes := make([]valueType, 0, len(allBaseSemaValueTypes)+len(standardLibraryValues)) diff --git a/compiler/compiler_test.go b/compiler/compiler_test.go index 17acf177d1..60c96154aa 100644 --- a/compiler/compiler_test.go +++ b/compiler/compiler_test.go @@ -24,12 +24,12 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/compiler/ir" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCompilerSimple(t *testing.T) { - checker, err := checker.ParseAndCheck(t, ` + checker, err := ParseAndCheck(t, ` fun inc(a: Int): Int { let mod = 1 return a + mod diff --git a/docs/development.md b/docs/development.md index 4a166bba19..477bcf6222 100644 --- a/docs/development.md +++ b/docs/development.md @@ -83,7 +83,7 @@ contains command-line tools that are useful when working on the implementation f Run the checker tests with the `cadence.checkConcurrently` flag, e.g. ```shell -go test -race -v ./tests/checker -cadence.checkConcurrently=10 +go test -race -v ./sema/... -cadence.checkConcurrently=10 ``` This runs each check of a checker test 10 times, concurrently, diff --git a/encoding/ccf/ccf_test.go b/encoding/ccf/ccf_test.go index db427edd67..3332bbb065 100644 --- a/encoding/ccf/ccf_test.go +++ b/encoding/ccf/ccf_test.go @@ -38,8 +38,8 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) @@ -4949,7 +4949,7 @@ func TestEncodeSortedDictionary(t *testing.T) { } func exportFromScript(t *testing.T, code string) cadence.Value { - checker, err := checker.ParseAndCheck(t, code) + checker, err := ParseAndCheck(t, code) require.NoError(t, err) var uuid uint64 diff --git a/encoding/json/encoding_test.go b/encoding/json/encoding_test.go index 5a22360dd0..308c8e0e7c 100644 --- a/encoding/json/encoding_test.go +++ b/encoding/json/encoding_test.go @@ -31,7 +31,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/runtime" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence" "github.com/onflow/cadence/sema" @@ -1123,7 +1123,7 @@ func TestEncodeDictionary(t *testing.T) { } func exportFromScript(t *testing.T, code string) cadence.Value { - checker, err := checker.ParseAndCheck(t, code) + checker, err := ParseAndCheck(t, code) require.NoError(t, err) var uuid uint64 = 0 diff --git a/tests/interpreter/account_test.go b/interpreter/account_test.go similarity index 100% rename from tests/interpreter/account_test.go rename to interpreter/account_test.go diff --git a/tests/interpreter/arithmetic_test.go b/interpreter/arithmetic_test.go similarity index 100% rename from tests/interpreter/arithmetic_test.go rename to interpreter/arithmetic_test.go diff --git a/tests/interpreter/array_test.go b/interpreter/array_test.go similarity index 100% rename from tests/interpreter/array_test.go rename to interpreter/array_test.go diff --git a/tests/interpreter/attachments_test.go b/interpreter/attachments_test.go similarity index 100% rename from tests/interpreter/attachments_test.go rename to interpreter/attachments_test.go diff --git a/tests/interpreter/bitwise_test.go b/interpreter/bitwise_test.go similarity index 100% rename from tests/interpreter/bitwise_test.go rename to interpreter/bitwise_test.go diff --git a/tests/interpreter/builtinfunctions_test.go b/interpreter/builtinfunctions_test.go similarity index 100% rename from tests/interpreter/builtinfunctions_test.go rename to interpreter/builtinfunctions_test.go diff --git a/tests/interpreter/character_test.go b/interpreter/character_test.go similarity index 100% rename from tests/interpreter/character_test.go rename to interpreter/character_test.go diff --git a/tests/interpreter/composite_value_test.go b/interpreter/composite_value_test.go similarity index 100% rename from tests/interpreter/composite_value_test.go rename to interpreter/composite_value_test.go diff --git a/tests/interpreter/condition_test.go b/interpreter/condition_test.go similarity index 99% rename from tests/interpreter/condition_test.go rename to interpreter/condition_test.go index 34d56d2f14..74d1deabc9 100644 --- a/tests/interpreter/condition_test.go +++ b/interpreter/condition_test.go @@ -31,7 +31,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -855,7 +855,7 @@ func TestInterpretInitializerWithInterfacePreCondition(t *testing.T) { ) } - checker, err := checker.ParseAndCheck(t, + checker, err := ParseAndCheck(t, fmt.Sprintf( ` access(all) diff --git a/tests/interpreter/container_mutation_test.go b/interpreter/container_mutation_test.go similarity index 100% rename from tests/interpreter/container_mutation_test.go rename to interpreter/container_mutation_test.go diff --git a/tests/interpreter/contract_test.go b/interpreter/contract_test.go similarity index 100% rename from tests/interpreter/contract_test.go rename to interpreter/contract_test.go diff --git a/tests/interpreter/declaration_test.go b/interpreter/declaration_test.go similarity index 100% rename from tests/interpreter/declaration_test.go rename to interpreter/declaration_test.go diff --git a/interpreter/deepcopyremove_test.go b/interpreter/deepcopyremove_test.go index 5521332900..de16e42445 100644 --- a/interpreter/deepcopyremove_test.go +++ b/interpreter/deepcopyremove_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/common" - . "github.com/onflow/cadence/interpreter" + "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/tests/utils" ) @@ -38,49 +38,49 @@ func TestValueDeepCopyAndDeepRemove(t *testing.T) { storage := newUnmeteredInMemoryStorage() - inter, err := NewInterpreter( + inter, err := interpreter.NewInterpreter( nil, utils.TestLocation, - &Config{ + &interpreter.Config{ Storage: storage, }, ) require.NoError(t, err) - dictionaryStaticType := &DictionaryStaticType{ - KeyType: PrimitiveStaticTypeString, - ValueType: PrimitiveStaticTypeInt256, + dictionaryStaticType := &interpreter.DictionaryStaticType{ + KeyType: interpreter.PrimitiveStaticTypeString, + ValueType: interpreter.PrimitiveStaticTypeInt256, } - dictValueKey := NewUnmeteredStringValue( + dictValueKey := interpreter.NewUnmeteredStringValue( strings.Repeat("x", int(atree.MaxInlineMapKeySize()+1)), ) - dictValueValue := NewUnmeteredInt256ValueFromInt64(1) - dictValue := NewDictionaryValue( + dictValueValue := interpreter.NewUnmeteredInt256ValueFromInt64(1) + dictValue := interpreter.NewDictionaryValue( inter, - EmptyLocationRange, + interpreter.EmptyLocationRange, dictionaryStaticType, dictValueKey, dictValueValue, ) - arrayValue := NewArrayValue( + arrayValue := interpreter.NewArrayValue( inter, - EmptyLocationRange, - &VariableSizedStaticType{ + interpreter.EmptyLocationRange, + &interpreter.VariableSizedStaticType{ Type: dictionaryStaticType, }, common.ZeroAddress, dictValue, ) - optionalValue := NewUnmeteredSomeValueNonCopying(arrayValue) + optionalValue := interpreter.NewUnmeteredSomeValueNonCopying(arrayValue) compositeValue := newTestCompositeValue(inter, address) compositeValue.SetMember( inter, - EmptyLocationRange, + interpreter.EmptyLocationRange, "value", optionalValue, ) @@ -99,7 +99,3 @@ func TestValueDeepCopyAndDeepRemove(t *testing.T) { require.Equal(t, 1, count) } - -func newUnmeteredInMemoryStorage() InMemoryStorage { - return NewInMemoryStorage(nil) -} diff --git a/tests/interpreter/dictionary_test.go b/interpreter/dictionary_test.go similarity index 100% rename from tests/interpreter/dictionary_test.go rename to interpreter/dictionary_test.go diff --git a/tests/interpreter/dynamic_casting_test.go b/interpreter/dynamic_casting_test.go similarity index 100% rename from tests/interpreter/dynamic_casting_test.go rename to interpreter/dynamic_casting_test.go diff --git a/tests/interpreter/entitlements_test.go b/interpreter/entitlements_test.go similarity index 100% rename from tests/interpreter/entitlements_test.go rename to interpreter/entitlements_test.go diff --git a/tests/interpreter/enum_test.go b/interpreter/enum_test.go similarity index 100% rename from tests/interpreter/enum_test.go rename to interpreter/enum_test.go diff --git a/tests/interpreter/equality_test.go b/interpreter/equality_test.go similarity index 100% rename from tests/interpreter/equality_test.go rename to interpreter/equality_test.go diff --git a/tests/interpreter/fixedpoint_test.go b/interpreter/fixedpoint_test.go similarity index 100% rename from tests/interpreter/fixedpoint_test.go rename to interpreter/fixedpoint_test.go diff --git a/tests/interpreter/for_test.go b/interpreter/for_test.go similarity index 100% rename from tests/interpreter/for_test.go rename to interpreter/for_test.go diff --git a/tests/interpreter/function_test.go b/interpreter/function_test.go similarity index 97% rename from tests/interpreter/function_test.go rename to interpreter/function_test.go index f2e4675e4e..e4e293fa9c 100644 --- a/tests/interpreter/function_test.go +++ b/interpreter/function_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/checker" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) @@ -221,7 +221,7 @@ func TestInterpretResultVariable(t *testing.T) { ) require.NoError(t, err) require.Len(t, checkerErrors, 1) - checkerError := checker.RequireCheckerErrors(t, checkerErrors[0], 1) + checkerError := RequireCheckerErrors(t, checkerErrors[0], 1) require.IsType(t, &sema.PurityError{}, checkerError[0]) _, err = inter.Invoke("main") @@ -280,7 +280,7 @@ func TestInterpretResultVariable(t *testing.T) { ) require.NoError(t, err) require.Len(t, checkerErrors, 1) - checkerError := checker.RequireCheckerErrors(t, checkerErrors[0], 1) + checkerError := RequireCheckerErrors(t, checkerErrors[0], 1) require.IsType(t, &sema.PurityError{}, checkerError[0]) _, err = inter.Invoke("main") diff --git a/tests/interpreter/if_test.go b/interpreter/if_test.go similarity index 98% rename from tests/interpreter/if_test.go rename to interpreter/if_test.go index cc7efb83c2..4242062e39 100644 --- a/tests/interpreter/if_test.go +++ b/interpreter/if_test.go @@ -24,11 +24,11 @@ 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/tests/checker" ) func TestInterpretIfStatement(t *testing.T) { @@ -83,7 +83,7 @@ func TestInterpretIfStatement(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) assert.IsType(t, &sema.UnreachableStatementError{}, errs[0]) assert.IsType(t, &sema.UnreachableStatementError{}, errs[1]) diff --git a/tests/interpreter/import_test.go b/interpreter/import_test.go similarity index 94% rename from tests/interpreter/import_test.go rename to interpreter/import_test.go index 45204a23c8..a5a2e808b7 100644 --- a/tests/interpreter/import_test.go +++ b/interpreter/import_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/common/orderedmap" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -154,7 +154,7 @@ func TestInterpretImportMultipleProgramsFromLocation(t *testing.T) { address := common.MustBytesToAddress([]byte{0x1}) - importedCheckerA, err := checker.ParseAndCheckWithOptions(t, + importedCheckerA, err := ParseAndCheckWithOptions(t, ` // this function *SHOULD* be imported in the importing program access(all) fun a(): Int { @@ -166,7 +166,7 @@ func TestInterpretImportMultipleProgramsFromLocation(t *testing.T) { return 11 } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: common.AddressLocation{ Address: address, Name: "a", @@ -175,7 +175,7 @@ func TestInterpretImportMultipleProgramsFromLocation(t *testing.T) { ) require.NoError(t, err) - importedCheckerB, err := checker.ParseAndCheckWithOptions(t, + importedCheckerB, err := ParseAndCheckWithOptions(t, ` // this function *SHOULD* be imported in the importing program access(all) fun b(): Int { @@ -187,7 +187,7 @@ func TestInterpretImportMultipleProgramsFromLocation(t *testing.T) { return 22 } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: common.AddressLocation{ Address: address, Name: "b", @@ -196,7 +196,7 @@ func TestInterpretImportMultipleProgramsFromLocation(t *testing.T) { ) require.NoError(t, err) - importingChecker, err := checker.ParseAndCheckWithOptions(t, + importingChecker, err := ParseAndCheckWithOptions(t, ` import a, b from 0x1 @@ -204,7 +204,7 @@ func TestInterpretImportMultipleProgramsFromLocation(t *testing.T) { return a() + b() } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ LocationHandler: func(identifiers []ast.Identifier, location common.Location) (result []sema.ResolvedLocation, err error) { @@ -316,11 +316,11 @@ func TestInterpretResourceConstructionThroughIndirectImport(t *testing.T) { address := common.MustBytesToAddress([]byte{0x1}) - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` resource R {} `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: common.AddressLocation{ Address: address, }, @@ -328,7 +328,7 @@ func TestInterpretResourceConstructionThroughIndirectImport(t *testing.T) { ) require.NoError(t, err) - importingChecker, err := checker.ParseAndCheckWithOptions(t, + importingChecker, err := ParseAndCheckWithOptions(t, ` import R from 0x1 @@ -337,7 +337,7 @@ func TestInterpretResourceConstructionThroughIndirectImport(t *testing.T) { destroy r } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ ImportHandler: func(checker *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { require.IsType(t, common.AddressLocation{}, importedLocation) @@ -396,7 +396,7 @@ func TestInterpretResourceConstructionThroughIndirectImport(t *testing.T) { require.ErrorAs(t, err, &resourceConstructionError) assert.Equal(t, - checker.RequireGlobalType(t, importedChecker.Elaboration, "R"), + RequireGlobalType(t, importedChecker.Elaboration, "R"), resourceConstructionError.CompositeType, ) } diff --git a/tests/interpreter/indexing_test.go b/interpreter/indexing_test.go similarity index 100% rename from tests/interpreter/indexing_test.go rename to interpreter/indexing_test.go diff --git a/tests/interpreter/integers_test.go b/interpreter/integers_test.go similarity index 100% rename from tests/interpreter/integers_test.go rename to interpreter/integers_test.go diff --git a/tests/interpreter/interface_test.go b/interpreter/interface_test.go similarity index 100% rename from tests/interpreter/interface_test.go rename to interpreter/interface_test.go diff --git a/tests/interpreter/invocation_test.go b/interpreter/invocation_test.go similarity index 100% rename from tests/interpreter/invocation_test.go rename to interpreter/invocation_test.go diff --git a/tests/interpreter/member_test.go b/interpreter/member_test.go similarity index 98% rename from tests/interpreter/member_test.go rename to interpreter/member_test.go index 29d14e5b82..a7dd3c454a 100644 --- a/tests/interpreter/member_test.go +++ b/interpreter/member_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/interpreter" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -407,7 +407,7 @@ func TestInterpretMemberAccessType(t *testing.T) { value, err := inter.Invoke("S") require.NoError(t, err) - sType := checker.RequireGlobalType(t, inter.Program.Elaboration, "S") + sType := RequireGlobalType(t, inter.Program.Elaboration, "S") ref := interpreter.NewUnmeteredEphemeralReferenceValue(inter, interpreter.UnauthorizedAccess, value, sType, interpreter.EmptyLocationRange) @@ -454,7 +454,7 @@ func TestInterpretMemberAccessType(t *testing.T) { value, err := inter.Invoke("S2") require.NoError(t, err) - sType := checker.RequireGlobalType(t, inter.Program.Elaboration, "S") + sType := RequireGlobalType(t, inter.Program.Elaboration, "S") ref := interpreter.NewUnmeteredEphemeralReferenceValue(inter, interpreter.UnauthorizedAccess, value, sType, interpreter.EmptyLocationRange) @@ -496,7 +496,7 @@ func TestInterpretMemberAccessType(t *testing.T) { value, err := inter.Invoke("S") require.NoError(t, err) - sType := checker.RequireGlobalType(t, inter.Program.Elaboration, "S") + sType := RequireGlobalType(t, inter.Program.Elaboration, "S") ref := interpreter.NewUnmeteredEphemeralReferenceValue(inter, interpreter.UnauthorizedAccess, value, sType, interpreter.EmptyLocationRange) @@ -541,7 +541,7 @@ func TestInterpretMemberAccessType(t *testing.T) { value, err := inter.Invoke("S2") require.NoError(t, err) - sType := checker.RequireGlobalType(t, inter.Program.Elaboration, "S") + sType := RequireGlobalType(t, inter.Program.Elaboration, "S") ref := interpreter.NewUnmeteredEphemeralReferenceValue(inter, interpreter.UnauthorizedAccess, value, sType, interpreter.EmptyLocationRange) diff --git a/tests/interpreter/memory_metering_test.go b/interpreter/memory_metering_test.go similarity index 99% rename from tests/interpreter/memory_metering_test.go rename to interpreter/memory_metering_test.go index 5de97ddfe5..56fae49cb0 100644 --- a/tests/interpreter/memory_metering_test.go +++ b/interpreter/memory_metering_test.go @@ -23,6 +23,7 @@ import ( "testing" "github.com/onflow/cadence/activations" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -32,7 +33,6 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/checker" "github.com/onflow/cadence/tests/utils" ) @@ -8147,11 +8147,11 @@ func TestInterpretASTMetering(t *testing.T) { #pragma ` - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` let Foo = 1 `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: utils.ImportedLocation, }, ) @@ -8444,12 +8444,12 @@ func TestInterpretASTMetering(t *testing.T) { import B from "string-location" ` - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` let A = 1 let B = 1 `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: utils.ImportedLocation, }, ) diff --git a/tests/interpreter/metatype_test.go b/interpreter/metatype_test.go similarity index 100% rename from tests/interpreter/metatype_test.go rename to interpreter/metatype_test.go diff --git a/tests/interpreter/metering_test.go b/interpreter/metering_test.go similarity index 96% rename from tests/interpreter/metering_test.go rename to interpreter/metering_test.go index 243afdba05..a7ea9882d0 100644 --- a/tests/interpreter/metering_test.go +++ b/interpreter/metering_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) @@ -36,20 +36,20 @@ func TestInterpretStatementHandler(t *testing.T) { t.Parallel() - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` access(all) fun a() { true true } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: utils.ImportedLocation, }, ) require.NoError(t, err) - importingChecker, err := checker.ParseAndCheckWithOptions(t, + importingChecker, err := ParseAndCheckWithOptions(t, ` import a from "imported" @@ -69,7 +69,7 @@ func TestInterpretStatementHandler(t *testing.T) { true } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, @@ -163,7 +163,7 @@ func TestInterpretLoopIterationHandler(t *testing.T) { t.Parallel() - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` access(all) fun a() { var i = 1 @@ -174,11 +174,11 @@ func TestInterpretLoopIterationHandler(t *testing.T) { for n in [1, 2, 3, 4, 5] {} } `, - checker.ParseAndCheckOptions{}, + ParseAndCheckOptions{}, ) require.NoError(t, err) - importingChecker, err := checker.ParseAndCheckWithOptions(t, + importingChecker, err := ParseAndCheckWithOptions(t, ` import a from "imported" @@ -193,7 +193,7 @@ func TestInterpretLoopIterationHandler(t *testing.T) { a() } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, @@ -290,7 +290,7 @@ func TestInterpretFunctionInvocationHandler(t *testing.T) { t.Parallel() - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` access(all) fun a() {} @@ -302,13 +302,13 @@ func TestInterpretFunctionInvocationHandler(t *testing.T) { true } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: utils.ImportedLocation, }, ) require.NoError(t, err) - importingChecker, err := checker.ParseAndCheckWithOptions(t, + importingChecker, err := ParseAndCheckWithOptions(t, ` import b from "imported" @@ -328,7 +328,7 @@ func TestInterpretFunctionInvocationHandler(t *testing.T) { true } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, diff --git a/tests/interpreter/interpreter_test.go b/interpreter/misc_test.go similarity index 99% rename from tests/interpreter/interpreter_test.go rename to interpreter/misc_test.go index 6a697eff69..d3c3138580 100644 --- a/tests/interpreter/interpreter_test.go +++ b/interpreter/misc_test.go @@ -39,7 +39,7 @@ import ( "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -168,9 +168,9 @@ func parseCheckAndInterpretWithOptionsAndMemoryMetering( err error, ) { - checker, err := checker.ParseAndCheckWithOptionsAndMemoryMetering(t, + checker, err := ParseAndCheckWithOptionsAndMemoryMetering(t, code, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: options.CheckerConfig, }, memoryGauge, @@ -1208,7 +1208,7 @@ func TestInterpretReturns(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.UnreachableStatementError{}, errs[0]) }, @@ -4207,19 +4207,19 @@ func TestInterpretImport(t *testing.T) { t.Parallel() - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` access(all) fun answer(): Int { return 42 } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: ImportedLocation, }, ) require.NoError(t, err) - importingChecker, err := checker.ParseAndCheckWithOptions(t, + importingChecker, err := ParseAndCheckWithOptions(t, ` import answer from "imported" @@ -4227,7 +4227,7 @@ func TestInterpretImport(t *testing.T) { return answer() } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, @@ -4298,9 +4298,9 @@ func TestInterpretImportError(t *testing.T) { baseValueActivation.DeclareValue(stdlib.PanicFunction) parseAndCheck := func(code string, location common.Location) *sema.Checker { - checker, err := checker.ParseAndCheckWithOptions(t, + checker, err := ParseAndCheckWithOptions(t, code, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: location, Config: &sema.Config{ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { @@ -6823,7 +6823,7 @@ func TestInterpretCompositeFunctionInvocationFromImportingProgram(t *testing.T) t.Parallel() - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` // function must have arguments access(all) fun x(x: Int) {} @@ -6836,13 +6836,13 @@ func TestInterpretCompositeFunctionInvocationFromImportingProgram(t *testing.T) } } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: ImportedLocation, }, ) require.NoError(t, err) - importingChecker, err := checker.ParseAndCheckWithOptions(t, + importingChecker, err := ParseAndCheckWithOptions(t, ` import Y from "imported" @@ -6851,7 +6851,7 @@ func TestInterpretCompositeFunctionInvocationFromImportingProgram(t *testing.T) Y().x() } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, @@ -7277,8 +7277,8 @@ func TestInterpretEmitEvent(t *testing.T) { _, err = inter.Invoke("test") require.NoError(t, err) - transferEventType := checker.RequireGlobalType(t, inter.Program.Elaboration, "Transfer") - transferAmountEventType := checker.RequireGlobalType(t, inter.Program.Elaboration, "TransferAmount") + transferEventType := RequireGlobalType(t, inter.Program.Elaboration, "Transfer") + transferAmountEventType := RequireGlobalType(t, inter.Program.Elaboration, "TransferAmount") fields1 := []interpreter.CompositeField{ { @@ -7420,7 +7420,7 @@ func TestInterpretReferenceEventParameter(t *testing.T) { _, err = inter.Invoke("test", ref) require.NoError(t, err) - eventType := checker.RequireGlobalType(t, inter.Program.Elaboration, "TestEvent") + eventType := RequireGlobalType(t, inter.Program.Elaboration, "TestEvent") expectedEvents := []interpreter.Value{ interpreter.NewCompositeValue( @@ -7758,7 +7758,7 @@ func TestInterpretEmitEventParameterTypes(t *testing.T) { _, err = inter.Invoke("test") require.NoError(t, err) - testType := checker.RequireGlobalType(t, inter.Program.Elaboration, "Test") + testType := RequireGlobalType(t, inter.Program.Elaboration, "Test") fields := []interpreter.CompositeField{ { @@ -8613,7 +8613,7 @@ func TestInterpretConformToImportedInterface(t *testing.T) { t.Parallel() - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` struct interface Foo { fun check(answer: Int) { @@ -8623,13 +8623,13 @@ func TestInterpretConformToImportedInterface(t *testing.T) { } } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: ImportedLocation, }, ) require.NoError(t, err) - importingChecker, err := checker.ParseAndCheckWithOptions(t, + importingChecker, err := ParseAndCheckWithOptions(t, ` import Foo from "imported" @@ -8642,7 +8642,7 @@ func TestInterpretConformToImportedInterface(t *testing.T) { bar.check(answer: 1) } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, @@ -10686,7 +10686,7 @@ func TestInterpretArrayFilter(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.PurityError{}, errs[0]) }, }, diff --git a/tests/interpreter/nesting_test.go b/interpreter/nesting_test.go similarity index 100% rename from tests/interpreter/nesting_test.go rename to interpreter/nesting_test.go diff --git a/tests/interpreter/path_test.go b/interpreter/path_test.go similarity index 100% rename from tests/interpreter/path_test.go rename to interpreter/path_test.go diff --git a/tests/interpreter/pathcapability_test.go b/interpreter/pathcapability_test.go similarity index 100% rename from tests/interpreter/pathcapability_test.go rename to interpreter/pathcapability_test.go diff --git a/tests/interpreter/range_value_test.go b/interpreter/range_value_test.go similarity index 100% rename from tests/interpreter/range_value_test.go rename to interpreter/range_value_test.go diff --git a/tests/interpreter/reference_test.go b/interpreter/reference_test.go similarity index 98% rename from tests/interpreter/reference_test.go rename to interpreter/reference_test.go index 808ff46c83..7af848436c 100644 --- a/tests/interpreter/reference_test.go +++ b/interpreter/reference_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -530,7 +530,7 @@ func TestInterpretResourceReferenceInvalidationOnMove(t *testing.T) { errorHandler := func(tt *testing.T) func(err error) { return func(err error) { - errors := checker.RequireCheckerErrors(tt, err, 1) + errors := RequireCheckerErrors(tt, err, 1) invalidatedRefError := &sema.InvalidatedResourceReferenceError{} assert.ErrorAs(tt, errors[0], &invalidatedRefError) } @@ -637,7 +637,7 @@ func TestInterpretResourceReferenceInvalidationOnMove(t *testing.T) { address := common.Address{0x1} - rType := checker.RequireGlobalType(t, inter.Program.Elaboration, "R").(*sema.CompositeType) + rType := RequireGlobalType(t, inter.Program.Elaboration, "R").(*sema.CompositeType) array := interpreter.NewArrayValue( inter, @@ -742,7 +742,7 @@ func TestInterpretResourceReferenceInvalidationOnMove(t *testing.T) { } `) - rType := checker.RequireGlobalType(t, inter.Program.Elaboration, "R").(*sema.CompositeType) + rType := RequireGlobalType(t, inter.Program.Elaboration, "R").(*sema.CompositeType) // Resource array in account 0x01 @@ -843,7 +843,7 @@ func TestInterpretResourceReferenceInvalidationOnMove(t *testing.T) { address := common.Address{0x1} - rType := checker.RequireGlobalType(t, inter.Program.Elaboration, "R").(*sema.CompositeType) + rType := RequireGlobalType(t, inter.Program.Elaboration, "R").(*sema.CompositeType) array := interpreter.NewArrayValue( inter, @@ -969,7 +969,7 @@ func TestInterpretResourceReferenceInvalidationOnMove(t *testing.T) { address := common.Address{0x1} - rType := checker.RequireGlobalType(t, inter.Program.Elaboration, "R").(*sema.CompositeType) + rType := RequireGlobalType(t, inter.Program.Elaboration, "R").(*sema.CompositeType) array := interpreter.NewArrayValue( inter, @@ -1524,7 +1524,7 @@ func TestInterpretResourceReferenceInvalidationOnDestroy(t *testing.T) { errorHandler := func(tt *testing.T) func(err error) { return func(err error) { - errors := checker.RequireCheckerErrors(tt, err, 1) + errors := RequireCheckerErrors(tt, err, 1) invalidatedRefError := &sema.InvalidatedResourceReferenceError{} assert.ErrorAs(tt, errors[0], &invalidatedRefError) } @@ -1747,7 +1747,7 @@ func TestInterpretReferenceToReference(t *testing.T) { } `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.NestedReferenceError{}, errs[0]) }, }) @@ -1787,7 +1787,7 @@ func TestInterpretReferenceToReference(t *testing.T) { } `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.NestedReferenceError{}, errs[0]) }, }) @@ -3040,7 +3040,7 @@ func TestInterpretDereference(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.InvalidUnaryOperandError{}, errs[0]) }, @@ -3071,7 +3071,7 @@ func TestInterpretDereference(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.InvalidUnaryOperandError{}, errs[0]) }, @@ -3208,7 +3208,7 @@ func TestInterpretHostFunctionReferenceInvalidation(t *testing.T) { result, err := inter.Invoke("main") require.NoError(t, err) - sType := checker.RequireGlobalType(t, inter.Program.Elaboration, "S").(*sema.CompositeType) + sType := RequireGlobalType(t, inter.Program.Elaboration, "S").(*sema.CompositeType) expectedResult := interpreter.NewArrayValue( inter, @@ -3281,7 +3281,7 @@ func TestInterpretHostFunctionReferenceInvalidation(t *testing.T) { result, err := inter.Invoke("main") require.NoError(t, err) - sType := checker.RequireGlobalType(t, inter.Program.Elaboration, "S").(*sema.CompositeType) + sType := RequireGlobalType(t, inter.Program.Elaboration, "S").(*sema.CompositeType) expectedResult := interpreter.NewTypeValue( inter, diff --git a/tests/interpreter/resources_test.go b/interpreter/resources_test.go similarity index 97% rename from tests/interpreter/resources_test.go rename to interpreter/resources_test.go index f6d1b11283..fd639a5739 100644 --- a/tests/interpreter/resources_test.go +++ b/interpreter/resources_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" "github.com/onflow/cadence/interpreter" @@ -321,7 +321,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -367,7 +367,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -413,7 +413,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -459,7 +459,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -502,7 +502,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -542,7 +542,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -582,7 +582,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -622,7 +622,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -664,7 +664,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -705,7 +705,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -743,7 +743,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -776,7 +776,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -809,7 +809,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -840,7 +840,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -891,7 +891,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -936,7 +936,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -981,7 +981,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1026,7 +1026,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1067,7 +1067,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1105,7 +1105,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1143,7 +1143,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1181,7 +1181,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1222,7 +1222,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1262,7 +1262,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1300,7 +1300,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1332,7 +1332,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1364,7 +1364,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1396,7 +1396,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1430,7 +1430,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1458,7 +1458,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) require.IsType(t, &sema.ResourceLossError{}, errs[0]) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[1]) }, @@ -1491,7 +1491,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 6) + errs := RequireCheckerErrors(t, err, 6) require.IsType(t, &sema.InvalidConditionalResourceOperandError{}, errs[0]) require.IsType(t, &sema.InvalidConditionalResourceOperandError{}, errs[1]) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[2]) @@ -1525,7 +1525,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1553,7 +1553,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1585,7 +1585,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1614,7 +1614,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1643,7 +1643,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1675,7 +1675,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) require.IsType(t, &sema.InvalidConditionalResourceOperandError{}, errs[0]) require.IsType(t, &sema.InvalidConditionalResourceOperandError{}, errs[1]) }, @@ -1708,7 +1708,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) require.IsType(t, &sema.InvalidConditionalResourceOperandError{}, errs[0]) require.IsType(t, &sema.InvalidConditionalResourceOperandError{}, errs[1]) }, @@ -1740,7 +1740,7 @@ func TestInterpretResourceInvalidationWithConditionalExprInDestroy(t *testing.T) }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) require.IsType(t, &sema.InvalidConditionalResourceOperandError{}, errs[0]) require.IsType(t, &sema.InvalidConditionalResourceOperandError{}, errs[0]) }, @@ -1782,7 +1782,7 @@ func TestInterpretResourceUseAfterInvalidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[1]) }, @@ -1820,7 +1820,7 @@ func TestInterpretResourceUseAfterInvalidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -2158,7 +2158,7 @@ func TestInterpretResourceDestroyedInPreCondition(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) require.IsType(t, &sema.PurityError{}, errs[0]) require.IsType(t, &sema.InvalidInterfaceConditionResourceInvalidationError{}, errs[1]) }, @@ -2633,7 +2633,7 @@ func TestInterpretDefaultDestroyEventArgumentScoping(t *testing.T) { }, }, HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.DefaultDestroyInvalidArgumentError{}, errs[0]) assert.Equal(t, errs[0].(*sema.DefaultDestroyInvalidArgumentError).Kind, sema.InvalidIdentifier) // ... @@ -2857,7 +2857,7 @@ func TestInterpretMovedResourceInOptionalBinding(t *testing.T) { } `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }) @@ -2900,7 +2900,7 @@ func TestInterpretMovedResourceInSecondValue(t *testing.T) { } `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }) @@ -3032,7 +3032,7 @@ func TestInterpretPreConditionResourceMove(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - checkerErrors := checker.RequireCheckerErrors(t, err, 3) + checkerErrors := RequireCheckerErrors(t, err, 3) require.IsType(t, &sema.PurityError{}, checkerErrors[0]) require.IsType(t, &sema.InvalidInterfaceConditionResourceInvalidationError{}, checkerErrors[1]) require.IsType(t, &sema.PurityError{}, checkerErrors[2]) @@ -3566,7 +3566,7 @@ func TestInterpretInvalidNilCoalescingResourceDuplication(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.InvalidNilCoalescingRightResourceOperandError{}, errs[0]) }, }, diff --git a/tests/interpreter/runtimetype_test.go b/interpreter/runtimetype_test.go similarity index 100% rename from tests/interpreter/runtimetype_test.go rename to interpreter/runtimetype_test.go diff --git a/tests/interpreter/string_test.go b/interpreter/string_test.go similarity index 100% rename from tests/interpreter/string_test.go rename to interpreter/string_test.go diff --git a/tests/interpreter/switch_test.go b/interpreter/switch_test.go similarity index 96% rename from tests/interpreter/switch_test.go rename to interpreter/switch_test.go index 3d0dda4b90..0cbe894063 100644 --- a/tests/interpreter/switch_test.go +++ b/interpreter/switch_test.go @@ -24,11 +24,11 @@ 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/tests/checker" ) func TestInterpretSwitchStatement(t *testing.T) { @@ -53,7 +53,7 @@ func TestInterpretSwitchStatement(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.UnreachableStatementError{}, errs[0]) }, @@ -91,7 +91,7 @@ func TestInterpretSwitchStatement(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.UnreachableStatementError{}, errs[0]) }, @@ -132,7 +132,7 @@ func TestInterpretSwitchStatement(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.UnreachableStatementError{}, errs[0]) }, @@ -219,7 +219,7 @@ func TestInterpretSwitchStatement(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.UnreachableStatementError{}, errs[0]) }, diff --git a/tests/interpreter/transactions_test.go b/interpreter/transactions_test.go similarity index 99% rename from tests/interpreter/transactions_test.go rename to interpreter/transactions_test.go index 71680a184d..8a4167a0b1 100644 --- a/tests/interpreter/transactions_test.go +++ b/interpreter/transactions_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/checker" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -420,7 +420,7 @@ func TestRuntimeInvalidTransferInExecute(t *testing.T) { } `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 3) + errs := RequireCheckerErrors(t, err, 3) require.IsType(t, &sema.ResourceCapturingError{}, errs[0]) require.IsType(t, &sema.ResourceCapturingError{}, errs[1]) require.IsType(t, &sema.ResourceCapturingError{}, errs[2]) diff --git a/tests/interpreter/transfer_test.go b/interpreter/transfer_test.go similarity index 100% rename from tests/interpreter/transfer_test.go rename to interpreter/transfer_test.go diff --git a/tests/interpreter/uuid_test.go b/interpreter/uuid_test.go similarity index 93% rename from tests/interpreter/uuid_test.go rename to interpreter/uuid_test.go index 3e56037a5c..aa4154ff19 100644 --- a/tests/interpreter/uuid_test.go +++ b/interpreter/uuid_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -36,7 +36,7 @@ func TestInterpretResourceUUID(t *testing.T) { t.Parallel() - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` access(all) resource R {} @@ -44,13 +44,13 @@ func TestInterpretResourceUUID(t *testing.T) { return <- create R() } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: ImportedLocation, }, ) require.NoError(t, err) - importingChecker, err := checker.ParseAndCheckWithOptions(t, + importingChecker, err := ParseAndCheckWithOptions(t, ` import createR from "imported" @@ -63,7 +63,7 @@ func TestInterpretResourceUUID(t *testing.T) { ] } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, diff --git a/interpreter/value_test.go b/interpreter/value_test.go index 1bfc7d3cc5..8f4df2bcc1 100644 --- a/interpreter/value_test.go +++ b/interpreter/value_test.go @@ -36,7 +36,7 @@ import ( . "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - checkerUtils "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) @@ -1898,9 +1898,9 @@ func TestEphemeralReferenceTypeConformance(t *testing.T) { } }` - checker, err := checkerUtils.ParseAndCheckWithOptions(t, + checker, err := ParseAndCheckWithOptions(t, code, - checkerUtils.ParseAndCheckOptions{}, + ParseAndCheckOptions{}, ) require.NoError(t, err) @@ -3622,9 +3622,9 @@ func TestNonStorable(t *testing.T) { } ` - checker, err := checkerUtils.ParseAndCheckWithOptions(t, + checker, err := ParseAndCheckWithOptions(t, code, - checkerUtils.ParseAndCheckOptions{}, + ParseAndCheckOptions{}, ) require.NoError(t, err) diff --git a/tests/interpreter/values_test.go b/interpreter/values_test.go similarity index 100% rename from tests/interpreter/values_test.go rename to interpreter/values_test.go diff --git a/tests/interpreter/while_test.go b/interpreter/while_test.go similarity index 100% rename from tests/interpreter/while_test.go rename to interpreter/while_test.go diff --git a/runtime/.gitattributes b/runtime/.gitattributes deleted file mode 100644 index 7a38edbb9a..0000000000 --- a/runtime/.gitattributes +++ /dev/null @@ -1,9 +0,0 @@ -*.interp linguist-generated=true -*.tokens linguist-generated=true -parser/cadence_parser.go linguist-generated=true -parser/cadence_lexer.go linguist-generated=true -parser/cadence_base_listener.go linguist-generated=true -parser/cadence_base_visitor.go linguist-generated=true -parser/cadence_visitor.go linguist-generated=true -parser/cadence_listener.go linguist-generated=true - diff --git a/tests/account_test.go b/runtime/account_test.go similarity index 99% rename from tests/account_test.go rename to runtime/account_test.go index 3182684d35..371cbba4cb 100644 --- a/tests/account_test.go +++ b/runtime/account_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "fmt" @@ -35,8 +35,8 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/checker" . "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" ) @@ -1717,7 +1717,7 @@ func TestRuntimePublicKey(t *testing.T) { } _, err := executeScript(script, runtimeInterface) - errs := checker.RequireCheckerErrors(t, err, 4) + errs := RequireCheckerErrors(t, err, 4) assert.IsType(t, &sema.InvalidAssignmentAccessError{}, errs[0]) assert.IsType(t, &sema.AssignmentToConstantMemberError{}, errs[1]) @@ -2360,7 +2360,7 @@ func TestRuntimeAuthAccountContracts(t *testing.T) { }, ) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.UnauthorizedReferenceAssignmentError{}, errs[0]) }) @@ -2402,7 +2402,7 @@ func TestRuntimeAuthAccountContracts(t *testing.T) { }, ) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.UnauthorizedReferenceAssignmentError{}, errs[0]) }) @@ -2614,7 +2614,7 @@ func TestRuntimeGetAuthAccount(t *testing.T) { }, ) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) @@ -2642,7 +2642,7 @@ func TestRuntimeGetAuthAccount(t *testing.T) { }, ) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.InsufficientArgumentsError{}, errs[0]) }) @@ -2669,7 +2669,7 @@ func TestRuntimeGetAuthAccount(t *testing.T) { Location: common.ScriptLocation{0x1}, }, ) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.ExcessiveArgumentsError{}, errs[0]) }) @@ -2704,7 +2704,7 @@ func TestRuntimeGetAuthAccount(t *testing.T) { }, ) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.NotDeclaredError{}, errs[0]) }) diff --git a/tests/attachments_test.go b/runtime/attachments_test.go similarity index 99% rename from tests/attachments_test.go rename to runtime/attachments_test.go index cf3de8047c..e03c72dc22 100644 --- a/tests/attachments_test.go +++ b/runtime/attachments_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/capabilities_test.go b/runtime/capabilities_test.go similarity index 99% rename from tests/capabilities_test.go rename to runtime/capabilities_test.go index f02f81c079..ade86c8d24 100644 --- a/tests/capabilities_test.go +++ b/runtime/capabilities_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/capabilitycontrollers_test.go b/runtime/capabilitycontrollers_test.go similarity index 99% rename from tests/capabilitycontrollers_test.go rename to runtime/capabilitycontrollers_test.go index 2a9881d312..fbb0d924cc 100644 --- a/tests/capabilitycontrollers_test.go +++ b/runtime/capabilitycontrollers_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "encoding/binary" diff --git a/tests/contract_test.go b/runtime/contract_test.go similarity index 99% rename from tests/contract_test.go rename to runtime/contract_test.go index 288424ea5c..6cd2b4caaa 100644 --- a/tests/contract_test.go +++ b/runtime/contract_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "encoding/hex" @@ -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/checker" . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -1234,7 +1234,7 @@ func TestRuntimeContractTryUpdate(t *testing.T) { ) RequireError(t, err) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) var notExportedError *sema.NotExportedError require.ErrorAs(t, errs[0], ¬ExportedError) }) diff --git a/tests/contract_update_test.go b/runtime/contract_update_test.go similarity index 99% rename from tests/contract_update_test.go rename to runtime/contract_update_test.go index 7cee60bf24..c032eb7124 100644 --- a/tests/contract_update_test.go +++ b/runtime/contract_update_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/contract_update_validation_test.go b/runtime/contract_update_validation_test.go similarity index 99% rename from tests/contract_update_validation_test.go rename to runtime/contract_update_validation_test.go index 0bebbb99a0..f4e77b8c85 100644 --- a/tests/contract_update_validation_test.go +++ b/runtime/contract_update_validation_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "encoding/hex" diff --git a/tests/convertTypes_test.go b/runtime/convertTypes_test.go similarity index 99% rename from tests/convertTypes_test.go rename to runtime/convertTypes_test.go index 5d5ea6b2a9..fea1f8a697 100644 --- a/tests/convertTypes_test.go +++ b/runtime/convertTypes_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/convertValues_test.go b/runtime/convertValues_test.go similarity index 99% rename from tests/convertValues_test.go rename to runtime/convertValues_test.go index 9637b6fb0e..bebbf750ca 100644 --- a/tests/convertValues_test.go +++ b/runtime/convertValues_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( _ "embed" @@ -2322,7 +2322,7 @@ func TestRuntimeExportCompositeValueWithFunctionValueField(t *testing.T) { assert.Equal(t, expected, actual) } -//go:embed test-export-json-deterministic.txt +//go:embed test-export-json-deterministic.json var exportJsonDeterministicExpected string func TestRuntimeExportJsonDeterministic(t *testing.T) { diff --git a/tests/coverage_test.go b/runtime/coverage_test.go similarity index 99% rename from tests/coverage_test.go rename to runtime/coverage_test.go index 8877be16eb..2c244b4c4d 100644 --- a/tests/coverage_test.go +++ b/runtime/coverage_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "encoding/json" diff --git a/tests/crypto_test.go b/runtime/crypto_test.go similarity index 99% rename from tests/crypto_test.go rename to runtime/crypto_test.go index 636cece7e9..71da0b283a 100644 --- a/tests/crypto_test.go +++ b/runtime/crypto_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "encoding/hex" diff --git a/tests/debugger_test.go b/runtime/debugger_test.go similarity index 99% rename from tests/debugger_test.go rename to runtime/debugger_test.go index 3289668907..7d5d5f8907 100644 --- a/tests/debugger_test.go +++ b/runtime/debugger_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "sync" diff --git a/tests/deployedcontract_test.go b/runtime/deployedcontract_test.go similarity index 99% rename from tests/deployedcontract_test.go rename to runtime/deployedcontract_test.go index 7090f7ad77..b73b16f71d 100644 --- a/tests/deployedcontract_test.go +++ b/runtime/deployedcontract_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/deployment_test.go b/runtime/deployment_test.go similarity index 99% rename from tests/deployment_test.go rename to runtime/deployment_test.go index 475cceb86f..6b6cbe83bd 100644 --- a/tests/deployment_test.go +++ b/runtime/deployment_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "encoding/hex" diff --git a/tests/entitlements_test.go b/runtime/entitlements_test.go similarity index 99% rename from tests/entitlements_test.go rename to runtime/entitlements_test.go index f0f5f7ea5f..d241cb6c4d 100644 --- a/tests/entitlements_test.go +++ b/runtime/entitlements_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" @@ -28,8 +28,8 @@ import ( "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -497,7 +497,7 @@ func TestRuntimeAccountEntitlementNamingConflict(t *testing.T) { var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) - errs := checker.RequireCheckerErrors(t, checkerErr, 1) + errs := RequireCheckerErrors(t, checkerErr, 1) var accessError *sema.InvalidAccessError require.ErrorAs(t, errs[0], &accessError) diff --git a/tests/error_test.go b/runtime/error_test.go similarity index 99% rename from tests/error_test.go rename to runtime/error_test.go index 2a99de14ad..a27aecbcf2 100644 --- a/tests/error_test.go +++ b/runtime/error_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "encoding/hex" diff --git a/tests/errors_test.go b/runtime/errors_test.go similarity index 99% rename from tests/errors_test.go rename to runtime/errors_test.go index 9fafcbf8fc..979a7c366e 100644 --- a/tests/errors_test.go +++ b/runtime/errors_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "fmt" diff --git a/tests/ft_test.go b/runtime/ft_test.go similarity index 99% rename from tests/ft_test.go rename to runtime/ft_test.go index 2efce854de..5d7d78b5e6 100644 --- a/tests/ft_test.go +++ b/runtime/ft_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "fmt" diff --git a/tests/import_test.go b/runtime/import_test.go similarity index 96% rename from tests/import_test.go rename to runtime/import_test.go index 2e75215a84..295353b5f6 100644 --- a/tests/import_test.go +++ b/runtime/import_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "fmt" @@ -30,8 +30,8 @@ import ( "github.com/onflow/cadence/encoding/json" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -91,7 +91,7 @@ func TestRuntimeCyclicImport(t *testing.T) { var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) - errs := checker.RequireCheckerErrors(t, checkerErr, 1) + errs := RequireCheckerErrors(t, checkerErr, 1) var importedProgramErr *sema.ImportedProgramError require.ErrorAs(t, errs[0], &importedProgramErr) @@ -101,7 +101,7 @@ func TestRuntimeCyclicImport(t *testing.T) { var checkerErr2 *sema.CheckerError require.ErrorAs(t, importedProgramErr.Err, &checkerErr2) - errs = checker.RequireCheckerErrors(t, checkerErr2, 1) + errs = RequireCheckerErrors(t, checkerErr2, 1) var importedProgramErr2 *sema.ImportedProgramError require.ErrorAs(t, errs[0], &importedProgramErr2) @@ -111,7 +111,7 @@ func TestRuntimeCyclicImport(t *testing.T) { var checkerErr3 *sema.CheckerError require.ErrorAs(t, importedProgramErr2.Err, &checkerErr3) - errs = checker.RequireCheckerErrors(t, checkerErr3, 1) + errs = RequireCheckerErrors(t, checkerErr3, 1) require.IsType(t, &sema.CyclicImportsError{}, errs[0]) } @@ -201,7 +201,7 @@ func TestRuntimeCheckCyclicImportsAfterUpdate(t *testing.T) { var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) - errs := checker.RequireCheckerErrors(t, checkerErr, 1) + errs := RequireCheckerErrors(t, checkerErr, 1) var importedProgramErr *sema.ImportedProgramError require.ErrorAs(t, errs[0], &importedProgramErr) @@ -209,7 +209,7 @@ func TestRuntimeCheckCyclicImportsAfterUpdate(t *testing.T) { var nestedCheckerErr *sema.CheckerError require.ErrorAs(t, importedProgramErr.Err, &nestedCheckerErr) - errs = checker.RequireCheckerErrors(t, nestedCheckerErr, 1) + errs = RequireCheckerErrors(t, nestedCheckerErr, 1) require.IsType(t, &sema.CyclicImportsError{}, errs[0]) } @@ -318,7 +318,7 @@ func TestRuntimeCheckCyclicImportAddress(t *testing.T) { var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) - errs := checker.RequireCheckerErrors(t, checkerErr, 1) + errs := RequireCheckerErrors(t, checkerErr, 1) // Direct cycle, by importing `Foo` in `Foo` require.IsType(t, &sema.CyclicImportsError{}, errs[0]) @@ -403,7 +403,7 @@ func TestRuntimeCheckCyclicImportToSelfDuringDeploy(t *testing.T) { var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) - errs := checker.RequireCheckerErrors(t, checkerErr, 1) + errs := RequireCheckerErrors(t, checkerErr, 1) require.IsType(t, &sema.CyclicImportsError{}, errs[0]) } diff --git a/tests/imported_values_memory_metering_test.go b/runtime/imported_values_memory_metering_test.go similarity index 99% rename from tests/imported_values_memory_metering_test.go rename to runtime/imported_values_memory_metering_test.go index 8b24d84ae1..c3e7a882a8 100644 --- a/tests/imported_values_memory_metering_test.go +++ b/runtime/imported_values_memory_metering_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "fmt" diff --git a/tests/inbox_test.go b/runtime/inbox_test.go similarity index 99% rename from tests/inbox_test.go rename to runtime/inbox_test.go index c2330bc954..00380e23e4 100644 --- a/tests/inbox_test.go +++ b/runtime/inbox_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "fmt" diff --git a/tests/literal_test.go b/runtime/literal_test.go similarity index 99% rename from tests/literal_test.go rename to runtime/literal_test.go index 296488776f..e35033b250 100644 --- a/tests/literal_test.go +++ b/runtime/literal_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "fmt" diff --git a/tests/nft_test.go b/runtime/nft_test.go similarity index 99% rename from tests/nft_test.go rename to runtime/nft_test.go index dd0f70db3d..fcaebdc473 100644 --- a/tests/nft_test.go +++ b/runtime/nft_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test const modifiedNonFungibleTokenInterface = ` diff --git a/tests/predeclaredvalues_test.go b/runtime/predeclaredvalues_test.go similarity index 99% rename from tests/predeclaredvalues_test.go rename to runtime/predeclaredvalues_test.go index acefd56e08..c60d3efb5b 100644 --- a/tests/predeclaredvalues_test.go +++ b/runtime/predeclaredvalues_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "math/big" @@ -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/checker" . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -245,7 +245,7 @@ func TestRuntimePredeclaredValues(t *testing.T) { require.ErrorAs(t, err, &checkerErr) assert.Equal(t, common.ScriptLocation{}, checkerErr.Location) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) var notDeclaredErr *sema.NotDeclaredError require.ErrorAs(t, errs[0], ¬DeclaredErr) diff --git a/tests/program_params_validation_test.go b/runtime/program_params_validation_test.go similarity index 98% rename from tests/program_params_validation_test.go rename to runtime/program_params_validation_test.go index 827de1ebe5..2e1a7f3ec1 100644 --- a/tests/program_params_validation_test.go +++ b/runtime/program_params_validation_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "fmt" @@ -30,8 +30,8 @@ import ( "github.com/onflow/cadence/encoding/json" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -346,7 +346,7 @@ func TestRuntimeScriptParameterTypeValidation(t *testing.T) { var checkerError *sema.CheckerError require.ErrorAs(t, err, &checkerError) - errs := checker.RequireCheckerErrors(t, checkerError, 1) + errs := RequireCheckerErrors(t, checkerError, 1) assert.IsType(t, &sema.InvalidTypeArgumentError{}, errs[0]) }) @@ -385,7 +385,7 @@ func TestRuntimeScriptParameterTypeValidation(t *testing.T) { var checkerError *sema.CheckerError require.ErrorAs(t, err, &checkerError) - errs := checker.RequireCheckerErrors(t, checkerError, 1) + errs := RequireCheckerErrors(t, checkerError, 1) assert.IsType(t, &sema.InvalidTypeArgumentError{}, errs[0]) }) @@ -811,7 +811,7 @@ func TestRuntimeTransactionParameterTypeValidation(t *testing.T) { err := executeTransaction(t, script, contracts, cadence.NewOptional(nil)) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.InvalidNonImportableTransactionParameterTypeError{}, errs[0]) }) @@ -876,7 +876,7 @@ func TestRuntimeTransactionParameterTypeValidation(t *testing.T) { err := executeTransaction(t, script, contracts, cadence.NewOptional(nil)) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.InvalidNonImportableTransactionParameterTypeError{}, errs[0]) }) @@ -903,7 +903,7 @@ func TestRuntimeTransactionParameterTypeValidation(t *testing.T) { err := executeTransaction(t, script, contracts, cadence.NewOptional(nil)) - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) require.IsType(t, &sema.InvalidNonImportableTransactionParameterTypeError{}, errs[0]) require.IsType(t, &sema.ResourceLossError{}, errs[1]) @@ -918,7 +918,7 @@ func TestRuntimeTransactionParameterTypeValidation(t *testing.T) { err := executeTransaction(t, script, nil, cadence.NewOptional(nil)) - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) require.IsType(t, &sema.InvalidNonImportableTransactionParameterTypeError{}, errs[0]) require.IsType(t, &sema.ResourceLossError{}, errs[1]) @@ -943,7 +943,7 @@ func TestRuntimeTransactionParameterTypeValidation(t *testing.T) { err := executeTransaction(t, script, contracts, cadence.NewOptional(nil)) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.InvalidNonImportableTransactionParameterTypeError{}, errs[0]) }) @@ -968,7 +968,7 @@ func TestRuntimeTransactionParameterTypeValidation(t *testing.T) { err := executeTransaction(t, script, nil, cadence.NewArray([]cadence.Value{})) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.InvalidNonImportableTransactionParameterTypeError{}, errs[0]) }) @@ -1004,7 +1004,7 @@ func TestRuntimeTransactionParameterTypeValidation(t *testing.T) { err := executeTransaction(t, script, nil, cadence.NewArray([]cadence.Value{})) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.InvalidNonImportableTransactionParameterTypeError{}, errs[0]) }) @@ -1110,7 +1110,7 @@ func TestRuntimeTransactionParameterTypeValidation(t *testing.T) { if test.expectErrors { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.InvalidNonImportableTransactionParameterTypeError{}, errs[0]) } else { diff --git a/tests/resource_duplicate_test.go b/runtime/resource_duplicate_test.go similarity index 99% rename from tests/resource_duplicate_test.go rename to runtime/resource_duplicate_test.go index 246f073a61..5f5f12c666 100644 --- a/tests/resource_duplicate_test.go +++ b/runtime/resource_duplicate_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/resourcedictionary_test.go b/runtime/resourcedictionary_test.go similarity index 99% rename from tests/resourcedictionary_test.go rename to runtime/resourcedictionary_test.go index e1b939e74e..088d4e977f 100644 --- a/tests/resourcedictionary_test.go +++ b/runtime/resourcedictionary_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "encoding/hex" diff --git a/tests/rlp_test.go b/runtime/rlp_test.go similarity index 99% rename from tests/rlp_test.go rename to runtime/rlp_test.go index 1aa9296eed..17582dceee 100644 --- a/tests/rlp_test.go +++ b/runtime/rlp_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/runtime_memory_metering_test.go b/runtime/runtime_memory_metering_test.go similarity index 99% rename from tests/runtime_memory_metering_test.go rename to runtime/runtime_memory_metering_test.go index e2aac366fd..f7e91fd7bf 100644 --- a/tests/runtime_memory_metering_test.go +++ b/runtime/runtime_memory_metering_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "fmt" diff --git a/tests/runtime_test.go b/runtime/runtime_test.go similarity index 99% rename from tests/runtime_test.go rename to runtime/runtime_test.go index de7487cab3..07e76ce395 100644 --- a/tests/runtime_test.go +++ b/runtime/runtime_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "crypto/rand" @@ -43,8 +43,8 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/checker" . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -1773,7 +1773,7 @@ func TestRuntimeStorageMultipleTransactionsInclusiveRangeFunction(t *testing.T) var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) - errs := checker.RequireCheckerErrors(t, checkerErr, 1) + errs := RequireCheckerErrors(t, checkerErr, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) @@ -4883,7 +4883,7 @@ func TestRuntimeTransactionTopLevelDeclarations(t *testing.T) { var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) - errs := checker.RequireCheckerErrors(t, checkerErr, 1) + errs := RequireCheckerErrors(t, checkerErr, 1) assert.IsType(t, &sema.InvalidTopLevelDeclarationError{}, errs[0]) }) @@ -7766,7 +7766,7 @@ func TestRuntimeImportTestStdlib(t *testing.T) { RequireError(t, err) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) notDeclaredErr := &sema.NotDeclaredError{} require.ErrorAs(t, errs[0], ¬DeclaredErr) @@ -8539,7 +8539,7 @@ func TestRuntimeOptionalReferenceAttack(t *testing.T) { var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) - errs := checker.RequireCheckerErrors(t, checkerErr, 1) + errs := RequireCheckerErrors(t, checkerErr, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) } @@ -9070,7 +9070,7 @@ func TestRuntimeTypesAndConversions(t *testing.T) { }) } - for name, ty := range checker.AllBaseSemaTypes() { + for name, ty := range AllBaseSemaTypes() { // Inclusive range is a dynamically created type. if _, isInclusiveRange := ty.(*sema.InclusiveRangeType); isInclusiveRange { continue @@ -9842,7 +9842,7 @@ func TestRuntimePreconditionDuplication(t *testing.T) { var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) - errs := checker.RequireCheckerErrors(t, checkerErr, 3) + errs := RequireCheckerErrors(t, checkerErr, 3) assert.IsType(t, &sema.PurityError{}, errs[0]) assert.IsType(t, &sema.InvalidInterfaceConditionResourceInvalidationError{}, errs[1]) diff --git a/tests/sharedstate_test.go b/runtime/sharedstate_test.go similarity index 99% rename from tests/sharedstate_test.go rename to runtime/sharedstate_test.go index b5d37b29a3..660c439b1c 100644 --- a/tests/sharedstate_test.go +++ b/runtime/sharedstate_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/storage_test.go b/runtime/storage_test.go similarity index 99% rename from tests/storage_test.go rename to runtime/storage_test.go index 3895ca2327..b82b77a2cb 100644 --- a/tests/storage_test.go +++ b/runtime/storage_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "encoding/binary" diff --git a/tests/test-export-json-deterministic.txt b/runtime/test-export-json-deterministic.json similarity index 100% rename from tests/test-export-json-deterministic.txt rename to runtime/test-export-json-deterministic.json diff --git a/tests/type_test.go b/runtime/type_test.go similarity index 99% rename from tests/type_test.go rename to runtime/type_test.go index 5ee6afc790..2ae870e408 100644 --- a/tests/type_test.go +++ b/runtime/type_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/validation_test.go b/runtime/validation_test.go similarity index 99% rename from tests/validation_test.go rename to runtime/validation_test.go index b46b609df8..980654b941 100644 --- a/tests/validation_test.go +++ b/runtime/validation_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/checker/access_test.go b/sema/accesses_test.go similarity index 99% rename from tests/checker/access_test.go rename to sema/accesses_test.go index 041fad225e..eaa4dc16a9 100644 --- a/tests/checker/access_test.go +++ b/sema/accesses_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +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" ) func expectSuccess(t *testing.T, err error) { diff --git a/tests/checker/account_test.go b/sema/account_test.go similarity index 99% rename from tests/checker/account_test.go rename to sema/account_test.go index 1fc36ef465..e993ed7303 100644 --- a/tests/checker/account_test.go +++ b/sema/account_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) diff --git a/tests/checker/any_test.go b/sema/any_test.go similarity index 96% rename from tests/checker/any_test.go rename to sema/any_test.go index fda0cd08b6..6e35846d12 100644 --- a/tests/checker/any_test.go +++ b/sema/any_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -24,6 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckAnyStruct(t *testing.T) { diff --git a/tests/checker/arrays_dictionaries_test.go b/sema/arrays_dictionaries_test.go similarity index 99% rename from tests/checker/arrays_dictionaries_test.go rename to sema/arrays_dictionaries_test.go index dea57fc1a6..20a306fe04 100644 --- a/tests/checker/arrays_dictionaries_test.go +++ b/sema/arrays_dictionaries_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -30,6 +30,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckDictionary(t *testing.T) { diff --git a/tests/checker/assert_test.go b/sema/assert_test.go similarity index 96% rename from tests/checker/assert_test.go rename to sema/assert_test.go index ea9591bcd9..2912bf380b 100644 --- a/tests/checker/assert_test.go +++ b/sema/assert_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -26,6 +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" ) func TestCheckAssertWithoutMessage(t *testing.T) { diff --git a/tests/checker/assignment_test.go b/sema/assignment_test.go similarity index 98% rename from tests/checker/assignment_test.go rename to sema/assignment_test.go index 6342ae4174..3d415c16ee 100644 --- a/tests/checker/assignment_test.go +++ b/sema/assignment_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidUnknownDeclarationAssignment(t *testing.T) { diff --git a/tests/checker/attachments_test.go b/sema/attachments_test.go similarity index 99% rename from tests/checker/attachments_test.go rename to sema/attachments_test.go index de3e3dd406..c1609e8e0b 100644 --- a/tests/checker/attachments_test.go +++ b/sema/attachments_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -26,6 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckAttachmentBasic(t *testing.T) { diff --git a/tests/checker/boolean_test.go b/sema/boolean_test.go similarity index 94% rename from tests/checker/boolean_test.go rename to sema/boolean_test.go index a6e5224581..6d4e0cde0d 100644 --- a/tests/checker/boolean_test.go +++ b/sema/boolean_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckBoolean(t *testing.T) { diff --git a/tests/checker/builtinfunctions_test.go b/sema/builtinfunctions_test.go similarity index 99% rename from tests/checker/builtinfunctions_test.go rename to sema/builtinfunctions_test.go index be7a0ba1d1..41a956d1d1 100644 --- a/tests/checker/builtinfunctions_test.go +++ b/sema/builtinfunctions_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +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" ) func TestCheckToString(t *testing.T) { diff --git a/tests/checker/capability_controller_test.go b/sema/capability_controller_test.go similarity index 98% rename from tests/checker/capability_controller_test.go rename to sema/capability_controller_test.go index 98cd7ec076..d2ab30eda3 100644 --- a/tests/checker/capability_controller_test.go +++ b/sema/capability_controller_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -26,6 +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" ) func TestCheckStorageCapabilityController(t *testing.T) { diff --git a/tests/checker/capability_test.go b/sema/capability_test.go similarity index 99% rename from tests/checker/capability_test.go rename to sema/capability_test.go index 3a9ffc013e..155442dc12 100644 --- a/tests/checker/capability_test.go +++ b/sema/capability_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckCapability(t *testing.T) { diff --git a/tests/checker/casting_test.go b/sema/casting_test.go similarity index 99% rename from tests/checker/casting_test.go rename to sema/casting_test.go index d8f901c874..e107a4615b 100644 --- a/tests/checker/casting_test.go +++ b/sema/casting_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -26,6 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckCastingIntLiteralToIntegerType(t *testing.T) { diff --git a/tests/checker/character_test.go b/sema/character_test.go similarity index 96% rename from tests/checker/character_test.go rename to sema/character_test.go index 816ae93159..318b101dbc 100644 --- a/tests/checker/character_test.go +++ b/sema/character_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckCharacterLiteral(t *testing.T) { diff --git a/tests/checker/composite_test.go b/sema/composite_test.go similarity index 99% rename from tests/checker/composite_test.go rename to sema/composite_test.go index 241a6ce50b..6598505d98 100644 --- a/tests/checker/composite_test.go +++ b/sema/composite_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -29,6 +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" ) func TestCheckInvalidCompositeRedeclaringType(t *testing.T) { diff --git a/tests/checker/conditional_test.go b/sema/conditional_test.go similarity index 98% rename from tests/checker/conditional_test.go rename to sema/conditional_test.go index 733c3fade3..98ec1a75a7 100644 --- a/tests/checker/conditional_test.go +++ b/sema/conditional_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckConditionalExpressionTest(t *testing.T) { diff --git a/tests/checker/conditions_test.go b/sema/conditions_test.go similarity index 99% rename from tests/checker/conditions_test.go rename to sema/conditions_test.go index 4c240510c9..d845c52c1d 100644 --- a/tests/checker/conditions_test.go +++ b/sema/conditions_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -26,6 +26,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckFunctionTestConditions(t *testing.T) { diff --git a/tests/checker/conformance_test.go b/sema/conformance_test.go similarity index 99% rename from tests/checker/conformance_test.go rename to sema/conformance_test.go index 8bb29b7548..6109516c58 100644 --- a/tests/checker/conformance_test.go +++ b/sema/conformance_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +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" ) func TestCheckEventNonTypeRequirementConformance(t *testing.T) { diff --git a/tests/checker/contract_test.go b/sema/contract_test.go similarity index 99% rename from tests/checker/contract_test.go rename to sema/contract_test.go index 9bb97a50d0..2de30e7d68 100644 --- a/tests/checker/contract_test.go +++ b/sema/contract_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidContractAccountField(t *testing.T) { diff --git a/tests/checker/crypto_test.go b/sema/crypto_test.go similarity index 99% rename from tests/checker/crypto_test.go rename to sema/crypto_test.go index 191183d7a4..91397e95ea 100644 --- a/tests/checker/crypto_test.go +++ b/sema/crypto_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +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" ) func TestCheckHashAlgorithmCases(t *testing.T) { diff --git a/tests/checker/declaration_test.go b/sema/declaration_test.go similarity index 99% rename from tests/checker/declaration_test.go rename to sema/declaration_test.go index 6d7cfd6fdc..738c4c6d34 100644 --- a/tests/checker/declaration_test.go +++ b/sema/declaration_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckConstantAndVariableDeclarations(t *testing.T) { diff --git a/tests/checker/dictionary_test.go b/sema/dictionary_test.go similarity index 95% rename from tests/checker/dictionary_test.go rename to sema/dictionary_test.go index abb66fe3b8..900c53860e 100644 --- a/tests/checker/dictionary_test.go +++ b/sema/dictionary_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckIncompleteDictionaryType(t *testing.T) { diff --git a/tests/checker/dynamic_casting_test.go b/sema/dynamic_casting_test.go similarity index 99% rename from tests/checker/dynamic_casting_test.go rename to sema/dynamic_casting_test.go index ce7f2e38d7..15861bc8e7 100644 --- a/tests/checker/dynamic_casting_test.go +++ b/sema/dynamic_casting_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +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/tests/utils" ) diff --git a/tests/checker/entitlements_test.go b/sema/entitlements_test.go similarity index 99% rename from tests/checker/entitlements_test.go rename to sema/entitlements_test.go index b546de5713..caa5dd36e4 100644 --- a/tests/checker/entitlements_test.go +++ b/sema/entitlements_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckBasicEntitlementDeclaration(t *testing.T) { diff --git a/tests/checker/entrypoint_test.go b/sema/entrypoint_test.go similarity index 98% rename from tests/checker/entrypoint_test.go rename to sema/entrypoint_test.go index 4bbba80238..ac76190b26 100644 --- a/tests/checker/entrypoint_test.go +++ b/sema/entrypoint_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -24,6 +24,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckEntryPointParameters(t *testing.T) { diff --git a/tests/checker/enum_test.go b/sema/enum_test.go similarity index 98% rename from tests/checker/enum_test.go rename to sema/enum_test.go index 671177fd5f..2fc3233336 100644 --- a/tests/checker/enum_test.go +++ b/sema/enum_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidNonEnumCompositeEnumCases(t *testing.T) { diff --git a/tests/checker/errors_test.go b/sema/error_handling_test.go similarity index 98% rename from tests/checker/errors_test.go rename to sema/error_handling_test.go index 33da8bc032..cc84b43316 100644 --- a/tests/checker/errors_test.go +++ b/sema/error_handling_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -27,6 +27,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/tests/utils" ) diff --git a/tests/checker/events_test.go b/sema/events_test.go similarity index 99% rename from tests/checker/events_test.go rename to sema/events_test.go index bf140bb749..d1c588392f 100644 --- a/tests/checker/events_test.go +++ b/sema/events_test.go @@ -16,22 +16,21 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" - "github.com/onflow/cadence/tests/utils" - - "github.com/stretchr/testify/require" - "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" + "github.com/onflow/cadence/tests/utils" ) func TestCheckEventDeclaration(t *testing.T) { diff --git a/tests/checker/external_mutation_test.go b/sema/external_mutation_test.go similarity index 99% rename from tests/checker/external_mutation_test.go rename to sema/external_mutation_test.go index bd56e9b039..3eabd29a5a 100644 --- a/tests/checker/external_mutation_test.go +++ b/sema/external_mutation_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +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" ) func TestCheckArrayUpdateIndexAccess(t *testing.T) { diff --git a/tests/checker/fixedpoint_test.go b/sema/fixedpoint_test.go similarity index 99% rename from tests/checker/fixedpoint_test.go rename to sema/fixedpoint_test.go index 2e7d514785..a1f0eb15e5 100644 --- a/tests/checker/fixedpoint_test.go +++ b/sema/fixedpoint_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -29,6 +29,7 @@ import ( "github.com/onflow/cadence/format" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckFixedPointLiteralTypeConversionInVariableDeclaration(t *testing.T) { diff --git a/tests/checker/for_test.go b/sema/for_test.go similarity index 99% rename from tests/checker/for_test.go rename to sema/for_test.go index d2b6a231d5..8e2f68dcb8 100644 --- a/tests/checker/for_test.go +++ b/sema/for_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +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" ) func TestCheckForVariableSized(t *testing.T) { diff --git a/tests/checker/force_test.go b/sema/force_test.go similarity index 97% rename from tests/checker/force_test.go rename to sema/force_test.go index 2317ebc1fc..c3d0f41f5c 100644 --- a/tests/checker/force_test.go +++ b/sema/force_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckForce(t *testing.T) { diff --git a/tests/checker/function_expression_test.go b/sema/function_expression_test.go similarity index 95% rename from tests/checker/function_expression_test.go rename to sema/function_expression_test.go index 14f65c0e91..5bb0467941 100644 --- a/tests/checker/function_expression_test.go +++ b/sema/function_expression_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidFunctionExpressionReturnValue(t *testing.T) { diff --git a/tests/checker/function_test.go b/sema/function_test.go similarity index 99% rename from tests/checker/function_test.go rename to sema/function_test.go index 88edcf9306..334f1ee2c7 100644 --- a/tests/checker/function_test.go +++ b/sema/function_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -28,6 +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" ) func TestCheckReferenceInFunction(t *testing.T) { diff --git a/sema/gen/golden_test.go b/sema/gen/golden_test.go index bcb116fa0f..0053427d45 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/checker" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestConstructor(t *testing.T) { @@ -57,11 +57,11 @@ func TestConstructor(t *testing.T) { Kind: common.DeclarationKindFunction, }) - _, err := checker.ParseAndCheckWithOptions(t, + _, err := ParseAndCheckWithOptions(t, ` let x = Foo(bar: 1) `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { return baseValueActivation @@ -83,11 +83,11 @@ func TestContract(t *testing.T) { Kind: common.DeclarationKindContract, }) - _, err := checker.ParseAndCheckWithOptions(t, + _, err := ParseAndCheckWithOptions(t, ` let x = Test.Foo(bar: 1) `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { return baseValueActivation diff --git a/tests/checker/genericfunction_test.go b/sema/genericfunction_test.go similarity index 99% rename from tests/checker/genericfunction_test.go rename to sema/genericfunction_test.go index 0d8dc3e805..6b3e443db1 100644 --- a/tests/checker/genericfunction_test.go +++ b/sema/genericfunction_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -30,6 +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" ) func parseAndCheckWithTestValue(t *testing.T, code string, ty sema.Type) (*sema.Checker, error) { diff --git a/tests/checker/hashable_struct_test.go b/sema/hashable_struct_test.go similarity index 95% rename from tests/checker/hashable_struct_test.go rename to sema/hashable_struct_test.go index 4ae190201e..51f432bf25 100644 --- a/tests/checker/hashable_struct_test.go +++ b/sema/hashable_struct_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -24,6 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckHashableStruct(t *testing.T) { diff --git a/tests/checker/if_test.go b/sema/if_test.go similarity index 98% rename from tests/checker/if_test.go rename to sema/if_test.go index 5681f8f111..0674d66d97 100644 --- a/tests/checker/if_test.go +++ b/sema/if_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckIfStatementTest(t *testing.T) { diff --git a/tests/checker/import_test.go b/sema/import_test.go similarity index 99% rename from tests/checker/import_test.go rename to sema/import_test.go index bc586139c6..9e92714fa9 100644 --- a/tests/checker/import_test.go +++ b/sema/import_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -30,6 +30,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/tests/utils" ) diff --git a/tests/checker/indexing_test.go b/sema/indexing_test.go similarity index 98% rename from tests/checker/indexing_test.go rename to sema/indexing_test.go index 1e9bef01e1..5eabac65ff 100644 --- a/tests/checker/indexing_test.go +++ b/sema/indexing_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckArrayIndexingWithInteger(t *testing.T) { diff --git a/tests/checker/initialization_test.go b/sema/initialization_test.go similarity index 99% rename from tests/checker/initialization_test.go rename to sema/initialization_test.go index 48242a9b6c..832bb2724e 100644 --- a/tests/checker/initialization_test.go +++ b/sema/initialization_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) // TODO: test multiple initializers once overloading is supported diff --git a/tests/checker/integer_test.go b/sema/integer_test.go similarity index 99% rename from tests/checker/integer_test.go rename to sema/integer_test.go index 798b168393..1fdcf5963f 100644 --- a/tests/checker/integer_test.go +++ b/sema/integer_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) var allIntegerTypesAndAddressType = common.Concat( diff --git a/tests/checker/interface_test.go b/sema/interface_test.go similarity index 99% rename from tests/checker/interface_test.go rename to sema/interface_test.go index fd453b789a..b43b4f7573 100644 --- a/tests/checker/interface_test.go +++ b/sema/interface_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +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" ) func constructorArguments(compositeKind common.CompositeKind) string { diff --git a/tests/checker/intersection_test.go b/sema/intersection_test.go similarity index 99% rename from tests/checker/intersection_test.go rename to sema/intersection_test.go index ee3b8bf94e..763d16f1b4 100644 --- a/tests/checker/intersection_test.go +++ b/sema/intersection_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -26,6 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckIntersectionType(t *testing.T) { diff --git a/tests/checker/invalid_test.go b/sema/invalid_test.go similarity index 98% rename from tests/checker/invalid_test.go rename to sema/invalid_test.go index b5f058e34c..87e85d7a28 100644 --- a/tests/checker/invalid_test.go +++ b/sema/invalid_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -24,6 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckSpuriousIdentifierAssignmentInvalidValueTypeMismatch(t *testing.T) { diff --git a/tests/checker/invocation_test.go b/sema/invocation_test.go similarity index 99% rename from tests/checker/invocation_test.go rename to sema/invocation_test.go index ded43f11ae..11abdd4073 100644 --- a/tests/checker/invocation_test.go +++ b/sema/invocation_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -28,6 +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/tests/utils" ) diff --git a/tests/checker/member_test.go b/sema/member_test.go similarity index 99% rename from tests/checker/member_test.go rename to sema/member_test.go index c2778c7c18..94fd50858b 100644 --- a/tests/checker/member_test.go +++ b/sema/member_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckOptionalChainingNonOptionalFieldRead(t *testing.T) { diff --git a/tests/checker/metatype_test.go b/sema/metatype_test.go similarity index 99% rename from tests/checker/metatype_test.go rename to sema/metatype_test.go index cb9c5c1b7c..fcf185510f 100644 --- a/tests/checker/metatype_test.go +++ b/sema/metatype_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckMetaType(t *testing.T) { diff --git a/tests/checker/move_test.go b/sema/move_test.go similarity index 97% rename from tests/checker/move_test.go rename to sema/move_test.go index 848fc6c6e7..0791f6f744 100644 --- a/tests/checker/move_test.go +++ b/sema/move_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -24,6 +24,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidMoves(t *testing.T) { diff --git a/tests/checker/nesting_test.go b/sema/nesting_test.go similarity index 99% rename from tests/checker/nesting_test.go rename to sema/nesting_test.go index 40ec6ab6e9..184e566224 100644 --- a/tests/checker/nesting_test.go +++ b/sema/nesting_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -29,6 +29,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckCompositeDeclarationNesting(t *testing.T) { diff --git a/tests/checker/never_test.go b/sema/never_test.go similarity index 98% rename from tests/checker/never_test.go rename to sema/never_test.go index 59c62020cc..5195786007 100644 --- a/tests/checker/never_test.go +++ b/sema/never_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckNever(t *testing.T) { diff --git a/tests/checker/nil_coalescing_test.go b/sema/nil_coalescing_test.go similarity index 98% rename from tests/checker/nil_coalescing_test.go rename to sema/nil_coalescing_test.go index 78a79677c0..0f7c0364fd 100644 --- a/tests/checker/nil_coalescing_test.go +++ b/sema/nil_coalescing_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckNilCoalescingNilIntToOptional(t *testing.T) { diff --git a/tests/utils/occurrence_matcher.go b/sema/occurrence_matcher_test.go similarity index 98% rename from tests/utils/occurrence_matcher.go rename to sema/occurrence_matcher_test.go index 830af59c65..1f672755ac 100644 --- a/tests/utils/occurrence_matcher.go +++ b/sema/occurrence_matcher_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package utils +package sema_test import ( "github.com/onflow/cadence/common" diff --git a/tests/checker/occurrences_test.go b/sema/occurrences_test.go similarity index 99% rename from tests/checker/occurrences_test.go rename to sema/occurrences_test.go index 462bb1e770..a1854e5cef 100644 --- a/tests/checker/occurrences_test.go +++ b/sema/occurrences_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -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/tests/sema_utils" ) // TODO: implement occurrences for type references diff --git a/tests/checker/operations_test.go b/sema/operations_test.go similarity index 99% rename from tests/checker/operations_test.go rename to sema/operations_test.go index 3a198b4004..c5f460bc28 100644 --- a/tests/checker/operations_test.go +++ b/sema/operations_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -30,6 +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" ) func TestCheckInvalidUnaryBooleanNegationOfInteger(t *testing.T) { diff --git a/tests/checker/optional_test.go b/sema/optional_test.go similarity index 99% rename from tests/checker/optional_test.go rename to sema/optional_test.go index e502aa9f26..ea92b679e3 100644 --- a/tests/checker/optional_test.go +++ b/sema/optional_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckOptional(t *testing.T) { diff --git a/tests/checker/overloading_test.go b/sema/overloading_test.go similarity index 96% rename from tests/checker/overloading_test.go rename to sema/overloading_test.go index d78bc4ba9b..77cdea966b 100644 --- a/tests/checker/overloading_test.go +++ b/sema/overloading_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -26,6 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidCompositeInitializerOverloading(t *testing.T) { diff --git a/tests/checker/path_test.go b/sema/path_test.go similarity index 98% rename from tests/checker/path_test.go rename to sema/path_test.go index c21e313830..0b3fcd1215 100644 --- a/tests/checker/path_test.go +++ b/sema/path_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckPath(t *testing.T) { diff --git a/tests/checker/pragma_test.go b/sema/pragma_test.go similarity index 98% rename from tests/checker/pragma_test.go rename to sema/pragma_test.go index 087ea1926a..1795e86df7 100644 --- a/tests/checker/pragma_test.go +++ b/sema/pragma_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -26,6 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckPragmaExpression(t *testing.T) { diff --git a/tests/checker/predeclaredvalues_test.go b/sema/predeclaredvalues_test.go similarity index 95% rename from tests/checker/predeclaredvalues_test.go rename to sema/predeclaredvalues_test.go index 1ebcfb7d14..b402b49c80 100644 --- a/tests/checker/predeclaredvalues_test.go +++ b/sema/predeclaredvalues_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -26,6 +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" ) func TestCheckPredeclaredValues(t *testing.T) { diff --git a/tests/checker/purity_test.go b/sema/purity_test.go similarity index 99% rename from tests/checker/purity_test.go rename to sema/purity_test.go index 16914158f5..2df908b4cd 100644 --- a/tests/checker/purity_test.go +++ b/sema/purity_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -26,6 +26,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckPuritySubtyping(t *testing.T) { diff --git a/tests/checker/range_test.go b/sema/range_test.go similarity index 99% rename from tests/checker/range_test.go rename to sema/range_test.go index d72c798855..752cb93f64 100644 --- a/tests/checker/range_test.go +++ b/sema/range_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "strings" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) diff --git a/tests/checker/range_value_test.go b/sema/range_value_test.go similarity index 99% rename from tests/checker/range_value_test.go rename to sema/range_value_test.go index f93fd5a9c9..1598aee163 100644 --- a/tests/checker/range_value_test.go +++ b/sema/range_value_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +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" ) type inclusiveRangeConstructionTest struct { diff --git a/tests/checker/reference_test.go b/sema/reference_test.go similarity index 99% rename from tests/checker/reference_test.go rename to sema/reference_test.go index ef4b92f33b..b05629424f 100644 --- a/tests/checker/reference_test.go +++ b/sema/reference_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +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/tests/utils" ) diff --git a/tests/checker/resources_test.go b/sema/resource_test.go similarity index 99% rename from tests/checker/resources_test.go rename to sema/resource_test.go index 050a117a56..1bfe40da3b 100644 --- a/tests/checker/resources_test.go +++ b/sema/resource_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -29,6 +29,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/tests/utils" ) diff --git a/tests/checker/return_test.go b/sema/return_test.go similarity index 99% rename from tests/checker/return_test.go rename to sema/return_test.go index 32b5cf4593..5f9b20ed5b 100644 --- a/tests/checker/return_test.go +++ b/sema/return_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +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" ) func TestCheckInvalidReturnValue(t *testing.T) { diff --git a/tests/checker/rlp_test.go b/sema/rlp_test.go similarity index 97% rename from tests/checker/rlp_test.go rename to sema/rlp_test.go index 2f77cb0708..b079b03c33 100644 --- a/tests/checker/rlp_test.go +++ b/sema/rlp_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -26,6 +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" ) func TestCheckRLPDecodeString(t *testing.T) { diff --git a/tests/checker/runtimetype_test.go b/sema/runtimetype_test.go similarity index 99% rename from tests/checker/runtimetype_test.go rename to sema/runtimetype_test.go index 7ee3c911e3..8d8b444c70 100644 --- a/tests/checker/runtimetype_test.go +++ b/sema/runtimetype_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckOptionalTypeConstructor(t *testing.T) { diff --git a/tests/checker/storable_test.go b/sema/storable_test.go similarity index 99% rename from tests/checker/storable_test.go rename to sema/storable_test.go index 5d1b97c2c5..3720107e70 100644 --- a/tests/checker/storable_test.go +++ b/sema/storable_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -29,6 +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" ) func TestCheckStorable(t *testing.T) { diff --git a/tests/checker/string_test.go b/sema/string_test.go similarity index 99% rename from tests/checker/string_test.go rename to sema/string_test.go index cc82a8ec00..23c0ff8001 100644 --- a/tests/checker/string_test.go +++ b/sema/string_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckCharacter(t *testing.T) { diff --git a/tests/checker/swap_test.go b/sema/swap_test.go similarity index 99% rename from tests/checker/swap_test.go rename to sema/swap_test.go index 28e708aceb..63fb658906 100644 --- a/tests/checker/swap_test.go +++ b/sema/swap_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -26,6 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidUnknownDeclarationSwap(t *testing.T) { diff --git a/tests/checker/switch_test.go b/sema/switch_test.go similarity index 99% rename from tests/checker/switch_test.go rename to sema/switch_test.go index 0f34d0a506..38328f1645 100644 --- a/tests/checker/switch_test.go +++ b/sema/switch_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckSwitchStatementTest(t *testing.T) { diff --git a/tests/checker/transactions_test.go b/sema/transactions_test.go similarity index 99% rename from tests/checker/transactions_test.go rename to sema/transactions_test.go index 2dfde9d8c8..79b362d918 100644 --- a/tests/checker/transactions_test.go +++ b/sema/transactions_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckTransactions(t *testing.T) { diff --git a/tests/checker/type_inference_test.go b/sema/type_inference_test.go similarity index 99% rename from tests/checker/type_inference_test.go rename to sema/type_inference_test.go index 6aa900a98e..85a338eaf3 100644 --- a/tests/checker/type_inference_test.go +++ b/sema/type_inference_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -26,6 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckArrayElementTypeInference(t *testing.T) { diff --git a/tests/checker/typeargument_test.go b/sema/typeargument_test.go similarity index 99% rename from tests/checker/typeargument_test.go rename to sema/typeargument_test.go index 5c03e2794a..66895844d4 100644 --- a/tests/checker/typeargument_test.go +++ b/sema/typeargument_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -27,6 +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" ) func TestCheckTypeArguments(t *testing.T) { diff --git a/tests/checker/utils_test.go b/sema/utils_test.go similarity index 96% rename from tests/checker/utils_test.go rename to sema/utils_test.go index 5aa262f30d..d65f31264d 100644 --- a/tests/checker/utils_test.go +++ b/sema/utils_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -24,6 +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" ) func ParseAndCheckWithPanic(t *testing.T, code string) (*sema.Checker, error) { diff --git a/tests/checker/while_test.go b/sema/while_test.go similarity index 97% rename from tests/checker/while_test.go rename to sema/while_test.go index a6eaa55230..9d40353678 100644 --- a/tests/checker/while_test.go +++ b/sema/while_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -24,6 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidWhileTest(t *testing.T) { diff --git a/stdlib/builtin_test.go b/stdlib/builtin_test.go index 676603eaa5..46bbed8071 100644 --- a/stdlib/builtin_test.go +++ b/stdlib/builtin_test.go @@ -23,7 +23,7 @@ import ( "github.com/onflow/cadence/activations" "github.com/onflow/cadence/common" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -100,9 +100,9 @@ func TestCheckAssert(t *testing.T) { baseValueActivation.DeclareValue(AssertFunction) parseAndCheck := func(t *testing.T, code string) (*sema.Checker, error) { - return checker.ParseAndCheckWithOptions(t, + return ParseAndCheckWithOptions(t, code, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { return baseValueActivation @@ -116,7 +116,7 @@ func TestCheckAssert(t *testing.T) { _, err := parseAndCheck(t, `let _ = assert()`) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, errs[0], &sema.InsufficientArgumentsError{}) }) @@ -124,7 +124,7 @@ func TestCheckAssert(t *testing.T) { _, err := parseAndCheck(t, `let _ = assert(1)`) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, errs[0], &sema.TypeMismatchError{}) }) @@ -146,7 +146,7 @@ func TestCheckAssert(t *testing.T) { _, err := parseAndCheck(t, `let _ = assert(true, message: 1)`) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, errs[0], &sema.TypeMismatchError{}) }) @@ -154,7 +154,7 @@ func TestCheckAssert(t *testing.T) { _, err := parseAndCheck(t, `let _ = assert(true, "")`) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, errs[0], &sema.MissingArgumentLabelError{}) }) @@ -162,7 +162,7 @@ func TestCheckAssert(t *testing.T) { _, err := parseAndCheck(t, `let _ = assert(true, message: "foo", true)`) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, errs[0], &sema.ExcessiveArgumentsError{}) }) } @@ -218,9 +218,9 @@ func TestCheckPanic(t *testing.T) { baseValueActivation.DeclareValue(PanicFunction) parseAndCheck := func(t *testing.T, code string) (*sema.Checker, error) { - return checker.ParseAndCheckWithOptions(t, + return ParseAndCheckWithOptions(t, code, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { return baseValueActivation @@ -234,7 +234,7 @@ func TestCheckPanic(t *testing.T) { _, err := parseAndCheck(t, `let _ = panic()`) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, errs[0], &sema.InsufficientArgumentsError{}) }) @@ -250,7 +250,7 @@ func TestCheckPanic(t *testing.T) { _, err := parseAndCheck(t, `let _ = panic(true)`) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, errs[0], &sema.TypeMismatchError{}) }) @@ -258,7 +258,7 @@ func TestCheckPanic(t *testing.T) { _, err := parseAndCheck(t, `let _ = panic("test", 1)`) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, errs[0], &sema.ExcessiveArgumentsError{}) }) } diff --git a/stdlib/test_test.go b/stdlib/test_test.go index 19912f763c..47592a0de2 100644 --- a/stdlib/test_test.go +++ b/stdlib/test_test.go @@ -34,7 +34,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) @@ -288,7 +288,7 @@ func TestTestNewMatcher(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) @@ -334,7 +334,7 @@ func TestTestNewMatcher(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) @@ -461,7 +461,7 @@ func TestTestEqualMatcher(t *testing.T) { _, err := newTestContractInterpreter(t, script) require.Error(t, err) - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) assert.IsType(t, &sema.TypeMismatchError{}, errs[1]) }) @@ -499,7 +499,7 @@ func TestTestEqualMatcher(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) @@ -671,7 +671,7 @@ func TestTestEqualMatcher(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 4) + errs := RequireCheckerErrors(t, err, 4) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) assert.IsType(t, &sema.TypeMismatchError{}, errs[1]) assert.IsType(t, &sema.TypeMismatchError{}, errs[2]) @@ -705,7 +705,7 @@ func TestTestEqualMatcher(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 3) + errs := RequireCheckerErrors(t, err, 3) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) assert.IsType(t, &sema.TypeMismatchError{}, errs[1]) assert.IsType(t, &sema.TypeMismatchError{}, errs[2]) @@ -990,7 +990,7 @@ func TestAssertEqual(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) assert.IsType(t, &sema.TypeMismatchError{}, errs[1]) }) @@ -1016,7 +1016,7 @@ func TestAssertEqual(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) @@ -1041,7 +1041,7 @@ func TestAssertEqual(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) } @@ -1931,7 +1931,7 @@ func TestTestExpect(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) @@ -1955,7 +1955,7 @@ func TestTestExpect(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) assert.IsType(t, &sema.TypeMismatchError{}, errs[1]) }) @@ -1981,7 +1981,7 @@ func TestTestExpect(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) @@ -2006,7 +2006,7 @@ func TestTestExpect(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) } @@ -2176,7 +2176,7 @@ func TestTestExpectFailure(t *testing.T) { ` _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) @@ -2213,7 +2213,7 @@ func TestTestExpectFailure(t *testing.T) { ` _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) } @@ -2377,7 +2377,7 @@ func TestBlockchain(t *testing.T) { } _, err := newTestContractInterpreterWithTestFramework(t, script, testFramework) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) assert.False(t, resetInvoked) }) @@ -2481,7 +2481,7 @@ func TestBlockchain(t *testing.T) { } _, err := newTestContractInterpreterWithTestFramework(t, script, testFramework) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) assert.False(t, moveTimeInvoked) }) diff --git a/tests/checker/utils.go b/tests/sema_utils/utils.go similarity index 99% rename from tests/checker/utils.go rename to tests/sema_utils/utils.go index 3afe516b80..23d1e7756e 100644 --- a/tests/checker/utils.go +++ b/tests/sema_utils/utils.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_utils import ( "flag" diff --git a/tools/analysis/analysis_test.go b/tools/analysis/analysis_test.go index 61e1d54ec4..0baebceefa 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/checker" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tools/analysis" ) @@ -558,7 +558,7 @@ func TestCyclicImports(t *testing.T) { var checkerError *sema.CheckerError require.ErrorAs(t, err, &checkerError) - errs := checker.RequireCheckerErrors(t, checkerError, 1) + errs := RequireCheckerErrors(t, checkerError, 1) var importedProgramErr *sema.ImportedProgramError require.ErrorAs(t, errs[0], &importedProgramErr) @@ -566,6 +566,6 @@ func TestCyclicImports(t *testing.T) { var nestedCheckerErr *sema.CheckerError require.ErrorAs(t, importedProgramErr.Err, &nestedCheckerErr) - errs = checker.RequireCheckerErrors(t, nestedCheckerErr, 1) + errs = RequireCheckerErrors(t, nestedCheckerErr, 1) require.IsType(t, &sema.CyclicImportsError{}, errs[0]) }