Newer
Older
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package testing
var chatty = flag.Bool("chatty", false, "chatty")
// Insert tabs after newlines - but not the last one
for i := 0; i < len(s) - 1; i++ { // -1 because if last char is newline, don't bother
if s[i] == '\n' {
export type T struct {
errors string;
failed bool;
}
func (t *T) Fail() {
t.failed = true
}
func (t *T) FailNow() {
t.Fail();
t.ch <- t;
sys.goexit();
}
func (t *T) Log(args ...) {
}
func (t *T) Logf(format string, args ...) {
l := len(t.errors);
if l > 0 && t.errors[l-1] != '\n' {
t.errors += "\n"
}
}
func (t *T) Error(args ...) {
t.Log(args);
t.Fail();
}
func (t *T) Errorf(format string, args ...) {
t.Logf(format, args);
t.Fail();
}
func (t *T) Fatal(args ...) {
t.Log(args);
t.FailNow();
}
func (t *T) Fatalf(format string, args ...) {
t.Logf(format, args);
t.FailNow();
}
println("testing: warning: no tests to run");
if *chatty {
<-t.ch;
if t.failed {
println("--- FAIL:", tests[i].name);
print(t.errors);
} else if *chatty {
println("--- PASS:", tests[i].name);
print(t.errors);