diff --git a/builtins_test.go b/builtins_test.go index 52ba4f4..9be496e 100644 --- a/builtins_test.go +++ b/builtins_test.go @@ -8,6 +8,8 @@ import ( "strings" "testing" "time" + + "github.com/larvit/fejkdata/internal/invariant" ) func TestBuiltinIDGenerators(t *testing.T) { @@ -188,12 +190,12 @@ func ibanValid(s string) bool { return rem == 1 } -// mustPanic fails unless call panics with internalError's phrase, which is what +// mustPanic fails unless call panics with invariant.Broken's phrase, which is what // separates a reported invariant break from a silently wrong value. func mustPanic(t *testing.T, name string, call func()) { t.Helper() defer func() { - if r := recover(); r == nil || !strings.HasPrefix(fmt.Sprint(r), "fejkdata: internal error: ") { + if r := recover(); r == nil || !strings.HasPrefix(fmt.Sprint(r), invariant.Broken("")) { t.Errorf("%s: recovered %v, want the invariant reported as an internal error", name, r) } }() diff --git a/internal/builtinfunc/builtinfunc_test.go b/internal/builtinfunc/builtinfunc_test.go index 140b0f1..7a3d5dc 100644 --- a/internal/builtinfunc/builtinfunc_test.go +++ b/internal/builtinfunc/builtinfunc_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/larvit/fejkdata/internal/grammar" + "github.com/larvit/fejkdata/internal/invariant" ) // TestRegistryShapes pins the builtin contract Prep relies on: every entry supplies prep, @@ -67,12 +68,12 @@ func TestArgGuardsPanic(t *testing.T) { } } -// mustPanic fails unless call panics with internalError's phrase, which is what +// mustPanic fails unless call panics with invariant.Broken's phrase, which is what // separates a reported invariant break from a silently wrong value. func mustPanic(t *testing.T, name string, call func()) { t.Helper() defer func() { - if r := recover(); r == nil || !strings.HasPrefix(fmt.Sprint(r), "fejkdata: internal error: ") { + if r := recover(); r == nil || !strings.HasPrefix(fmt.Sprint(r), invariant.Broken("")) { t.Errorf("%s: recovered %v, want the invariant reported as an internal error", name, r) } }() diff --git a/internal/datatype/datatype_test.go b/internal/datatype/datatype_test.go index ec1d1f3..d53d9fe 100644 --- a/internal/datatype/datatype_test.go +++ b/internal/datatype/datatype_test.go @@ -23,3 +23,9 @@ func TestStringNamesADatatypeNoDataWrites(t *testing.T) { t.Errorf("String = %q, want DataType(9)", got) } } + +func TestNounNamesADatatypeNoDataWrites(t *testing.T) { + if got := Noun(DataType(9)); got != "DataType(9)" { + t.Errorf("Noun = %q, want DataType(9)", got) + } +} diff --git a/internal/proven/proven_test.go b/internal/proven/proven_test.go index db75ece..6f5ec11 100644 --- a/internal/proven/proven_test.go +++ b/internal/proven/proven_test.go @@ -20,7 +20,7 @@ func TestLiteralSaysWhichDatatypesItsTextIs(t *testing.T) { {"-0", [datatype.Count]bool{datatype.Integer: true, datatype.Number: true, datatype.Boolean: true}}, } { v := Literal(c.text) - for d := datatype.Integer; d <= datatype.Boolean; d++ { + for d := datatype.Integer; d < datatype.Count; d++ { if (v.Not[d] != "") != c.not[d] { t.Errorf("Literal(%q).Not[%s] = %q", c.text, d, v.Not[d]) }