|
|
|
@@ -1000,8 +1000,7 @@ func TestAstFunc2(t *testing.T) {
|
|
|
|
const magicError = "# err: "
|
|
|
|
const magicError = "# err: "
|
|
|
|
const magicErrorLexParse = "errLexParse: "
|
|
|
|
const magicErrorLexParse = "errLexParse: "
|
|
|
|
const magicErrorInit = "errInit: "
|
|
|
|
const magicErrorInit = "errInit: "
|
|
|
|
const magicError8 = "err8: " // TODO: rename
|
|
|
|
const magicInterpolate = "errInterpolate: "
|
|
|
|
// TODO: move them all down by one
|
|
|
|
|
|
|
|
const magicErrorSetScope = "errSetScope: "
|
|
|
|
const magicErrorSetScope = "errSetScope: "
|
|
|
|
const magicErrorUnify = "errUnify: "
|
|
|
|
const magicErrorUnify = "errUnify: "
|
|
|
|
const magicErrorGraph = "errGraph: "
|
|
|
|
const magicErrorGraph = "errGraph: "
|
|
|
|
@@ -1035,15 +1034,14 @@ func TestAstFunc2(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type errs struct {
|
|
|
|
type errs struct {
|
|
|
|
failLexParse bool
|
|
|
|
failLexParse bool
|
|
|
|
failInit bool
|
|
|
|
failInit bool
|
|
|
|
fail8 bool // TODO: rename
|
|
|
|
failInterpolate bool
|
|
|
|
// TODO: move them all down by one
|
|
|
|
failSetScope bool
|
|
|
|
failSetScope bool
|
|
|
|
failUnify bool
|
|
|
|
failUnify bool
|
|
|
|
failGraph bool
|
|
|
|
failGraph bool
|
|
|
|
fail5 bool
|
|
|
|
fail5 bool
|
|
|
|
fail6 bool
|
|
|
|
fail6 bool
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
type test struct { // an individual test
|
|
|
|
type test struct { // an individual test
|
|
|
|
name string
|
|
|
|
name string
|
|
|
|
@@ -1098,8 +1096,7 @@ func TestAstFunc2(t *testing.T) {
|
|
|
|
errStr := ""
|
|
|
|
errStr := ""
|
|
|
|
failLexParse := false
|
|
|
|
failLexParse := false
|
|
|
|
failInit := false
|
|
|
|
failInit := false
|
|
|
|
fail8 := false // TODO: rename
|
|
|
|
failInterpolate := false
|
|
|
|
// TODO: move them all down by one
|
|
|
|
|
|
|
|
failSetScope := false
|
|
|
|
failSetScope := false
|
|
|
|
failUnify := false
|
|
|
|
failUnify := false
|
|
|
|
failGraph := false
|
|
|
|
failGraph := false
|
|
|
|
@@ -1119,12 +1116,11 @@ func TestAstFunc2(t *testing.T) {
|
|
|
|
str = errStr
|
|
|
|
str = errStr
|
|
|
|
failInit = true
|
|
|
|
failInit = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if strings.HasPrefix(str, magicError8) { // TODO: rename
|
|
|
|
if strings.HasPrefix(str, magicInterpolate) {
|
|
|
|
errStr = strings.TrimPrefix(str, magicError8)
|
|
|
|
errStr = strings.TrimPrefix(str, magicInterpolate)
|
|
|
|
str = errStr
|
|
|
|
str = errStr
|
|
|
|
fail8 = true
|
|
|
|
failInterpolate = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO: move them all down by one
|
|
|
|
|
|
|
|
if strings.HasPrefix(str, magicErrorSetScope) {
|
|
|
|
if strings.HasPrefix(str, magicErrorSetScope) {
|
|
|
|
errStr = strings.TrimPrefix(str, magicErrorSetScope)
|
|
|
|
errStr = strings.TrimPrefix(str, magicErrorSetScope)
|
|
|
|
str = errStr
|
|
|
|
str = errStr
|
|
|
|
@@ -1159,15 +1155,14 @@ func TestAstFunc2(t *testing.T) {
|
|
|
|
fail: errStr != "",
|
|
|
|
fail: errStr != "",
|
|
|
|
expstr: str,
|
|
|
|
expstr: str,
|
|
|
|
errs: errs{
|
|
|
|
errs: errs{
|
|
|
|
failLexParse: failLexParse,
|
|
|
|
failLexParse: failLexParse,
|
|
|
|
failInit: failInit,
|
|
|
|
failInit: failInit,
|
|
|
|
fail8: fail8, // TODO: rename
|
|
|
|
failInterpolate: failInterpolate,
|
|
|
|
// TODO: move them all down by one
|
|
|
|
failSetScope: failSetScope,
|
|
|
|
failSetScope: failSetScope,
|
|
|
|
failUnify: failUnify,
|
|
|
|
failUnify: failUnify,
|
|
|
|
failGraph: failGraph,
|
|
|
|
failGraph: failGraph,
|
|
|
|
fail5: fail5,
|
|
|
|
fail5: fail5,
|
|
|
|
fail6: fail6,
|
|
|
|
fail6: fail6,
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
})
|
|
|
|
//t.Logf("adding: %s", f + "/")
|
|
|
|
//t.Logf("adding: %s", f + "/")
|
|
|
|
@@ -1203,8 +1198,7 @@ func TestAstFunc2(t *testing.T) {
|
|
|
|
src := dir + path // location of the test
|
|
|
|
src := dir + path // location of the test
|
|
|
|
failLexParse := errs.failLexParse
|
|
|
|
failLexParse := errs.failLexParse
|
|
|
|
failInit := errs.failInit
|
|
|
|
failInit := errs.failInit
|
|
|
|
fail8 := errs.fail8 // TODO: rename
|
|
|
|
failInterpolate := errs.failInterpolate
|
|
|
|
// TODO: move them all down by one
|
|
|
|
|
|
|
|
failSetScope := errs.failSetScope
|
|
|
|
failSetScope := errs.failSetScope
|
|
|
|
failUnify := errs.failUnify
|
|
|
|
failUnify := errs.failUnify
|
|
|
|
failGraph := errs.failGraph
|
|
|
|
failGraph := errs.failGraph
|
|
|
|
@@ -1353,12 +1347,12 @@ func TestAstFunc2(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
iast, err := ast.Interpolate()
|
|
|
|
iast, err := ast.Interpolate()
|
|
|
|
if (!fail || !fail8) && err != nil {
|
|
|
|
if (!fail || !failInterpolate) && err != nil {
|
|
|
|
t.Errorf("test #%d: FAIL", index)
|
|
|
|
t.Errorf("test #%d: FAIL", index)
|
|
|
|
t.Errorf("test #%d: Interpolate failed with: %+v", index, err)
|
|
|
|
t.Errorf("test #%d: Interpolate failed with: %+v", index, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if fail8 && err != nil {
|
|
|
|
if failInterpolate && 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)
|
|
|
|
@@ -1368,7 +1362,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 fail8 && err == nil {
|
|
|
|
if failInterpolate && err == nil {
|
|
|
|
t.Errorf("test #%d: FAIL", index)
|
|
|
|
t.Errorf("test #%d: FAIL", index)
|
|
|
|
t.Errorf("test #%d: Interpolate passed, expected fail", index)
|
|
|
|
t.Errorf("test #%d: Interpolate passed, expected fail", index)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|