lang: Rename old fail8 variable to failInterpolate

Eight... Interpolate?

Cleanups...
This commit is contained in:
James Shubin
2021-05-08 04:30:17 -04:00
parent f778f53744
commit a02d282d3e
5 changed files with 29 additions and 35 deletions

View File

@@ -1000,8 +1000,7 @@ func TestAstFunc2(t *testing.T) {
const magicError = "# err: "
const magicErrorLexParse = "errLexParse: "
const magicErrorInit = "errInit: "
const magicError8 = "err8: " // TODO: rename
// TODO: move them all down by one
const magicInterpolate = "errInterpolate: "
const magicErrorSetScope = "errSetScope: "
const magicErrorUnify = "errUnify: "
const magicErrorGraph = "errGraph: "
@@ -1037,8 +1036,7 @@ func TestAstFunc2(t *testing.T) {
type errs struct {
failLexParse bool
failInit bool
fail8 bool // TODO: rename
// TODO: move them all down by one
failInterpolate bool
failSetScope bool
failUnify bool
failGraph bool
@@ -1098,8 +1096,7 @@ func TestAstFunc2(t *testing.T) {
errStr := ""
failLexParse := false
failInit := false
fail8 := false // TODO: rename
// TODO: move them all down by one
failInterpolate := false
failSetScope := false
failUnify := false
failGraph := false
@@ -1119,12 +1116,11 @@ func TestAstFunc2(t *testing.T) {
str = errStr
failInit = true
}
if strings.HasPrefix(str, magicError8) { // TODO: rename
errStr = strings.TrimPrefix(str, magicError8)
if strings.HasPrefix(str, magicInterpolate) {
errStr = strings.TrimPrefix(str, magicInterpolate)
str = errStr
fail8 = true
failInterpolate = true
}
// TODO: move them all down by one
if strings.HasPrefix(str, magicErrorSetScope) {
errStr = strings.TrimPrefix(str, magicErrorSetScope)
str = errStr
@@ -1161,8 +1157,7 @@ func TestAstFunc2(t *testing.T) {
errs: errs{
failLexParse: failLexParse,
failInit: failInit,
fail8: fail8, // TODO: rename
// TODO: move them all down by one
failInterpolate: failInterpolate,
failSetScope: failSetScope,
failUnify: failUnify,
failGraph: failGraph,
@@ -1203,8 +1198,7 @@ func TestAstFunc2(t *testing.T) {
src := dir + path // location of the test
failLexParse := errs.failLexParse
failInit := errs.failInit
fail8 := errs.fail8 // TODO: rename
// TODO: move them all down by one
failInterpolate := errs.failInterpolate
failSetScope := errs.failSetScope
failUnify := errs.failUnify
failGraph := errs.failGraph
@@ -1353,12 +1347,12 @@ func TestAstFunc2(t *testing.T) {
}
iast, err := ast.Interpolate()
if (!fail || !fail8) && err != nil {
if (!fail || !failInterpolate) && err != nil {
t.Errorf("test #%d: FAIL", index)
t.Errorf("test #%d: Interpolate failed with: %+v", index, err)
return
}
if fail8 && err != nil {
if failInterpolate && err != nil {
s := err.Error() // convert to string
if s != expstr {
t.Errorf("test #%d: FAIL", index)
@@ -1368,7 +1362,7 @@ func TestAstFunc2(t *testing.T) {
}
return // fail happened during lex parse, don't run init/interpolate!
}
if fail8 && err == nil {
if failInterpolate && err == nil {
t.Errorf("test #%d: FAIL", index)
t.Errorf("test #%d: Interpolate passed, expected fail", index)
return

View File

@@ -1 +1 @@
# err: err8: parser failed: cannot parse string: X: ${foo()}
# err: errInterpolate: parser failed: cannot parse string: X: ${foo()}

View File

@@ -1 +1 @@
# err: err8: parser failed: cannot parse string: X: ${}
# err: errInterpolate: parser failed: cannot parse string: X: ${}

View File

@@ -1 +1 @@
# err: err8: parser failed: cannot parse string: X: \z
# err: errInterpolate: parser failed: cannot parse string: X: \z

View File

@@ -1 +1 @@
# err: err8: parser failed: cannot parse string: X: there is no \j sequence
# err: errInterpolate: parser failed: cannot parse string: X: there is no \j sequence