Wrapped ph7_function_name
This commit is contained in:
parent
57f15fdbd4
commit
880c237e6d
5
ph7.go
5
ph7.go
@ -247,7 +247,10 @@ func (c *Context) RandomString(length int) (string, error) {
|
||||
// TODO (*Context).PeekAuxData
|
||||
// TODO (*Context).PopAuxData
|
||||
// TODO (*Context).ResultBufLength
|
||||
// TODO (*Context).FunctionName
|
||||
|
||||
func (c *Context) FunctionName() string {
|
||||
return C.GoString(C.ph7_function_name((*C.ph7_context)(c)))
|
||||
}
|
||||
|
||||
// TODO (*Context).AllocChunk
|
||||
// TODO (*Context).ReallocChunk
|
||||
|
13
ph7_test.go
13
ph7_test.go
@ -198,6 +198,19 @@ func TestContextThrowError(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFunctionName(t *testing.T) {
|
||||
const script = "echo doStuff();"
|
||||
vm, close := setupVM(t, script)
|
||||
defer close()
|
||||
|
||||
f := func(ctx *ph7.Context) error {
|
||||
_, err := fmt.Fprint(ctx, ctx.FunctionName())
|
||||
return err
|
||||
}
|
||||
mustSucceed(t, vm.CreateFunction("doStuff", CtxFunc(f)))
|
||||
expectOutput(t, vm, "doStuff")
|
||||
}
|
||||
|
||||
func TestContextResultInt(t *testing.T) {
|
||||
testResultCode(t, "42", func(ctx *ph7.Context) error {
|
||||
return ctx.ResultInt(42)
|
||||
|
Loading…
Reference in New Issue
Block a user