specs_format

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunSpecs

func RunSpecs(stdout io.Writer, stderr io.Writer, rawSpecs []RawSpec) bool

func ShowDiff

func ShowDiff(w io.Writer, expected_ any, got_ any)

Types

type AssertionMismatch

type AssertionMismatch[T any] struct {
	Assertion string `json:"assertion"`
	Expected  T      `json:"expected,omitempty"`
	Got       T      `json:"got,omitempty"`
}

type Movements

type Movements = map[string]map[string]map[string]*big.Int

TODO test

type RawSpec

type RawSpec struct {
	NumscriptPath    string
	SpecsPath        string
	NumscriptContent string
	SpecsFileContent []byte
}

func ReadSpecsFiles

func ReadSpecsFiles(paths []string) ([]RawSpec, error)

type Specs

type Specs struct {
	FeatureFlags []string                     `json:"featureFlags,omitempty"`
	Balances     interpreter.Balances         `json:"balances,omitempty"`
	Vars         interpreter.VariablesMap     `json:"variables,omitempty"`
	Meta         interpreter.AccountsMetadata `json:"metadata,omitempty"`
	TestCases    []TestCase                   `json:"testCases,omitempty"`
}

--- Specs:

type SpecsResult

type SpecsResult struct {
	// Invariants: total==passing+failing
	Total   uint `json:"total"`
	Passing uint `json:"passing"`
	Failing uint `json:"failing"`
	Cases   []TestCaseResult
}

func Check

type TestCase

type TestCase struct {
	It       string                       `json:"it"`
	Balances interpreter.Balances         `json:"balances,omitempty"`
	Vars     interpreter.VariablesMap     `json:"variables,omitempty"`
	Meta     interpreter.AccountsMetadata `json:"metadata,omitempty"`

	// Expectations
	ExpectMissingFunds bool                         `json:"expect.missingFunds,omitempty"`
	ExpectPostings     []interpreter.Posting        `json:"expect.postings,omitempty"`
	ExpectTxMeta       map[string]string            `json:"expect.txMetadata,omitempty"`
	ExpectAccountsMeta interpreter.AccountsMetadata `json:"expect.metadata,omitempty"`
	ExpectVolumes      interpreter.Balances         `json:"expect.volumes,omitempty"`
	ExpectMovements    Movements                    `json:"expect.movements,omitempty"`
}

type TestCaseResult

type TestCaseResult struct {
	It       string                       `json:"it"`
	Pass     bool                         `json:"pass"`
	Balances interpreter.Balances         `json:"balances"`
	Vars     interpreter.VariablesMap     `json:"variables"`
	Meta     interpreter.AccountsMetadata `json:"metadata"`

	// Assertions
	FailedAssertions []AssertionMismatch[any] `json:"failedAssertions"`
}

type TestResult

type TestResult struct {
	Specs  Specs
	File   string
	Result TestCaseResult
}

Jump to

Keyboard shortcuts

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