|
|
|
@@ -549,7 +549,7 @@ func TestAstFunc1(t *testing.T) {
|
|
|
|
const magicErrorLexParse = "errLexParse: "
|
|
|
|
const magicErrorLexParse = "errLexParse: "
|
|
|
|
const magicErrorFailInit = "errInit: "
|
|
|
|
const magicErrorFailInit = "errInit: "
|
|
|
|
const magicErrorSetScope = "errSetScope: "
|
|
|
|
const magicErrorSetScope = "errSetScope: "
|
|
|
|
const magicError3 = "err3: "
|
|
|
|
const magicErrorUnify = "errUnify: "
|
|
|
|
const magicError4 = "err4: "
|
|
|
|
const magicError4 = "err4: "
|
|
|
|
const magicEmpty = "# empty!"
|
|
|
|
const magicEmpty = "# empty!"
|
|
|
|
dir, err := util.TestDirFull()
|
|
|
|
dir, err := util.TestDirFull()
|
|
|
|
@@ -582,7 +582,7 @@ func TestAstFunc1(t *testing.T) {
|
|
|
|
failLexParse bool
|
|
|
|
failLexParse bool
|
|
|
|
failInit bool
|
|
|
|
failInit bool
|
|
|
|
failSetScope bool
|
|
|
|
failSetScope bool
|
|
|
|
fail3 bool
|
|
|
|
failUnify bool
|
|
|
|
fail4 bool
|
|
|
|
fail4 bool
|
|
|
|
}
|
|
|
|
}
|
|
|
|
type test struct { // an individual test
|
|
|
|
type test struct { // an individual test
|
|
|
|
@@ -639,7 +639,7 @@ func TestAstFunc1(t *testing.T) {
|
|
|
|
failLexParse := false
|
|
|
|
failLexParse := false
|
|
|
|
failInit := false
|
|
|
|
failInit := false
|
|
|
|
failSetScope := false
|
|
|
|
failSetScope := false
|
|
|
|
fail3 := false
|
|
|
|
failUnify := false
|
|
|
|
fail4 := false
|
|
|
|
fail4 := false
|
|
|
|
if strings.HasPrefix(str, magicError) {
|
|
|
|
if strings.HasPrefix(str, magicError) {
|
|
|
|
errStr = strings.TrimPrefix(str, magicError)
|
|
|
|
errStr = strings.TrimPrefix(str, magicError)
|
|
|
|
@@ -660,10 +660,10 @@ func TestAstFunc1(t *testing.T) {
|
|
|
|
str = errStr
|
|
|
|
str = errStr
|
|
|
|
failSetScope = true
|
|
|
|
failSetScope = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if strings.HasPrefix(str, magicError3) {
|
|
|
|
if strings.HasPrefix(str, magicErrorUnify) {
|
|
|
|
errStr = strings.TrimPrefix(str, magicError3)
|
|
|
|
errStr = strings.TrimPrefix(str, magicErrorUnify)
|
|
|
|
str = errStr
|
|
|
|
str = errStr
|
|
|
|
fail3 = true
|
|
|
|
failUnify = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if strings.HasPrefix(str, magicError4) {
|
|
|
|
if strings.HasPrefix(str, magicError4) {
|
|
|
|
errStr = strings.TrimPrefix(str, magicError4)
|
|
|
|
errStr = strings.TrimPrefix(str, magicError4)
|
|
|
|
@@ -682,7 +682,7 @@ func TestAstFunc1(t *testing.T) {
|
|
|
|
failLexParse: failLexParse,
|
|
|
|
failLexParse: failLexParse,
|
|
|
|
failInit: failInit,
|
|
|
|
failInit: failInit,
|
|
|
|
failSetScope: failSetScope,
|
|
|
|
failSetScope: failSetScope,
|
|
|
|
fail3: fail3,
|
|
|
|
failUnify: failUnify,
|
|
|
|
fail4: fail4,
|
|
|
|
fail4: fail4,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
})
|
|
|
|
@@ -720,7 +720,7 @@ func TestAstFunc1(t *testing.T) {
|
|
|
|
failLexParse := errs.failLexParse
|
|
|
|
failLexParse := errs.failLexParse
|
|
|
|
failInit := errs.failInit
|
|
|
|
failInit := errs.failInit
|
|
|
|
failSetScope := errs.failSetScope
|
|
|
|
failSetScope := errs.failSetScope
|
|
|
|
fail3 := errs.fail3
|
|
|
|
failUnify := errs.failUnify
|
|
|
|
fail4 := errs.fail4
|
|
|
|
fail4 := errs.fail4
|
|
|
|
|
|
|
|
|
|
|
|
t.Logf("\n\ntest #%d (%s) ----------------\npath: %s\n\n", index, name, src)
|
|
|
|
t.Logf("\n\ntest #%d (%s) ----------------\npath: %s\n\n", index, name, src)
|
|
|
|
@@ -891,12 +891,12 @@ func TestAstFunc1(t *testing.T) {
|
|
|
|
Logf: xlogf,
|
|
|
|
Logf: xlogf,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
err = unifier.Unify()
|
|
|
|
err = unifier.Unify()
|
|
|
|
if (!fail || !fail3) && err != nil {
|
|
|
|
if (!fail || !failUnify) && err != nil {
|
|
|
|
t.Errorf("test #%d: FAIL", index)
|
|
|
|
t.Errorf("test #%d: FAIL", index)
|
|
|
|
t.Errorf("test #%d: could not unify types: %+v", index, err)
|
|
|
|
t.Errorf("test #%d: could not unify types: %+v", index, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if fail3 && err != nil {
|
|
|
|
if failUnify && 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)
|
|
|
|
@@ -906,7 +906,7 @@ func TestAstFunc1(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return // fail happened during unification, don't run Graph!
|
|
|
|
return // fail happened during unification, don't run Graph!
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if fail3 && err == nil {
|
|
|
|
if failUnify && err == nil {
|
|
|
|
t.Errorf("test #%d: FAIL", index)
|
|
|
|
t.Errorf("test #%d: FAIL", index)
|
|
|
|
t.Errorf("test #%d: unification passed, expected fail", index)
|
|
|
|
t.Errorf("test #%d: unification passed, expected fail", index)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
@@ -1003,7 +1003,7 @@ func TestAstFunc2(t *testing.T) {
|
|
|
|
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: "
|
|
|
|
const magicError3 = "err3: "
|
|
|
|
const magicErrorUnify = "errUnify: "
|
|
|
|
const magicError4 = "err4: "
|
|
|
|
const magicError4 = "err4: "
|
|
|
|
const magicError5 = "err5: "
|
|
|
|
const magicError5 = "err5: "
|
|
|
|
const magicError6 = "err6: "
|
|
|
|
const magicError6 = "err6: "
|
|
|
|
@@ -1040,7 +1040,7 @@ func TestAstFunc2(t *testing.T) {
|
|
|
|
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
|
|
|
|
fail3 bool
|
|
|
|
failUnify bool
|
|
|
|
fail4 bool
|
|
|
|
fail4 bool
|
|
|
|
fail5 bool
|
|
|
|
fail5 bool
|
|
|
|
fail6 bool
|
|
|
|
fail6 bool
|
|
|
|
@@ -1101,7 +1101,7 @@ func TestAstFunc2(t *testing.T) {
|
|
|
|
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
|
|
|
|
fail3 := false
|
|
|
|
failUnify := false
|
|
|
|
fail4 := false
|
|
|
|
fail4 := false
|
|
|
|
fail5 := false
|
|
|
|
fail5 := false
|
|
|
|
fail6 := false
|
|
|
|
fail6 := false
|
|
|
|
@@ -1130,10 +1130,10 @@ func TestAstFunc2(t *testing.T) {
|
|
|
|
str = errStr
|
|
|
|
str = errStr
|
|
|
|
failSetScope = true
|
|
|
|
failSetScope = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if strings.HasPrefix(str, magicError3) {
|
|
|
|
if strings.HasPrefix(str, magicErrorUnify) {
|
|
|
|
errStr = strings.TrimPrefix(str, magicError3)
|
|
|
|
errStr = strings.TrimPrefix(str, magicErrorUnify)
|
|
|
|
str = errStr
|
|
|
|
str = errStr
|
|
|
|
fail3 = true
|
|
|
|
failUnify = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if strings.HasPrefix(str, magicError4) {
|
|
|
|
if strings.HasPrefix(str, magicError4) {
|
|
|
|
errStr = strings.TrimPrefix(str, magicError4)
|
|
|
|
errStr = strings.TrimPrefix(str, magicError4)
|
|
|
|
@@ -1164,7 +1164,7 @@ func TestAstFunc2(t *testing.T) {
|
|
|
|
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,
|
|
|
|
fail3: fail3,
|
|
|
|
failUnify: failUnify,
|
|
|
|
fail4: fail4,
|
|
|
|
fail4: fail4,
|
|
|
|
fail5: fail5,
|
|
|
|
fail5: fail5,
|
|
|
|
fail6: fail6,
|
|
|
|
fail6: fail6,
|
|
|
|
@@ -1206,7 +1206,7 @@ func TestAstFunc2(t *testing.T) {
|
|
|
|
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
|
|
|
|
fail3 := errs.fail3
|
|
|
|
failUnify := errs.failUnify
|
|
|
|
fail4 := errs.fail4
|
|
|
|
fail4 := errs.fail4
|
|
|
|
fail5 := errs.fail5
|
|
|
|
fail5 := errs.fail5
|
|
|
|
fail6 := errs.fail6
|
|
|
|
fail6 := errs.fail6
|
|
|
|
@@ -1408,12 +1408,12 @@ func TestAstFunc2(t *testing.T) {
|
|
|
|
Logf: xlogf,
|
|
|
|
Logf: xlogf,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
err = unifier.Unify()
|
|
|
|
err = unifier.Unify()
|
|
|
|
if (!fail || !fail3) && err != nil {
|
|
|
|
if (!fail || !failUnify) && err != nil {
|
|
|
|
t.Errorf("test #%d: FAIL", index)
|
|
|
|
t.Errorf("test #%d: FAIL", index)
|
|
|
|
t.Errorf("test #%d: could not unify types: %+v", index, err)
|
|
|
|
t.Errorf("test #%d: could not unify types: %+v", index, err)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if fail3 && err != nil {
|
|
|
|
if failUnify && 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)
|
|
|
|
@@ -1423,7 +1423,7 @@ func TestAstFunc2(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return // fail happened during unification, don't run Graph!
|
|
|
|
return // fail happened during unification, don't run Graph!
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if fail3 && err == nil {
|
|
|
|
if failUnify && err == nil {
|
|
|
|
t.Errorf("test #%d: FAIL", index)
|
|
|
|
t.Errorf("test #%d: FAIL", index)
|
|
|
|
t.Errorf("test #%d: unification passed, expected fail", index)
|
|
|
|
t.Errorf("test #%d: unification passed, expected fail", index)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|