atexit_test.go
This file
Path
src/util/atexit_test.go
24 lines · 446 bytes · Go
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than 76efddd point at it.
bash: shift-delete to delete history entries during CTRL-RJunegunn Choibefore adoption76efddd
lines 1–24why, one step back1package util23import (4 "reflect"5 "testing"6)78func TestAtExit(t *testing.T) {9 want := []int{3, 2, 1, 0}10 var called []int11 for i := range 4 {12 n := i13 AtExit(func() { called = append(called, n) })14 }15 RunAtExitFuncs()16 if !reflect.DeepEqual(called, want) {17 t.Errorf("AtExit: want call order: %v got: %v", want, called)18 }1920 RunAtExitFuncs()21 if !reflect.DeepEqual(called, want) {22 t.Error("AtExit: should only call exit funcs once")23 }24}