Commit 8fb837d9 authored by Russ Cox's avatar Russ Cox

add test for once

R=r
DELTA=31  (31 added, 0 deleted, 0 changed)
OCL=21043
CL=21175
parent 42d89ac0
......@@ -37,6 +37,7 @@ FILES=\
TEST=\
bignum\
bufio\
once\
sort\
strings\
utf8\
......
// 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
import (
"once";
"testing";
)
var ncall int;
func Call() {
ncall++
}
export func TestOnce(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);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment