Skip to content
Myr

atexit_test.go

This file

Path

src/util/atexit_test.go

24 lines · 446 bytes · Go

Last changed by

Not known.

History of this file

Take it

1package 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}