roundtrip

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package roundtrip is a native module for the tests of the runtime and the generator: every kind of value that crosses, sent to the platform and back, with calls of each shape. It is implemented three times, in swift/ (with Foundation only, so that it builds on Linux too), rust/ and zig/, each of which the tests run.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNamed is the error Fail throws for "named".
	ErrNamed = native.NewError("named")
)

Functions

This section is empty.

Types

type Counter

type Counter interface {
	io.Closer
	// Next returns the count, then adds one.
	Next() int
	// Same returns another counter of the same count.
	Same() Counter
}

Counter counts.

type Echo

type Echo interface {
	// Scalars returns its arguments, one more each.
	Scalars(i int, i8 int8, u16 uint16, i32 int32, u64 uint64, f32 float32, f float64, b bool) Scalars
	// Add is a plain sum, the cheapest call.
	Add(a, b int) int
	// Text returns s twice, and b reversed.
	Text(s string, b []byte) Texts
	// Record returns r with its counts doubled.
	Record(r Record) (Record, error)
	// Lists returns the lengths of the words, and a map of each to its
	// length.
	Lists(words []string, nested [][]int) (map[string]int, error)
	// Maybe returns p's value plus one, or nil for nil.
	Maybe(p *int) *int
	// Times returns t moved by d, and d doubled.
	Times(t time.Time, d time.Duration) (Moment, error)
	// Kind returns the next kind, and the next level.
	Kind(k Kind, l Level) (Kinds, error)
	// Fail throws the error named, or nothing for "".
	Fail(name string) error
	// Wait waits d, or until ctx is done, then returns s.
	Wait(ctx context.Context, d time.Duration, s string) (string, error)
	// Count yields 0 to n-1, failing at fail when it is not -1.
	Count(ctx context.Context, n, fail int) iter.Seq2[int, error]
	// Records yields n records.
	Records(ctx context.Context, n int) iter.Seq2[Record, error]
	// Counter makes a counter starting at n.
	Counter(n int) (Counter, error)
	// Each calls f with each word and its index, and returns how many.
	Each(words []string, f func(word string, i int)) int
	// Ask asks f for the double of each number, and returns their sum.
	Ask(ns []int, f func(n int) (int, error)) (int, error)
	// Ticks calls f every interval until closed.
	Ticks(interval time.Duration, f func(n int)) io.Closer
	// Use asks s for a score of each word, and returns their sum.
	Use(ctx context.Context, s Scorer, words []string) (float64, error)
	// Fill writes b's index into each byte of buf, xor x.
	Fill(buf *native.Buffer, x int) (int, error)
	// Mix sums numbers of each kind, a call of numbers only.
	Mix(f float32, d float64, b bool, i int8) float64
	// Box returns r moved by its size.
	Box(r ui.Rect) (ui.Rect, error)
	// Nothing returns how many structs without fields it was given.
	Nothing(e []Empty) int
	// OnMain runs on the main thread, which go test does not run: the
	// tests only build it.
	//
	//golet:mainthread
	OnMain(r Record, f func(in Inner)) (Texts, error)
}

Echo returns what it is given.

func NewEcho

func NewEcho() (Echo, error)

NewEcho makes the implementation of Echo on this platform. It returns errors.ErrUnsupported where the module has none, or the system lacks what it needs.

type Empty

type Empty struct{}

Empty has no fields.

type Inner

type Inner struct {
	X, Y float64
}

Inner is nested.

type Kind

type Kind string

Kind is a string enum.

const (
	KindA Kind = "a"
	KindB Kind = "b"
	KindC Kind = "c"
)

type Kinds

type Kinds struct {
	Kind  Kind
	Level Level
}

Kinds are an enum of each kind back.

type Level

type Level int

Level is an integer enum.

const (
	Low  Level = 1
	High Level = 2
)

type Moment

type Moment struct {
	At    time.Time
	Twice time.Duration
}

Moment is a time and a duration back.

type Record

type Record struct {
	Name   string
	Counts []int
	Tags   map[string]string
	Inner  Inner
	Next   *Inner
	Kind   Kind
	Data   []byte
}

Record is a struct with every kind of field.

type Scalars

type Scalars struct {
	I   int
	I8  int8
	U16 uint16
	I32 int32
	U64 uint64
	F32 float32
	F   float64
	B   bool
}

Scalars are the scalars back.

type Scorer

type Scorer interface {
	// Score scores a word.
	Score(word string) float64
	// Explain explains a score, which may wait.
	Explain(ctx context.Context, word string) (string, error)
}

Scorer is implemented by Go.

type Texts

type Texts struct {
	S string
	B []byte
}

Texts are a string and bytes back.

Directories

Path Synopsis
Package uses is a native module that uses another, roundtrip: its structs, enums and objects cross from one module to the other.
Package uses is a native module that uses another, roundtrip: its structs, enums and objects cross from one module to the other.

Jump to

Keyboard shortcuts

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