go2hx

manual

github

Module: stdgo.testing.quick

(view library index)

Overview

Package quick implements utility functions to help with black box testing.

The testing/quick package is frozen and is not accepting new features.

Index

Constants

import stdgo.testing.quick.Quick
final _complexSize:stdgo.GoUInt64 = ((50i64 : stdgo.GoUInt64))

complexSize is the maximum length of arbitrary values that contain other values.

Variables

import stdgo.testing.quick.Quick
var _defaultConfig:stdgo.testing.quick.Config
var _defaultMaxCount:stdgo.Pointer<stdgo.GoInt>

Functions

import stdgo.testing.quick.Quick

function _arbitraryValues

function _arbitraryValues(_args:stdgo.Slice<stdgo.reflect.Value>, _f:stdgo.reflect.Type_, _config:stdgo.Ref<stdgo.testing.quick.Config>, _rand:stdgo.Ref<stdgo.math.rand.Rand>):stdgo.Error

arbitraryValues writes Values to args such that args contains Values suitable for calling f.

(view code)

function _fArray

function _fArray(_a:stdgo.GoArray<stdgo.GoByte>):stdgo.GoArray<stdgo.GoByte>

(view code)

function _fArrayAlias

function _fArrayAlias(_a:stdgo.testing.quick.TestArrayAlias):stdgo.testing.quick.TestArrayAlias

(view code)

function _fBool

function _fBool(_a:Bool):Bool

(view code)

function _fBoolAlias

function _fBoolAlias(_a:stdgo.testing.quick.TestBoolAlias):stdgo.testing.quick.TestBoolAlias

(view code)

function _fComplex128

function _fComplex128(_a:stdgo.GoComplex128):stdgo.GoComplex128

(view code)

function _fComplex128Alias

function _fComplex128Alias(_a:stdgo.testing.quick.TestComplex128Alias):stdgo.testing.quick.TestComplex128Alias

(view code)

function _fComplex64

function _fComplex64(_a:stdgo.GoComplex64):stdgo.GoComplex64

(view code)

function _fComplex64Alias

function _fComplex64Alias(_a:stdgo.testing.quick.TestComplex64Alias):stdgo.testing.quick.TestComplex64Alias

(view code)

function _fFloat32

function _fFloat32(_a:stdgo.GoFloat32):stdgo.GoFloat32

(view code)

function _fFloat32Alias

function _fFloat32Alias(_a:stdgo.testing.quick.TestFloat32Alias):stdgo.testing.quick.TestFloat32Alias

(view code)

function _fFloat64

function _fFloat64(_a:stdgo.GoFloat64):stdgo.GoFloat64

(view code)

function _fFloat64Alias

function _fFloat64Alias(_a:stdgo.testing.quick.TestFloat64Alias):stdgo.testing.quick.TestFloat64Alias

(view code)

function _fInt

function _fInt(_a:stdgo.GoInt):stdgo.GoInt

(view code)

function _fInt16

function _fInt16(_a:stdgo.GoInt16):stdgo.GoInt16

(view code)

function _fInt16Alias

function _fInt16Alias(_a:stdgo.testing.quick.TestInt16Alias):stdgo.testing.quick.TestInt16Alias

(view code)

function _fInt32

function _fInt32(_a:stdgo.GoInt32):stdgo.GoInt32

(view code)

function _fInt32Alias

function _fInt32Alias(_a:stdgo.testing.quick.TestInt32Alias):stdgo.testing.quick.TestInt32Alias

(view code)

function _fInt64

function _fInt64(_a:stdgo.GoInt64):stdgo.GoInt64

(view code)

function _fInt64Alias

function _fInt64Alias(_a:stdgo.testing.quick.TestInt64Alias):stdgo.testing.quick.TestInt64Alias

(view code)

function _fInt8

function _fInt8(_a:stdgo.GoInt8):stdgo.GoInt8

(view code)

function _fInt8Alias

