1
0
mirror of https://github.com/golang/go synced 2024-10-03 08:21:21 -06:00
go/src/pkg/once/once_test.go
Robert Griesemer d65a5cce89 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

4th set of files.

R=rsc
CC=golang-dev
https://golang.org/cl/180049
2009-12-15 15:40:16 -08:00

31 lines
580 B
Go

// 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 once_test
import (
"once"
"testing"
)
var ncall int
func call() { ncall++ }
func TestDo(t *testing.T) {
ncall = 0
once.Do(call)
if ncall != 1 {
t.Fatalf("once.Do(call) didn't call(): ncall=%d", ncall)
}
once.Do(call)
if ncall != 1 {
t.Fatalf("second once.Do(call) did call(): ncall=%d", ncall)
}
once.Do(call)
if ncall != 1 {
t.Fatalf("third once.Do(call) did call(): ncall=%d", ncall)
}
}