package command import "testing" func TestCommand_Exec(t *testing.T) { zs := NewPerson("张三", NewCommand(nil, nil)) ls := NewPerson("老四", NewCommand(&zs, zs.Buy)) ww := NewPerson("王五", NewCommand(&ls, ls.Drink)) ml := NewPerson("马六", NewCommand(&ww, ww.Eat)) tq := NewPerson("田七", NewCommand(&ml, ml.Sleep)) hb := NewPerson("胡八", NewCommand(&tq, tq.Wash)) hb.cmd.Exec() }