function _fInt8Alias(_a:stdgo.testing.quick.TestInt8Alias):stdgo.testing.quick.TestInt8Alias

(view code)

function _fIntAlias

function _fIntAlias(_a:stdgo.testing.quick.TestIntAlias):stdgo.testing.quick.TestIntAlias

(view code)

function _fMap

function _fMap(_a:stdgo.GoMap<stdgo.GoInt, stdgo.GoInt>):stdgo.GoMap<stdgo.GoInt, stdgo.GoInt>

(view code)

function _fMapAlias

function _fMapAlias(_a:stdgo.testing.quick.TestMapAlias):stdgo.testing.quick.TestMapAlias

(view code)

function _fPtr

function _fPtr(_a:stdgo.Pointer<stdgo.GoInt>):stdgo.Pointer<stdgo.GoInt>

(view code)

function _fPtrAlias

function _fPtrAlias(_a:stdgo.testing.quick.TestPtrAlias):stdgo.testing.quick.TestPtrAlias

(view code)

function _fSlice

function _fSlice(_a:stdgo.Slice<stdgo.GoByte>):stdgo.Slice<stdgo.GoByte>

(view code)

function _fSliceAlias

function _fSliceAlias(_a:stdgo.testing.quick.TestSliceAlias):stdgo.testing.quick.TestSliceAlias

(view code)

function _fString

function _fString(_a:stdgo.GoString):stdgo.GoString

(view code)

function _fStringAlias

function _fStringAlias(_a:stdgo.testing.quick.TestStringAlias):stdgo.testing.quick.TestStringAlias

(view code)

function _fStruct

function _fStruct(_a:stdgo.testing.quick.TestStruct):stdgo.testing.quick.TestStruct

(view code)

function _fStructAlias

function _fStructAlias(_a:stdgo.testing.quick.TestStructAlias):stdgo.testing.quick.TestStructAlias

(view code)

function _fUint

function _fUint(_a:stdgo.GoUInt):stdgo.GoUInt

(view code)

function _fUint16

function _fUint16(_a:stdgo.GoUInt16):stdgo.GoUInt16

(view code)

function _fUint16Alias

function _fUint16Alias(_a:stdgo.testing.quick.TestUint16Alias):stdgo.testing.quick.TestUint16Alias

(view code)

function _fUint32

function _fUint32(_a:stdgo.GoUInt32):stdgo.GoUInt32

(view code)

function _fUint32Alias

function _fUint32Alias(_a:stdgo.testing.quick.TestUint32Alias):stdgo.testing.quick.TestUint32Alias

(view code)

function _fUint64

function _fUint64(_a:stdgo.GoUInt64):stdgo.GoUInt64

(view code)

function _fUint64Alias

function _fUint64Alias(_a:stdgo.testing.quick.TestUint64Alias):stdgo.testing.quick.TestUint64Alias

(view code)

function _fUint8

function _fUint8(_a:stdgo.GoUInt8):stdgo.GoUInt8

(view code)

function _fUint8Alias

function _fUint8Alias(_a:stdgo.testing.quick.TestUint8Alias):stdgo.testing.quick.TestUint8Alias

(view code)

function _fUintAlias

function _fUintAlias(_a:stdgo.testing.quick.TestUintAlias):stdgo.testing.quick.TestUintAlias

(view code)

function _fUintptr

function _fUintptr(_a:stdgo.GoUIntptr):stdgo.GoUIntptr

(view code)

function _fUintptrAlias

function _fUintptrAlias(_a:stdgo.testing.quick.TestUintptrAlias):stdgo.testing.quick.TestUintptrAlias

(view code)

function _functionAndType

function _functionAndType(_f:stdgo.AnyInterface):{
	_2:Bool;
	_1:stdgo.reflect.Type_;
	_0:stdgo.reflect.Value;
}

(view code)

function _myStructProperty

function _myStructProperty(_in:stdgo.testing.quick.T_myStruct):Bool

(view code)

function _randFloat32

