lang: Rename old fail9 variable to failInit

Cleanups...
This commit is contained in:
James Shubin
2021-05-08 04:25:56 -04:00
parent 95ea93564e
commit f778f53744
2 changed files with 15 additions and 15 deletions

View File

@@ -547,7 +547,7 @@ func TestAstFunc0(t *testing.T) {
func TestAstFunc1(t *testing.T) { func TestAstFunc1(t *testing.T) {
const magicError = "# err: " const magicError = "# err: "
const magicErrorLexParse = "errLexParse: " const magicErrorLexParse = "errLexParse: "
const magicErrorFailInit = "errInit: " const magicErrorInit = "errInit: "
const magicErrorSetScope = "errSetScope: " const magicErrorSetScope = "errSetScope: "
const magicErrorUnify = "errUnify: " const magicErrorUnify = "errUnify: "
const magicErrorGraph = "errGraph: " const magicErrorGraph = "errGraph: "
@@ -650,8 +650,8 @@ func TestAstFunc1(t *testing.T) {
str = errStr str = errStr
failLexParse = true failLexParse = true
} }
if strings.HasPrefix(str, magicErrorFailInit) { if strings.HasPrefix(str, magicErrorInit) {
errStr = strings.TrimPrefix(str, magicErrorFailInit) errStr = strings.TrimPrefix(str, magicErrorInit)
str = errStr str = errStr
failInit = true failInit = true
} }
@@ -999,7 +999,7 @@ func TestAstFunc1(t *testing.T) {
func TestAstFunc2(t *testing.T) { func TestAstFunc2(t *testing.T) {
const magicError = "# err: " const magicError = "# err: "
const magicErrorLexParse = "errLexParse: " const magicErrorLexParse = "errLexParse: "
const magicError9 = "err9: " // TODO: rename const magicErrorInit = "errInit: "
const magicError8 = "err8: " // TODO: rename const magicError8 = "err8: " // TODO: rename
// TODO: move them all down by one // TODO: move them all down by one
const magicErrorSetScope = "errSetScope: " const magicErrorSetScope = "errSetScope: "
@@ -1036,7 +1036,7 @@ func TestAstFunc2(t *testing.T) {
type errs struct { type errs struct {
failLexParse bool failLexParse bool
fail9 bool // TODO: rename failInit bool
fail8 bool // TODO: rename fail8 bool // TODO: rename
// TODO: move them all down by one // TODO: move them all down by one
failSetScope bool failSetScope bool
@@ -1097,7 +1097,7 @@ func TestAstFunc2(t *testing.T) {
// if the graph file has a magic error string, it's a failure // if the graph file has a magic error string, it's a failure
errStr := "" errStr := ""
failLexParse := false failLexParse := false
fail9 := false // TODO: rename failInit := false
fail8 := false // TODO: rename fail8 := false // TODO: rename
// TODO: move them all down by one // TODO: move them all down by one
failSetScope := false failSetScope := false
@@ -1114,10 +1114,10 @@ func TestAstFunc2(t *testing.T) {
str = errStr str = errStr
failLexParse = true failLexParse = true
} }
if strings.HasPrefix(str, magicError9) { // TODO: rename if strings.HasPrefix(str, magicErrorInit) {
errStr = strings.TrimPrefix(str, magicError9) errStr = strings.TrimPrefix(str, magicErrorInit)
str = errStr str = errStr
fail9 = true failInit = true
} }
if strings.HasPrefix(str, magicError8) { // TODO: rename if strings.HasPrefix(str, magicError8) { // TODO: rename
errStr = strings.TrimPrefix(str, magicError8) errStr = strings.TrimPrefix(str, magicError8)
@@ -1160,7 +1160,7 @@ func TestAstFunc2(t *testing.T) {
expstr: str, expstr: str,
errs: errs{ errs: errs{
failLexParse: failLexParse, failLexParse: failLexParse,
fail9: fail9, // TODO: rename failInit: failInit,
fail8: fail8, // TODO: rename fail8: fail8, // TODO: rename
// TODO: move them all down by one // TODO: move them all down by one
failSetScope: failSetScope, failSetScope: failSetScope,
@@ -1202,7 +1202,7 @@ func TestAstFunc2(t *testing.T) {
name, path, fail, expstr, errs := tc.name, tc.path, tc.fail, strings.Trim(tc.expstr, "\n"), tc.errs name, path, fail, expstr, errs := tc.name, tc.path, tc.fail, strings.Trim(tc.expstr, "\n"), tc.errs
src := dir + path // location of the test src := dir + path // location of the test
failLexParse := errs.failLexParse failLexParse := errs.failLexParse
fail9 := errs.fail9 // TODO: rename failInit := errs.failInit
fail8 := errs.fail8 // TODO: rename fail8 := errs.fail8 // TODO: rename
// TODO: move them all down by one // TODO: move them all down by one
failSetScope := errs.failSetScope failSetScope := errs.failSetScope
@@ -1331,12 +1331,12 @@ func TestAstFunc2(t *testing.T) {
} }
// some of this might happen *after* interpolate in SetScope or Unify... // some of this might happen *after* interpolate in SetScope or Unify...
err = ast.Init(data) err = ast.Init(data)
if (!fail || !fail9) && err != nil { if (!fail || !failInit) && err != nil {
t.Errorf("test #%d: FAIL", index) t.Errorf("test #%d: FAIL", index)
t.Errorf("test #%d: could not init and validate AST: %+v", index, err) t.Errorf("test #%d: could not init and validate AST: %+v", index, err)
return return
} }
if fail9 && err != nil { if failInit && err != nil {
s := err.Error() // convert to string s := err.Error() // convert to string
if s != expstr { if s != expstr {
t.Errorf("test #%d: FAIL", index) t.Errorf("test #%d: FAIL", index)
@@ -1346,7 +1346,7 @@ func TestAstFunc2(t *testing.T) {
} }
return // fail happened during lex parse, don't run init/interpolate! return // fail happened during lex parse, don't run init/interpolate!
} }
if fail9 && err == nil { if failInit && err == nil {
t.Errorf("test #%d: FAIL", index) t.Errorf("test #%d: FAIL", index)
t.Errorf("test #%d: Init passed, expected fail", index) t.Errorf("test #%d: Init passed, expected fail", index)
return return

View File

@@ -1 +1 @@
# err: err9: duplicate struct field name of: `x` # err: errInit: duplicate struct field name of: `x`