lang: Improve sub testing
This makes individual sub tests from the table easier to run.
This commit is contained in:
@@ -945,38 +945,40 @@ func TestInterpretMany(t *testing.T) {
|
|||||||
|
|
||||||
names := []string{}
|
names := []string{}
|
||||||
for index, tc := range testCases { // run all the tests
|
for index, tc := range testCases { // run all the tests
|
||||||
name, code, fail, exp := tc.name, tc.code, tc.fail, tc.graph
|
if tc.name == "" {
|
||||||
|
t.Errorf("test #%d: not named", index)
|
||||||
if name == "" {
|
|
||||||
name = "<sub test not named>"
|
|
||||||
}
|
|
||||||
if util.StrInList(name, names) {
|
|
||||||
t.Errorf("test #%d: duplicate sub test name of: %s", index, name)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
names = append(names, name)
|
if util.StrInList(tc.name, names) {
|
||||||
|
t.Errorf("test #%d: duplicate sub test name of: %s", index, tc.name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
names = append(names, tc.name)
|
||||||
|
|
||||||
//if index != 3 { // hack to run a subset (useful for debugging)
|
//if index != 3 { // hack to run a subset (useful for debugging)
|
||||||
//if tc.name != "nil" {
|
//if tc.name != "nil" {
|
||||||
// continue
|
// continue
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
t.Run(fmt.Sprintf("test #%d (%s)", index, tc.name), func(t *testing.T) {
|
||||||
|
name, code, fail, exp := tc.name, tc.code, tc.fail, tc.graph
|
||||||
|
|
||||||
t.Logf("\n\ntest #%d (%s) ----------------\n\n", index, name)
|
t.Logf("\n\ntest #%d (%s) ----------------\n\n", index, name)
|
||||||
|
|
||||||
graph, err := runInterpret(t, code)
|
graph, err := runInterpret(t, code)
|
||||||
if !fail && err != nil {
|
if !fail && err != nil {
|
||||||
t.Errorf("test #%d: FAIL", index)
|
t.Errorf("test #%d: FAIL", index)
|
||||||
t.Errorf("test #%d: runInterpret failed with: %+v", index, err)
|
t.Errorf("test #%d: runInterpret failed with: %+v", index, err)
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
if fail && err == nil {
|
if fail && err == nil {
|
||||||
t.Errorf("test #%d: FAIL", index)
|
t.Errorf("test #%d: FAIL", index)
|
||||||
t.Errorf("test #%d: runInterpret passed, expected fail", index)
|
t.Errorf("test #%d: runInterpret passed, expected fail", index)
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if fail { // can't process graph if it's nil
|
if fail { // can't process graph if it's nil
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Logf("test #%d: graph: %+v", index, graph)
|
t.Logf("test #%d: graph: %+v", index, graph)
|
||||||
@@ -986,7 +988,8 @@ func TestInterpretMany(t *testing.T) {
|
|||||||
t.Logf("test #%d: actual: %v%s", index, graph, fullPrint(graph))
|
t.Logf("test #%d: actual: %v%s", index, graph, fullPrint(graph))
|
||||||
t.Logf("test #%d: expected: %v%s", index, exp, fullPrint(exp))
|
t.Logf("test #%d: expected: %v%s", index, exp, fullPrint(exp))
|
||||||
t.Errorf("test #%d: cmp error:\n%v", index, err)
|
t.Errorf("test #%d: cmp error:\n%v", index, err)
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user