function _randFloat32(_rand:stdgo.Ref<stdgo.math.rand.Rand>):stdgo.GoFloat32

randFloat32 generates a random float taking the full range of a float32.

(view code)

function _randFloat64

function _randFloat64(_rand:stdgo.Ref<stdgo.math.rand.Rand>):stdgo.GoFloat64

randFloat64 generates a random float taking the full range of a float64.

(view code)

function _randInt64

function _randInt64(_rand:stdgo.Ref<stdgo.math.rand.Rand>):stdgo.GoInt64

randInt64 returns a random int64.

(view code)

function _reportError

function _reportError(_property:stdgo.GoString, _err:stdgo.Error, _t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function _sizedValue

function _sizedValue(_t:stdgo.reflect.Type_, _rand:stdgo.Ref<stdgo.math.rand.Rand>, _size:stdgo.GoInt):{
	_1:Bool;
	_0:stdgo.reflect.Value;
}

sizedValue returns an arbitrary value of the given type. The size hint is used for shrinking as a function of indirection level so that recursive data structures will terminate.

(view code)

function _toInterfaces

function _toInterfaces(_values:stdgo.Slice<stdgo.reflect.Value>):stdgo.Slice<stdgo.AnyInterface>

(view code)

function _toString

function _toString(_interfaces:stdgo.Slice<stdgo.AnyInterface>):stdgo.GoString

(view code)

function check

function check(_f:stdgo.AnyInterface, _config:stdgo.Ref<stdgo.testing.quick.Config>):stdgo.Error

Check looks for an input to f, any function that returns bool, such that f returns false. It calls f repeatedly, with arbitrary values for each argument. If f returns false on a given input, Check returns that input as a *CheckError. For example:

	func TestOddMultipleOfThree(t *testing.T) {
		f := func(x int) bool {
			y := OddMultipleOfThree(x)
			return y%2 == 1 && y%3 == 0
		}
		if err := quick.Check(f, nil); err != nil {
			t.Error(err)
		}
	}

(view code)

function checkEqual

function checkEqual(_f:stdgo.AnyInterface, _g:stdgo.AnyInterface, _config:stdgo.Ref<stdgo.testing.quick.Config>):stdgo.Error

CheckEqual looks for an input on which f and g return different results. It calls f and g repeatedly with arbitrary values for each argument. If f and g return different answers, CheckEqual returns a *CheckEqualError describing the input and the outputs.

(view code)

function testCheckEqual

function testCheckEqual(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testCheckProperty

function testCheckProperty(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testEmptyStruct

function testEmptyStruct(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testFailure

function testFailure(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testInt64

function testInt64(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testMutuallyRecursive

function testMutuallyRecursive(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testNonZeroSliceAndMap

function testNonZeroSliceAndMap(_t:stdgo.Ref<stdgo.testing.T_>):Void

Some serialization formats (e.g. encoding/pem) cannot distinguish between a nil and an empty map or slice, so avoid generating the zero value for these.

(view code)

function testRecursive

function testRecursive(_t:stdgo.Ref<stdgo.testing.T_>):Void

Recursive data structures didn't terminate. Issues 8818 and 11148.

(view code)

function value

function value(_t:stdgo.reflect.Type_, _rand:stdgo.Ref<stdgo.math.rand.Rand>):{
	_1:Bool;
	_0:stdgo.reflect.Value;
}

Value returns an arbitrary value of the given type. If the type implements the Generator interface, that will be used. Note: To create arbitrary values for structs, all the fields must be exported.

(view code)

Classes

import stdgo.testing.quick.*

class A

var b:stdgo.Ref<stdgo.testing.quick.B>

A function new

function new(?b:stdgo.Ref<stdgo.testing.quick.B>):Void

(view code)

class B

var a:stdgo.Ref<stdgo.testing.quick.A>

B function new

function new(?a:stdgo.Ref<stdgo.testing.quick.A>):Void

(view code)

class CheckEqualError

A CheckEqualError is the result CheckEqual finding an error.

var checkError:stdgo.testing.quick.CheckError
var out1:stdgo.Slice<stdgo.AnyInterface>
var out2:stdgo.Slice<stdgo.AnyInterface>

CheckEqualError function new

function new(?checkError:stdgo.testing.quick.CheckError, ?out1:stdgo.Slice<stdgo.AnyInterface>, ?out2:stdgo.Slice<stdgo.AnyInterface>):Void

(view code)

CheckEqualError function error

function error():stdgo.GoString

(view code)

class CheckError

A CheckError is the result of Check finding an error.

var count:stdgo.GoInt
var in_:stdgo.Slice<stdgo.AnyInterface>

CheckError function new

function new(?count:stdgo.GoInt, ?in_:stdgo.Slice<stdgo.AnyInterface>):Void

(view code)

CheckError function error

function error():stdgo.GoString

(view code)

class Config

A Config structure contains options for running a test.

var maxCount:stdgo.GoInt

MaxCount sets the maximum number of iterations. If zero, MaxCountScale is used.

var maxCountScale:stdgo.GoFloat64

MaxCountScale is a non-negative scale factor applied to the default maximum. A count of zero implies the default, which is usually 100 but can be set by the -quickchecks flag.

var rand:stdgo.Ref<stdgo.math.rand.Rand>

Rand specifies a source of random numbers. If nil, a default pseudo-random source will be used.

Config function new

function new(?maxCount:stdgo.GoInt, ?maxCountScale:stdgo.GoFloat64, ?rand:stdgo.Ref<stdgo.math.rand.Rand>, ?values:(:stdgo.Slice<stdgo.reflect.Value>, :stdgo.Ref<stdgo.math.rand.Rand>):Void):Void

(view code)

Config function values

function values(:stdgo.Slice<stdgo.reflect.Value>, :stdgo.Ref<stdgo.math.rand.Rand>):Void

Values specifies a function to generate a slice of arbitrary reflect.Values that are congruent with the arguments to the function being tested. If nil, the top-level Value function is used to generate them.

Config function _getMaxCount

function _getMaxCount():stdgo.GoInt

getMaxCount returns the maximum number of iterations to run for a given Config.

(view code)

Config function _getRand

function _getRand():stdgo.Ref<stdgo.math.rand.Rand>

getRand returns the *rand.Rand to use for a given Config.

(view code)

class T\testNonZeroSliceAndMap\35\\\localname\__Q

var m:stdgo.GoMap<stdgo.GoInt, stdgo.GoInt>
var s:stdgo.Slice<stdgo.GoInt>

T\testNonZeroSliceAndMap\35\\\localname\__Q function new

function new(?m:stdgo.GoMap<stdgo.GoInt, stdgo.GoInt>, ?s:stdgo.Slice<stdgo.GoInt>):Void

(view code)

class T\testRecursive\34\\\localname\__R

var mapP:stdgo.GoMap<stdgo.GoInt, stdgo.Ref<stdgo.testing.quick.T_testRecursive_34___localname___R>>
var mapR:stdgo.GoMap<stdgo.Ref<stdgo.testing.quick.T_testRecursive_34___localname___R>, stdgo.Ref<stdgo.testing.quick.T_testRecursive_34___localname___R>>
var map_:stdgo.GoMap<stdgo.GoInt, stdgo.testing.quick.T_testRecursive_34___localname___R>
var ptr:stdgo.Ref<stdgo.testing.quick.T_testRecursive_34___localname___R>
var slice:stdgo.Slice<stdgo.testing.quick.T_testRecursive_34___localname___R>
var sliceMap:stdgo.Slice<stdgo.GoMap<stdgo.GoInt, stdgo.testing.quick.T_testRecursive_34___localname___R>>
var sliceP:stdgo.Slice<stdgo.Ref<stdgo.testing.quick.T_testRecursive_34___localname___R>>

T\testRecursive\34\\\localname\__R function new

function new(?ptr:stdgo.Ref<stdgo.testing.quick.T_testRecursive_34___localname___R>, ?sliceP:stdgo.Slice<stdgo.Ref<stdgo.testing.quick.T_testRecursive_34___localname___R>>, ?slice:stdgo.Slice<stdgo.testing.quick.T_testRecursive_34___localname___R>, ?map_:stdgo.GoMap<stdgo.GoInt, stdgo.testing.quick.T_testRecursive_34___localname___R>, ?mapP:stdgo.GoMap<stdgo.GoInt, stdgo.Ref<stdgo.testing.quick.T_testRecursive_34___localname___R>>, ?mapR:stdgo.GoMap<stdgo.Ref<stdgo.testing.quick.T_testRecursive_34___localname___R>, stdgo.Ref<stdgo.testing.quick.T_testRecursive_34___localname___R>>, ?sliceMap:stdgo.Slice<stdgo.GoMap<stdgo.GoInt, stdgo.testing.quick.T_testRecursive_34___localname___R>>):Void

(view code)

class TestStruct

var a:stdgo.GoInt
var b:stdgo.GoString

TestStruct function new

function new(?a:stdgo.GoInt, ?b:stdgo.GoString):Void

(view code)

Typedefs

import stdgo.testing.quick.*

typedef Generator

typedef Generator = {
	public function generate(_rand:stdgo.Ref<stdgo.math.rand.Rand>, _size:stdgo.GoInt):stdgo.reflect.Value;	//  Generate returns a random instance of the type on which it is a method using the size as a size hint.
};

A Generator can generate random values of its own type.

typedef SetupError

typedef SetupError = stdgo.GoString;

A SetupError is the result of an error in the way that check is being used, independent of the functions being tested.

typedef T__struct_0

typedef T__struct_0 = {
};

typedef TestArrayAlias

typedef TestArrayAlias = stdgo.GoArray<stdgo.GoUInt8>;

typedef TestBoolAlias

typedef TestBoolAlias = Bool;

typedef TestComplex128Alias

typedef TestComplex128Alias = stdgo.GoComplex128;

typedef TestComplex64Alias

typedef TestComplex64Alias = stdgo.GoComplex64;

typedef TestFloat32Alias

typedef TestFloat32Alias = stdgo.GoFloat32;

typedef TestFloat64Alias

typedef TestFloat64Alias = stdgo.GoFloat64;

typedef TestInt16Alias

typedef TestInt16Alias = stdgo.GoInt16;

typedef TestInt32Alias

typedef TestInt32Alias = stdgo.GoInt32;

typedef TestInt64Alias

typedef TestInt64Alias = stdgo.GoInt64;

typedef TestInt8Alias

typedef TestInt8Alias = stdgo.GoInt8;

typedef TestIntAlias

typedef TestIntAlias = stdgo.GoInt;

typedef TestMapAlias

typedef TestMapAlias = stdgo.GoMap<stdgo.GoInt, stdgo.GoInt>;

typedef TestPtrAlias

typedef TestPtrAlias = stdgo.Pointer<stdgo.GoInt>;

typedef TestSliceAlias

typedef TestSliceAlias = stdgo.Slice<stdgo.GoUInt8>;

typedef TestStringAlias

typedef TestStringAlias = stdgo.GoString;

typedef TestStructAlias

typedef TestStructAlias = stdgo.testing.quick.TestStruct;

typedef TestUint16Alias

typedef TestUint16Alias = stdgo.GoUInt16;

typedef TestUint32Alias

typedef TestUint32Alias = stdgo.GoUInt32;

typedef TestUint64Alias

typedef TestUint64Alias = stdgo.GoUInt64;

typedef TestUint8Alias

typedef TestUint8Alias = stdgo.GoUInt8;

typedef TestUintAlias

typedef TestUintAlias = stdgo.GoUInt;

typedef TestUintptrAlias

typedef TestUintptrAlias = stdgo.GoUIntptr;