Documentation ¶
Overview ¶
Package testutils provides utilities for testing Io code in Go.
Index ¶
- func CheckNewSlots(t *testing.T, obj *iolang.Object, slots []string)
- func CheckObjectIsProto(t *testing.T, obj *iolang.Object)
- func CheckSlots(t *testing.T, obj *iolang.Object, slots []string)
- func PassControl(want *iolang.Object, stop iolang.Stop) func(*iolang.Object, iolang.Stop) bool
- func PassEqual(want *iolang.Object) func(*iolang.Object, iolang.Stop) bool
- func PassEqualSlots(want iolang.Slots) func(*iolang.Object, iolang.Stop) bool
- func PassFailure() func(*iolang.Object, iolang.Stop) bool
- func PassIdentical(want *iolang.Object) func(*iolang.Object, iolang.Stop) bool
- func PassLocalSlots(want, exclude []string) func(*iolang.Object, iolang.Stop) bool
- func PassSuccess() func(*iolang.Object, iolang.Stop) bool
- func PassTag(want iolang.Tag) func(*iolang.Object, iolang.Stop) bool
- func PassUnequal(want *iolang.Object) func(*iolang.Object, iolang.Stop) bool
- func ResetVM()
- func VM() *iolang.VM
- type SourceTestCase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckNewSlots ¶
CheckNewSlots is a testing helper to check whether an object has the given slots, and possibly others.
func CheckObjectIsProto ¶
CheckObjectIsProto is a testing helper to check that an object has exactly one proto, which is Core Object. obj must come from the test VM.
func CheckSlots ¶
CheckSlots is a testing helper to check whether an object has exactly the listed slots.
func PassControl ¶
PassControl returns a Pass function for a SourceTestCase that predicates on equality with a certain control flow status. The control flow check precedes the value check. Equality here has the same semantics as in PassEqual.
func PassEqual ¶
PassEqual returns a Pass function for a SourceTestCase that predicates on equality. To determine equality, this first checks for equal identities; if not, it checks that the result of TestingVM().Compare(want, result) is 0. If the Stop is not NoStop, then the predicate returns false.
func PassEqualSlots ¶
PassEqualSlots returns a Pass function for a SourceTestCase that returns true iff the result has exactly the same slots as want and the slots' values compare equal. If the Stop is not NoStop, then the predicate returns false.
func PassFailure ¶
PassFailure returns a Pass function for a SourceTestCase that returns true iff the result is a raised exception.
func PassIdentical ¶
PassIdentical returns a Pass function for a SourceTestCase that predicates on identity equality, i.e. the result must be exactly the given object. If the Stop is not NoStop, then the predicate returns false.
func PassLocalSlots ¶
PassLocalSlots returns a Pass function for a SourceTestCase that returns true iff the result locally has all of the slots in want and none of the slots in exclude. If the Stop is not NoStop, then the predicate returns false.
func PassSuccess ¶
PassSuccess returns a Pass function for a SourceTestCase that returns true iff the control flow status is NoStop.
func PassTag ¶
PassTag returns a Pass function for a SourceTestCase that predicates on equality of the Tag of the result. If the Stop is not NoStop, then the predicate returns false.
func PassUnequal ¶
PassUnequal returns a Pass function for a SourceTestCase that predicates on non-equality by checking that the result of testVM.Compare(want, result) is not 0.
Types ¶
type SourceTestCase ¶
type SourceTestCase struct { // Source is the Io source code to execute. Source string // Pass is a predicate taking the result of executing Source. If Pass // returns false, then the test fails. Pass func(result *iolang.Object, control iolang.Stop) bool }
A SourceTestCase is a test case containing Io source code and a predicate to check the result.