tests

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NodeContentEquals = &nodeContentEqualsChecker{}

NodeContentEquals checks whether two nodes have equal content by first encoding them via printer.Sprint, then checking that the generated encodings are identical.

See: printer.Sprint.

Functions

func BenchmarkSpec_Marshal_Map3StrInt

func BenchmarkSpec_Marshal_Map3StrInt(b *testing.B, np datamodel.NodePrototype)

func BenchmarkSpec_Marshal_MapNStrMap3StrInt

func BenchmarkSpec_Marshal_MapNStrMap3StrInt(b *testing.B, np datamodel.NodePrototype)

func BenchmarkSpec_Unmarshal_Map3StrInt

func BenchmarkSpec_Unmarshal_Map3StrInt(b *testing.B, np datamodel.NodePrototype)

func BenchmarkSpec_Unmarshal_MapNStrMap3StrInt

func BenchmarkSpec_Unmarshal_MapNStrMap3StrInt(b *testing.B, np datamodel.NodePrototype)

func BenchmarkSpec_Walk_Map3StrInt

func BenchmarkSpec_Walk_Map3StrInt(b *testing.B, np datamodel.NodePrototype)

func BenchmarkSpec_Walk_MapNStrMap3StrInt

func BenchmarkSpec_Walk_MapNStrMap3StrInt(b *testing.B, np datamodel.NodePrototype)

func SchemaTestAll added in v0.11.0

func SchemaTestAll(t *testing.T, forTest func(name string) []EngineSubtest)
func SchemaTestLinks(t *testing.T, engine Engine)

func SchemaTestListsContainingLists added in v0.10.0

func SchemaTestListsContainingLists(t *testing.T, engine Engine)

TestListsContainingLists is probing *two* things:

  • that lists can nest, obviously
  • that representation semantics are held correctly when we recurse, both in builders and in reading

To cover that latter situation, this depends on structs (so we can use rename directives on the representation to make it distinctive).

func SchemaTestListsContainingMaybe added in v0.10.0

func SchemaTestListsContainingMaybe(t *testing.T, engine Engine)

func SchemaTestMapsContainingMaps added in v0.10.0

func SchemaTestMapsContainingMaps(t *testing.T, engine Engine)

TestMapsContainingMaps is probing *two* things:

  • that maps can nest, obviously
  • that representation semantics are held correctly when we recurse, both in builders and in reading

To cover that latter situation, this depends on structs (so we can use rename directives on the representation to make it distinctive).

func SchemaTestMapsContainingMaybe added in v0.10.0

func SchemaTestMapsContainingMaybe(t *testing.T, engine Engine)

func SchemaTestMapsWithComplexKeys added in v0.10.0

func SchemaTestMapsWithComplexKeys(t *testing.T, engine Engine)

func SchemaTestRequiredFields added in v0.10.0

func SchemaTestRequiredFields(t *testing.T, engine Engine)

func SchemaTestScalars added in v0.11.0

func SchemaTestScalars(t *testing.T, engine Engine)

func SchemaTestStructNesting added in v0.10.0

func SchemaTestStructNesting(t *testing.T, engine Engine)

func SchemaTestStructReprStringjoin added in v0.10.0

func SchemaTestStructReprStringjoin(t *testing.T, engine Engine)

TestStructReprStringjoin exercises... well, what it says on the tin.

These should pass even if the natural map representation doesn't. No maybes are exercised.

func SchemaTestStructReprTuple added in v0.10.0

func SchemaTestStructReprTuple(t *testing.T, engine Engine)

func SchemaTestStructsContainingMaybe added in v0.10.0

func SchemaTestStructsContainingMaybe(t *testing.T, engine Engine)

TestStructsContainingMaybe checks all the variations of "nullable" and "optional" on struct fields. It does this twice: once for the child maybes being implemented with pointers, and once with maybes implemented as embeds. The child values are scalars.

Both type-level generic build and access as well as representation build and access are exercised; the representation used is map (the native representation for structs).

func SchemaTestUnionKeyed added in v0.10.0

func SchemaTestUnionKeyed(t *testing.T, engine Engine)

func SchemaTestUnionKeyedComplexChildren added in v0.10.0

func SchemaTestUnionKeyedComplexChildren(t *testing.T, engine Engine)

Test keyed unions again, but this time with more complex types as children.

The previous tests used scalar types as the children; this exercises most things, but also has a couple (extremely non-obvious) simplifications: namely, because the default representation for strings are "natural" representations, the ReprAssemblers are actually aliases of the type-level Assemblers! Aaaand that makes a few things "work" by coincidence that wouldn't otherwise fly.

func SchemaTestUnionKeyedReset added in v0.10.0

func SchemaTestUnionKeyedReset(t *testing.T, engine Engine)

TestUnionKeyedReset puts a union inside a list, so that we can use the list's reuse of assembler as a test of the assembler's reset feature. The value inside the union is also more complex than a scalar value so that we test resetting gets passed down, too.

func SchemaTestUnionKinded added in v0.10.0

func SchemaTestUnionKinded(t *testing.T, engine Engine)

func SchemaTestUnionStringprefix added in v0.10.0

func SchemaTestUnionStringprefix(t *testing.T, engine Engine)

func SpecBenchmarkMapStrInt_25n_AssembleEntry

func SpecBenchmarkMapStrInt_25n_AssembleEntry(b *testing.B, np datamodel.NodePrototype)

func SpecBenchmarkMapStrInt_25n_AssembleStandard

func SpecBenchmarkMapStrInt_25n_AssembleStandard(b *testing.B, np datamodel.NodePrototype)

func SpecBenchmarkMapStrInt_25n_Iteration

func SpecBenchmarkMapStrInt_25n_Iteration(b *testing.B, np datamodel.NodePrototype)

func SpecBenchmarkMapStrInt_3n_AssembleEntry

func SpecBenchmarkMapStrInt_3n_AssembleEntry(b *testing.B, np datamodel.NodePrototype)

func SpecBenchmarkMapStrInt_3n_AssembleStandard

func SpecBenchmarkMapStrInt_3n_AssembleStandard(b *testing.B, np datamodel.NodePrototype)

func SpecBenchmarkMapStrInt_3n_Iteration

func SpecBenchmarkMapStrInt_3n_Iteration(b *testing.B, np datamodel.NodePrototype)

func SpecTestBytes added in v0.16.0

func SpecTestBytes(t *testing.T, np datamodel.NodePrototype)

func SpecTestListString

func SpecTestListString(t *testing.T, np datamodel.NodePrototype)

func SpecTestMapStrInt

func SpecTestMapStrInt(t *testing.T, np datamodel.NodePrototype)

func SpecTestMapStrListStr

func SpecTestMapStrListStr(t *testing.T, np datamodel.NodePrototype)

func SpecTestMapStrMapStrInt

func SpecTestMapStrMapStrInt(t *testing.T, np datamodel.NodePrototype)

func SpecTestString

func SpecTestString(t *testing.T, np datamodel.NodePrototype)

Types

type Engine added in v0.10.0

type Engine interface {
	Init(t *testing.T, ts schema.TypeSystem)
	PrototypeByName(name string) datamodel.NodePrototype
}

Engine describes the interface that can be supplied to run tests on schemas.

The PrototypeByName function can get its job done using only interface types that we already know from outside any generated code, so you can write tests that have no _compile time_ dependency on the generated code. This makes it easier for IDEs and suchlike to help you write and check the test functions.

Ask for prototypes using the type name alone (no package prefix); their representation prototypes can be obtained by appending ".Repr".

type EngineSubtest added in v0.11.0

type EngineSubtest struct {
	Name   string // subtest name
	Engine Engine
}

Directories

Path Synopsis
The corpus package exports some values useful for building tests and benchmarks.
The corpus package exports some values useful for building tests and benchmarks.

Jump to

Keyboard shortcuts

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