2018-07-16 20:34:20 -04:00
|
|
|
package caller
|
2017-07-27 14:43:13 -04:00
|
|
|
|
2018-07-16 20:34:20 -04:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
2017-07-27 14:43:13 -04:00
|
|
|
|
|
|
|
func fun1() string {
|
2018-07-16 20:34:20 -04:00
|
|
|
return Name(0)
|
2017-07-27 14:43:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func fun2() string {
|
2018-07-16 20:34:20 -04:00
|
|
|
return Name(1)
|
2017-07-27 14:43:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func fun3() string {
|
|
|
|
return fun4()
|
|
|
|
}
|
|
|
|
|
|
|
|
func fun4() string {
|
2018-07-16 20:34:20 -04:00
|
|
|
return Name(0)
|
2017-07-27 14:43:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func fun5() string {
|
|
|
|
return fun6()
|
|
|
|
}
|
|
|
|
|
|
|
|
func fun6() string {
|
2018-07-16 20:34:20 -04:00
|
|
|
return Name(1)
|
2017-07-27 14:43:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCaller(t *testing.T) {
|
|
|
|
funName := fun1()
|
|
|
|
if funName != "fun1" {
|
|
|
|
t.Fatalf("error on fun1 caller %s", funName)
|
|
|
|
}
|
|
|
|
|
|
|
|
funName = fun2()
|
|
|
|
if funName != "TestCaller" {
|
|
|
|
t.Fatalf("error on fun2 caller %s", funName)
|
|
|
|
}
|
|
|
|
|
|
|
|
funName = fun3()
|
|
|
|
if funName != "fun4" {
|
|
|
|
t.Fatalf("error on fun2 caller %s", funName)
|
|
|
|
}
|
|
|
|
|
|
|
|
funName = fun5()
|
|
|
|
if funName != "fun5" {
|
|
|
|
t.Fatalf("error on fun5 caller %s", funName)
|
|
|
|
}
|
|
|
|
}
|