specimen

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2022 License: MPL-2.0 Imports: 11 Imported by: 0

README

Code Overview

/go/specimen

  • codebox.go is about what a codebox is and how to create one
  • data.go is about the TreeRoot, Nodule, Nodule, Nodule and how to create them
  • file.go is about local files and virtual files
  • run.go implements the entry point to the library: "specimen.Run(...)"
  • tree.go implements the focustree.Node interface on the types defined in data.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeCodeboxSet

func MakeCodeboxSet(codeboxMap map[string]BoxFunction) map[string]*Codebox

MakeCodeboxSet names the box functions by their mapping key, making codeboxes

func Run

func Run(t *testing.T, codeboxSet map[string]*Codebox, dataFileSlice []File)

Load the data of the given files and runs the code sandboxes with it

Types

type BoxFunction

type BoxFunction func(s *S, input Dict)

BoxFunction is the type that user-defined functions must implement in codeboxes

type Codebox

type Codebox struct {
	// Name is the name given when registring the codebox
	Name string
	// BoxFunction is the function which adapts to the code.
	BoxFunction BoxFunction
}

Codebox is a function with a name to be matched with data from the yaml files

type Dict

type Dict = map[string]interface{}

Dict is a shorthand for map of strings to interfaces

type FailStatus

type FailStatus int
const (
	Pristine FailStatus = iota
	Failed
	Aborted
	Panicked
)

type File

type File struct {
	Path    string
	Content []byte
}

File represents a file by its path and content

func ReadLocalFile

func ReadLocalFile(path string) File

ReadLocalFile reads a file from the file system and returns a specimen.File

func VirtualFile

func VirtualFile(imaginary_path string, content []byte) File

VirtualFile creates a specimen.File from scratch

func VirtualFileDedent

func VirtualFileDedent(imaginary_path string, content []byte) File

VirtualFileDedent dedents the givent content and creates a specimen.File

type Nodule

type Nodule struct {
	File    *File
	Mapping *yaml.Node
	// Kind is one of "File", "Node", "Slab" -- Kind is used in error reports
	Kind string
	// Location is a clickable link to the beginning of the nodule
	Location string
	Flag     focustree.FlagType
	// Name is an indicative name for the nodule
	Name     string
	Children []Nodule
	Codebox  *Codebox
	Input    map[string]interface{}
	Matrix   map[string][]interface{}
}

Nodule is a node inside a file

func (*Nodule) Clone

func (n *Nodule) Clone() (m Nodule)

func (Nodule) Errorf

func (n Nodule) Errorf(format string, a ...interface{}) error

func (Nodule) GetChildren

func (n Nodule) GetChildren() (children []focustree.Node)

func (Nodule) GetFlag

func (n Nodule) GetFlag() focustree.FlagType

func (*Nodule) Initialize

func (n *Nodule) Initialize() (err error)

Initialize tries to compute the properties of a Nodule necessary to perform the slab selection.

func (*Nodule) InitializeFile

func (n *Nodule) InitializeFile() (err error)

func (Nodule) IsLeaf

func (n Nodule) IsLeaf() bool

func (*Nodule) Populate

func (n *Nodule) Populate(
	codeboxSet map[string]*Codebox, codebox *Codebox,
	input map[string]interface{},
	matrix map[string][]interface{},
) error

Populate fills the Codebox and Input fields through the tree of nodules

func (Nodule) Warning

func (n Nodule) Warning(info string)

type S

type S struct {
	// contains filtered or unexported fields
}

S is a context structure for the Specimen package

func (*S) Abort

func (s *S) Abort(info string)

Abort marks the slab as aborted and saves the given information, if provided.

func (*S) ExpectEqual

func (s *S) ExpectEqual(value, wanted interface{}, context string)

ExpectEqual test if the two given values are equal data structures

func (*S) Fail

func (s *S) Fail(info string)

Fail marks the slab as failed and saves the given information, if provided. It can be called multiple times for a single slab. All saved information will be reported.

type TreeRoot

type TreeRoot []Nodule

TreeRoot is used to gather the files for exploration by the focustree package

func (TreeRoot) GetChildren

func (t TreeRoot) GetChildren() (children []focustree.Node)

func (TreeRoot) GetFlag

func (TreeRoot) GetFlag() focustree.FlagType

func (TreeRoot) IsLeaf

func (TreeRoot) IsLeaf() bool

func (TreeRoot) Warning

func (TreeRoot) Warning(info string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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