test: Refactor unification_test to subtests
Testsuite for unification now uses subtests feature.
This commit is contained in:
@@ -475,24 +475,14 @@ func TestUnification1(t *testing.T) {
|
||||
}
|
||||
|
||||
for index, test := range values { // run all the tests
|
||||
name, ast, fail, expect := test.name, test.ast, test.fail, test.expect
|
||||
|
||||
if name == "" {
|
||||
name = "<sub test not named>"
|
||||
}
|
||||
|
||||
//if index != 3 { // hack to run a subset (useful for debugging)
|
||||
//if test.name != "nil" {
|
||||
// continue
|
||||
//}
|
||||
|
||||
t.Logf("\n\ntest #%d (%s) ----------------\n\n", index, name)
|
||||
t.Run(fmt.Sprintf("test #%d (%s)", index, test.name), func(t *testing.T) {
|
||||
ast, fail, expect := test.ast, test.fail, test.expect
|
||||
|
||||
//str := strings.NewReader(code)
|
||||
//ast, err := LexParse(str)
|
||||
//if err != nil {
|
||||
// t.Errorf("test #%d: lex/parse failed with: %+v", index, err)
|
||||
// continue
|
||||
// return
|
||||
//}
|
||||
// TODO: print out the AST's so that we can see the types
|
||||
t.Logf("\n\ntest #%d: AST (before): %+v\n", index, ast)
|
||||
@@ -502,7 +492,7 @@ func TestUnification1(t *testing.T) {
|
||||
//astInterpolated, err := ast.Interpolate() // interpolate strings in ast
|
||||
//if err != nil {
|
||||
// t.Errorf("test #%d: interpolate failed with: %+v", index, err)
|
||||
// continue
|
||||
// return
|
||||
//}
|
||||
//t.Logf("test #%d: astInterpolated: %+v", index, astInterpolated)
|
||||
|
||||
@@ -514,8 +504,9 @@ func TestUnification1(t *testing.T) {
|
||||
}
|
||||
// propagate the scope down through the AST...
|
||||
if err := ast.SetScope(scope); err != nil {
|
||||
t.Errorf("test #%d: FAIL", index)
|
||||
t.Errorf("test #%d: set scope failed with: %+v", index, err)
|
||||
continue
|
||||
return
|
||||
}
|
||||
|
||||
// apply type unification
|
||||
@@ -528,20 +519,18 @@ func TestUnification1(t *testing.T) {
|
||||
t.Logf("\n\ntest #%d: AST (after): %+v\n", index, ast)
|
||||
|
||||
if !fail && err != nil {
|
||||
t.Errorf("test #%d: FAIL", index)
|
||||
t.Errorf("test #%d: unification failed with: %+v", index, err)
|
||||
continue
|
||||
return
|
||||
}
|
||||
if fail && err == nil {
|
||||
t.Errorf("test #%d: FAIL", index)
|
||||
t.Errorf("test #%d: unification passed, expected fail", index)
|
||||
continue
|
||||
return
|
||||
}
|
||||
if fail {
|
||||
continue
|
||||
}
|
||||
// continue the test
|
||||
|
||||
if expect == nil {
|
||||
continue
|
||||
if expect == nil { // test done early
|
||||
return
|
||||
}
|
||||
// TODO: do this in sorted order
|
||||
var failed bool
|
||||
@@ -560,8 +549,8 @@ func TestUnification1(t *testing.T) {
|
||||
}
|
||||
}
|
||||
if failed {
|
||||
continue
|
||||
return
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user