Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 1 of 1 for TestOncePanic (0.11 sec)

  1. src/sync/once_test.go

    	const N = 10
    	for i := 0; i < N; i++ {
    		go run(t, once, o, c)
    	}
    	for i := 0; i < N; i++ {
    		<-c
    	}
    	if *o != 1 {
    		t.Errorf("once failed outside run: %d is not 1", *o)
    	}
    }
    
    func TestOncePanic(t *testing.T) {
    	var once Once
    	func() {
    		defer func() {
    			if r := recover(); r == nil {
    				t.Fatalf("Once.Do did not panic")
    			}
    		}()
    		once.Do(func() {
    			panic("failed")
    		})
    	}()
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Sep 16 21:22:33 UTC 2014
    - 1.1K bytes
    - Viewed (0)
Back to top