+ xiang.helper.Return
This commit is contained in:
parent
bae9e1ae88
commit
8ba5a624ae
3 changed files with 12 additions and 0 deletions
|
|
@ -5,6 +5,11 @@ import (
|
||||||
"github.com/yaoapp/kun/exception"
|
"github.com/yaoapp/kun/exception"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ProcessReturn xiang.helper.Return 返回数值
|
||||||
|
func ProcessReturn(process *gou.Process) interface{} {
|
||||||
|
return process.Args
|
||||||
|
}
|
||||||
|
|
||||||
// ProcessThrow xiang.helper.Throw 抛出异常
|
// ProcessThrow xiang.helper.Throw 抛出异常
|
||||||
func ProcessThrow(process *gou.Process) interface{} {
|
func ProcessThrow(process *gou.Process) interface{} {
|
||||||
process.ValidateArgNums(2)
|
process.ValidateArgNums(2)
|
||||||
|
|
@ -14,3 +14,9 @@ func TestProcessThrow(t *testing.T) {
|
||||||
gou.NewProcess("xiang.helper.Throw", "Someting error", 500).Run()
|
gou.NewProcess("xiang.helper.Throw", "Someting error", 500).Run()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestProcessReturn(t *testing.T) {
|
||||||
|
v := gou.NewProcess("xiang.helper.Return", "hello", "world").Run().([]interface{})
|
||||||
|
assert.Equal(t, "hello", v[0])
|
||||||
|
assert.Equal(t, "world", v[1])
|
||||||
|
}
|
||||||
|
|
@ -47,6 +47,7 @@ func init() {
|
||||||
|
|
||||||
gou.RegisterProcessHandler("xiang.helper.Print", ProcessPrint)
|
gou.RegisterProcessHandler("xiang.helper.Print", ProcessPrint)
|
||||||
gou.RegisterProcessHandler("xiang.helper.Throw", ProcessThrow)
|
gou.RegisterProcessHandler("xiang.helper.Throw", ProcessThrow)
|
||||||
|
gou.RegisterProcessHandler("xiang.helper.Return", ProcessReturn)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue