utils

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ImportedLocation = common.StringLocation("imported")

ImportedLocation is used as the default location for imported programs in tests.

View Source
const TestLocation = common.StringLocation("test")

TestLocation is used as the default location for programs in tests.

Variables

This section is empty.

Functions

func ArrayElements

func ArrayElements(inter *interpreter.Interpreter, array *interpreter.ArrayValue) []interpreter.Value

func AssertEqualWithDiff

func AssertEqualWithDiff(t *testing.T, expected, actual any)

AssertEqualWithDiff asserts that two objects are equal.

If the objects are not equal, this function prints a human-readable diff.

func AssertValueSlicesEqual

func AssertValueSlicesEqual(t testing.TB, inter *interpreter.Interpreter, expected, actual []interpreter.Value) bool

func AssertValuesEqual

func AssertValuesEqual(t testing.TB, interpreter *interpreter.Interpreter, expected, actual interpreter.Value) bool

func DeploymentTransaction

func DeploymentTransaction(name string, contract []byte) []byte

func RemovalTransaction

func RemovalTransaction(name string) []byte

func RequireError

func RequireError(t *testing.T, err error)

RequireError is a wrapper around require.Error which also ensures that the error message, the secondary message (if any), and the error notes' (if any) messages can be successfully produced

func RequireValuesEqual

func RequireValuesEqual(t testing.TB, inter *interpreter.Interpreter, expected, actual interpreter.Value)

func UpdateTransaction

func UpdateTransaction(name string, contract []byte) []byte

func ValuesAreEqual

func ValuesAreEqual(inter *interpreter.Interpreter, expected, actual interpreter.Value) bool

Types

type DictionaryEntry

type DictionaryEntry[K, V any] struct {
	Key   K
	Value V
}

func DictionaryEntries

func DictionaryEntries[K, V any](
	inter *interpreter.Interpreter,
	dict *interpreter.DictionaryValue,
	fromKey func(interpreter.Value) (K, bool),
	fromVal func(interpreter.Value) (V, bool),
) ([]DictionaryEntry[K, V], bool)

DictionaryEntries is similar to DictionaryKeyValues, attempting to map untyped Values to concrete values using the provided morphisms. If a conversion fails, then this function returns (nil, false). Useful in contexts when Cadence values need to be extracted into their go counterparts.

type OccurrenceMatcher

type OccurrenceMatcher struct {
	OriginStartPos  *sema.Position
	OriginEndPos    *sema.Position
	StartPos        sema.Position
	EndPos          sema.Position
	DeclarationKind common.DeclarationKind
}

func (*OccurrenceMatcher) Match

func (matcher *OccurrenceMatcher) Match(actual any) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL