diff options
| author | Robert Griesemer <gri@golang.org> | 2009-12-15 15:35:38 -0800 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2009-12-15 15:35:38 -0800 |
| commit | e4bd81f903362d998f7bfc02095935408aff0bc5 (patch) | |
| tree | 05f75a90e239d33be427da4f9c5596d2fcb3dc96 /src/pkg/log/log_test.go | |
| parent | d9527dd16f72598b54a64550607bf892efa12384 (diff) | |
| download | golang-e4bd81f903362d998f7bfc02095935408aff0bc5.tar.gz | |
1) Change default gofmt default settings for
parsing and printing to new syntax.
Use -oldparser to parse the old syntax,
use -oldprinter to print the old syntax.
2) Change default gofmt formatting settings
to use tabs for indentation only and to use
spaces for alignment. This will make the code
alignment insensitive to an editor's tabwidth.
Use -spaces=false to use tabs for alignment.
3) Manually changed src/exp/parser/parser_test.go
so that it doesn't try to parse the parser's
source files using the old syntax (they have
new syntax now).
4) gofmt -w src misc test/bench
3rd set of files.
R=rsc
CC=golang-dev
http://codereview.appspot.com/180048
Diffstat (limited to 'src/pkg/log/log_test.go')
| -rw-r--r-- | src/pkg/log/log_test.go | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/pkg/log/log_test.go b/src/pkg/log/log_test.go index caef8b134..fd0b36c6e 100644 --- a/src/pkg/log/log_test.go +++ b/src/pkg/log/log_test.go @@ -7,25 +7,25 @@ package log // These tests are too simple. import ( - "bufio"; - "os"; - "regexp"; - "testing"; + "bufio" + "os" + "regexp" + "testing" ) const ( - Rdate = `[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]`; - Rtime = `[0-9][0-9]:[0-9][0-9]:[0-9][0-9]`; - Rmicroseconds = `\.[0-9][0-9][0-9][0-9][0-9][0-9]`; - Rline = `[0-9]+:`; - Rlongfile = `.*/[A-Za-z0-9_\-]+\.go:` + Rline; - Rshortfile = `[A-Za-z0-9_\-]+\.go:` + Rline; + Rdate = `[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]` + Rtime = `[0-9][0-9]:[0-9][0-9]:[0-9][0-9]` + Rmicroseconds = `\.[0-9][0-9][0-9][0-9][0-9][0-9]` + Rline = `[0-9]+:` + Rlongfile = `.*/[A-Za-z0-9_\-]+\.go:` + Rline + Rshortfile = `[A-Za-z0-9_\-]+\.go:` + Rline ) type tester struct { - flag int; - prefix string; - pattern string; // regexp that log output must match; we add ^ and expected_text$ always + flag int + prefix string + pattern string // regexp that log output must match; we add ^ and expected_text$ always } var tests = []tester{ @@ -35,10 +35,10 @@ var tests = []tester{ tester{Lok | Ldate, "", Rdate + " "}, tester{Lok | Ltime, "", Rtime + " "}, tester{Lok | Ltime | Lmicroseconds, "", Rtime + Rmicroseconds + " "}, - tester{Lok | Lmicroseconds, "", Rtime + Rmicroseconds + " "}, // microsec implies time + tester{Lok | Lmicroseconds, "", Rtime + Rmicroseconds + " "}, // microsec implies time tester{Lok | Llongfile, "", Rlongfile + " "}, tester{Lok | Lshortfile, "", Rshortfile + " "}, - tester{Lok | Llongfile | Lshortfile, "", Rshortfile + " "}, // shortfile overrides longfile + tester{Lok | Llongfile | Lshortfile, "", Rshortfile + " "}, // shortfile overrides longfile // everything at once: tester{Lok | Ldate | Ltime | Lmicroseconds | Llongfile, "XXX", "XXX" + Rdate + " " + Rtime + Rmicroseconds + " " + Rlongfile + " "}, tester{Lok | Ldate | Ltime | Lmicroseconds | Lshortfile, "XXX", "XXX" + Rdate + " " + Rtime + Rmicroseconds + " " + Rshortfile + " "}, @@ -46,26 +46,26 @@ var tests = []tester{ // Test using Log("hello", 23, "world") or using Logf("hello %d world", 23) func testLog(t *testing.T, flag int, prefix string, pattern string, useLogf bool) { - r, w, err1 := os.Pipe(); + r, w, err1 := os.Pipe() if err1 != nil { t.Fatal("pipe", err1) } - defer r.Close(); - defer w.Close(); - buf := bufio.NewReader(r); - l := New(w, nil, prefix, flag); + defer r.Close() + defer w.Close() + buf := bufio.NewReader(r) + l := New(w, nil, prefix, flag) if useLogf { l.Logf("hello %d world", 23) } else { l.Log("hello", 23, "world") } - line, err3 := buf.ReadString('\n'); + line, err3 := buf.ReadString('\n') if err3 != nil { t.Fatal("log error", err3) } - line = line[0 : len(line)-1]; - pattern = "^" + pattern + "hello 23 world$"; - matched, err4 := regexp.MatchString(pattern, line); + line = line[0 : len(line)-1] + pattern = "^" + pattern + "hello 23 world$" + matched, err4 := regexp.MatchString(pattern, line) if err4 != nil { t.Fatal("pattern did not compile:", err4) } @@ -76,7 +76,7 @@ func testLog(t *testing.T, flag int, prefix string, pattern string, useLogf bool func TestAllLog(t *testing.T) { for _, testcase := range tests { - testLog(t, testcase.flag, testcase.prefix, testcase.pattern, false); - testLog(t, testcase.flag, testcase.prefix, testcase.pattern, true); + testLog(t, testcase.flag, testcase.prefix, testcase.pattern, false) + testLog(t, testcase.flag, testcase.prefix, testcase.pattern, true) } } |
