examples

package
v0.0.0-...-bbe2460 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package examples discovers and executes Selene example scripts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capture

func Capture(script Script) (string, error)

Capture executes the script using the interpreter and returns everything the program printed. It is a convenience helper for documentation tooling.

func ManifestRoots

func ManifestRoots(root string) ([]string, error)

ManifestRoots returns the configured example roots (falling back to a default of `examples/` when the manifest omits the section).

func Run

func Run(script Script, mode Mode, stdout io.Writer) error

Run executes a script using the selected mode. Output produced through the builtin `print` function is redirected to the provided writer when non-nil.

func RunAll

func RunAll(scripts []Script, modes []Mode) []error

RunAll executes each script using every requested mode. It returns a slice of accumulated errors (rather than failing fast) so tooling can report the full set of failing examples.

Types

type Mode

type Mode string

Mode identifies which execution backend should be used when running an example. It intentionally mirrors the CLI surface so the command and tests stay in sync.

const (
	ModeInterpreter Mode = "interp"
	ModeVM          Mode = "vm"
	ModeJIT         Mode = "jit"
)

type Script

type Script struct {
	Path     string
	Relative string
}

Script represents a runnable example discovered on disk.

func Discover

func Discover(root string, roots []string) ([]Script, error)

Discover walks the provided example roots (relative to the repository root) and returns a stable, deduplicated list of runnable scripts.

Jump to

Keyboard shortcuts

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