tests

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

README

GX testing

Files with a .gx extension are used to test the GX compiler and the XLA backend.

GX tests implement the following testing procedures. First, all the GX files are parsed and compiled into the GX intermediate representation (gir). If there are compiling errors, then errors specified in the comments are removed from the set of reported errors. If there are remaining errors, then the test has failed and stops. The remaining errors are reported as test errors. If all errors have been removed, then the test has succeeded.

If the compiler reported no error then, each exported functions with a Test suffix is interpreted into a XLA compute graph. The compute graph is then executed. The graph output is converted into an output string. This output string is compared to the Want: section in the comments. The test fails if an error occurs while building or running the XLA graph or if the string in the comment does not match the output of the graph.

Note that test functions with expected errors cannot be mixed with functions expected to be executed with no errors.

Documentation

Overview

Package tests embed all GX test files.

Index

Constants

This section is empty.

Variables

View Source
var AlgebraicCore = []string{
	"testfiles/core",
}

AlgebraicCore is a set of paths only testing core algebraic operations.

View Source
var All = appendAll(Language, Stdlib)

All includes all paths.

View Source
var Errors = []string{
	"errors/einsum",
	"errors/ellipsis",
	"errors/meta",
	"errors/process",
	"errors/beforefunc",

	"errors/redefined",
	"errors/slices",
}

Errors is the set of paths testing for compiler errors.

FS is the filesystem containing all GX test files.

View Source
var Language = appendAll(LanguageCore, []string{
	"testfiles/einsum",
	"testfiles/trace",
})

Language is a set of paths testing the GX language.

View Source
var LanguageCore = appendAll(AlgebraicCore, []string{
	"testfiles/forloops",
	"testfiles/generics",
	"testfiles/ifstmts",
	"testfiles/imports",
	"testfiles/slices",
})

LanguageCore is a set of paths testing the GX core language without built-in like einsum.

View Source
var Stdlib = []string{
	"testfiles/bfloat16",
	"testfiles/grad",
	"testfiles/stdlib",
	"testfiles/nn",
	"testfiles/ellipsis",
	"testfiles/compeval",
}

Stdlib is a set of path testing the standard library or where a standard library implementation is required.

View Source
var Units = []string{
	"testfiles/units",
}

Units tests each file in the folder as its own package. It is used to facilitate debugging by isolating GX code for each file/package. Tests by default should be added to folders defined above. Only copy a test here to facilitate debugging.

Functions

func CoreBuilder

func CoreBuilder() *builder.Builder

CoreBuilder returns the builder to run core tests.

func Importer

func Importer() importers.Importer

Importer returns the importer for GX tests.

func StdlibBuilder

func StdlibBuilder(stdlibImpl *impl.Stdlib) *builder.Builder

StdlibBuilder returns the builder to run tests with the standard library.

Types

This section is empty.

Directories

Path Synopsis
Package bindings provide test files to test bindings.
Package bindings provide test files to test bindings.
basic
Package basic encapsulates GX source files into a Go package.
Package basic encapsulates GX source files into a Go package.
basic/basic_go_gx
Package basic_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/basic.
Package basic_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/basic.
cartpole
Package cartpole encapsulates GX source files into a Go package.
Package cartpole encapsulates GX source files into a Go package.
cartpole/cartpole_go_gx
Package cartpole_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/cartpole.
Package cartpole_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/cartpole.
dtypes
Package dtypes encapsulates GX source files into a Go package.
Package dtypes encapsulates GX source files into a Go package.
dtypes/dtypes_go_gx
Package dtypes_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/dtypes.
Package dtypes_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/dtypes.
encoding
Package encoding encapsulates GX source files into a Go package.
Package encoding encapsulates GX source files into a Go package.
encoding/encoding_go_gx
Package encoding_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/encoding.
Package encoding_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/encoding.
imports
Package imports encapsulates GX source files into a Go package.
Package imports encapsulates GX source files into a Go package.
imports/imports_go_gx
Package imports_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/imports.
Package imports_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/imports.
math
Package math encapsulates GX source files into a Go package.
Package math encapsulates GX source files into a Go package.
math/math_go_gx
Package math_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/math.
Package math_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/math.
parameters
Package parameters encapsulates GX source files into a Go package.
Package parameters encapsulates GX source files into a Go package.
parameters/parameters_go_gx
Package parameters_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/parameters.
Package parameters_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/parameters.
pkgvars
Package pkgvars encapsulates GX source files into a Go package.
Package pkgvars encapsulates GX source files into a Go package.
pkgvars/pkgvars_go_gx
Package pkgvars_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/pkgvars.
Package pkgvars_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/pkgvars.
rand
Package rand encapsulates GX source files into a Go package.
Package rand encapsulates GX source files into a Go package.
rand/rand_go_gx
Package rand_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/rand.
Package rand_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/rand.
unexported
Package unexported encapsulates GX source files into a Go package.
Package unexported encapsulates GX source files into a Go package.
unexported/unexported_go_gx
Package unexported_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/unexported.
Package unexported_go_gx are Go bindings to the GX package: github.com/gx-org/gx/tests/bindings/unexported.
Package testing provides functions to run gx tests.
Package testing provides functions to run gx tests.
prime
Package prime generates prime numbers.
Package prime generates prime numbers.

Jump to

Keyboard shortcuts

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