lang, test: Inline some overly indented tests

Sometimes you're busy hacking and it's nice for future you to fix up
your code!
This commit is contained in:
James Shubin
2019-07-21 01:19:15 -04:00
parent 9ca6c6a315
commit 64288b4914
4 changed files with 113 additions and 104 deletions

View File

@@ -143,10 +143,15 @@ func TestPureFuncExec0(t *testing.T) {
return return
} }
if !reflect.DeepEqual(result, expect) { if reflect.DeepEqual(result, expect) {
return
}
// double check because DeepEqual is different since the func exists // double check because DeepEqual is different since the func exists
diff := pretty.Compare(result, expect) diff := pretty.Compare(result, expect)
if diff != "" { // bonus if diff == "" { // bonus
return
}
t.Errorf("test #%d: result did not match expected", index) t.Errorf("test #%d: result did not match expected", index)
// TODO: consider making our own recursive print function // TODO: consider making our own recursive print function
t.Logf("test #%d: actual: \n\n%s\n", index, spew.Sdump(result)) t.Logf("test #%d: actual: \n\n%s\n", index, spew.Sdump(result))
@@ -163,9 +168,6 @@ func TestPureFuncExec0(t *testing.T) {
t.Logf("test #%d: actual: \n\n%s\n", index, diffable.Sprint(result)) t.Logf("test #%d: actual: \n\n%s\n", index, diffable.Sprint(result))
t.Logf("test #%d: expected: \n\n%s", index, diffable.Sprint(expect)) t.Logf("test #%d: expected: \n\n%s", index, diffable.Sprint(expect))
t.Logf("test #%d: diff:\n%s", index, diff) t.Logf("test #%d: diff:\n%s", index, diff)
return
}
}
}) })
} }
} }

View File

@@ -145,11 +145,17 @@ func TestMetadataParse0(t *testing.T) {
return return
} }
if metadata != nil { if metadata == nil {
if !reflect.DeepEqual(meta, metadata) { return
}
if reflect.DeepEqual(meta, metadata) {
return
}
// double check because DeepEqual is different since the func exists // double check because DeepEqual is different since the func exists
diff := pretty.Compare(meta, metadata) diff := pretty.Compare(meta, metadata)
if diff != "" { // bonus if diff == "" { // bonus
return
}
t.Errorf("test #%d: metadata did not match expected", index) t.Errorf("test #%d: metadata did not match expected", index)
// TODO: consider making our own recursive print function // TODO: consider making our own recursive print function
t.Logf("test #%d: actual: \n\n%s\n", index, spew.Sdump(meta)) t.Logf("test #%d: actual: \n\n%s\n", index, spew.Sdump(meta))
@@ -166,10 +172,6 @@ func TestMetadataParse0(t *testing.T) {
t.Logf("test #%d: actual: \n\n%s\n", index, diffable.Sprint(meta)) t.Logf("test #%d: actual: \n\n%s\n", index, diffable.Sprint(meta))
t.Logf("test #%d: expected: \n\n%s", index, diffable.Sprint(metadata)) t.Logf("test #%d: expected: \n\n%s", index, diffable.Sprint(metadata))
t.Logf("test #%d: diff:\n%s", index, diff) t.Logf("test #%d: diff:\n%s", index, diff)
return
}
}
}
}) })
} }
} }

View File

@@ -185,18 +185,19 @@ func TestInterpolate0(t *testing.T) {
} }
} }
if !reflect.DeepEqual(iast, exp) { if reflect.DeepEqual(iast, exp) {
return
}
// double check because DeepEqual is different since the logf exists // double check because DeepEqual is different since the logf exists
diff := pretty.Compare(iast, exp) diff := pretty.Compare(iast, exp)
if diff != "" { // bonus if diff == "" { // bonus
return
}
t.Errorf("test #%d: AST did not match expected", index) t.Errorf("test #%d: AST did not match expected", index)
// TODO: consider making our own recursive print function // TODO: consider making our own recursive print function
t.Logf("test #%d: actual: \n%s", index, spew.Sdump(iast)) t.Logf("test #%d: actual: \n%s", index, spew.Sdump(iast))
t.Logf("test #%d: expected: \n%s", index, spew.Sdump(exp)) t.Logf("test #%d: expected: \n%s", index, spew.Sdump(exp))
t.Logf("test #%d: diff:\n%s", index, diff) t.Logf("test #%d: diff:\n%s", index, diff)
return
}
}
}) })
} }
} }
@@ -421,18 +422,19 @@ func TestInterpolateBasicStmt(t *testing.T) {
} }
} }
if !reflect.DeepEqual(iast, exp) { if reflect.DeepEqual(iast, exp) {
return
}
// double check because DeepEqual is different since the logf exists // double check because DeepEqual is different since the logf exists
diff := pretty.Compare(iast, exp) diff := pretty.Compare(iast, exp)
if diff != "" { // bonus if diff == "" { // bonus
return
}
t.Errorf("test #%d: AST did not match expected", index) t.Errorf("test #%d: AST did not match expected", index)
// TODO: consider making our own recursive print function // TODO: consider making our own recursive print function
t.Logf("test #%d: actual: \n%s", index, spew.Sdump(iast)) t.Logf("test #%d: actual: \n%s", index, spew.Sdump(iast))
t.Logf("test #%d: expected: \n%s", index, spew.Sdump(exp)) t.Logf("test #%d: expected: \n%s", index, spew.Sdump(exp))
t.Logf("test #%d: diff:\n%s", index, diff) t.Logf("test #%d: diff:\n%s", index, diff)
return
}
}
}) })
} }
} }
@@ -742,18 +744,19 @@ func TestInterpolateBasicExpr(t *testing.T) {
} }
} }
if !reflect.DeepEqual(iast, exp) { if reflect.DeepEqual(iast, exp) {
return
}
// double check because DeepEqual is different since the logf exists // double check because DeepEqual is different since the logf exists
diff := pretty.Compare(iast, exp) diff := pretty.Compare(iast, exp)
if diff != "" { // bonus if diff == "" { // bonus
return
}
t.Errorf("test #%d: AST did not match expected", index) t.Errorf("test #%d: AST did not match expected", index)
// TODO: consider making our own recursive print function // TODO: consider making our own recursive print function
t.Logf("test #%d: actual: \n%s", index, spew.Sdump(iast)) t.Logf("test #%d: actual: \n%s", index, spew.Sdump(iast))
t.Logf("test #%d: expected: \n%s", index, spew.Sdump(exp)) t.Logf("test #%d: expected: \n%s", index, spew.Sdump(exp))
t.Logf("test #%d: diff:\n%s", index, diff) t.Logf("test #%d: diff:\n%s", index, diff)
return
}
}
}) })
} }
} }

View File

@@ -2108,8 +2108,12 @@ func TestLexParse0(t *testing.T) {
return return
} }
if exp != nil { if exp == nil {
if !reflect.DeepEqual(ast, exp) { return
}
if reflect.DeepEqual(ast, exp) {
return
}
// double check because DeepEqual is different since the func exists // double check because DeepEqual is different since the func exists
// more details, for tricky cases: // more details, for tricky cases:
@@ -2121,7 +2125,9 @@ func TestLexParse0(t *testing.T) {
SkipZeroFields: true, SkipZeroFields: true,
} }
diff := diffable.Compare(exp, ast) diff := diffable.Compare(exp, ast)
if diff != "" { // bonus if diff == "" { // bonus
return
}
t.Errorf("test #%d: AST did not match expected", index) t.Errorf("test #%d: AST did not match expected", index)
// TODO: consider making our own recursive print function // TODO: consider making our own recursive print function
t.Logf("test #%d: actual: \n\n%s\n", index, spew.Sdump(ast)) t.Logf("test #%d: actual: \n\n%s\n", index, spew.Sdump(ast))
@@ -2130,10 +2136,6 @@ func TestLexParse0(t *testing.T) {
t.Logf("test #%d: actual: \n\n%s\n", index, diffable.Sprint(ast)) t.Logf("test #%d: actual: \n\n%s\n", index, diffable.Sprint(ast))
t.Logf("test #%d: expected: \n\n%s", index, diffable.Sprint(exp)) t.Logf("test #%d: expected: \n\n%s", index, diffable.Sprint(exp))
t.Logf("test #%d: diff:\n%s", index, diff) t.Logf("test #%d: diff:\n%s", index, diff)
return
}
}
}
}) })
} }
} }