package interceptor import ( "path/filepath" "runtime" "testing" "github.com/mattn/anko/env" ) func TestAnkointerceptor_ExecRequire(t *testing.T) { // 创建测试环境 e := env.NewEnv() // 创建拦截器实例 interceptor := NewAnkointerceptor(e) _, file, _, _ := runtime.Caller(0) scriptPath := filepath.Join(filepath.Dir(file), "testdata/test_caller.ank") v, _ := interceptor.Exec(scriptPath) if v != "Hello, tom from test script" { t.Errorf("Not equal") } } func TestAnkointerceptor_loadlib(t *testing.T) { e := env.NewEnv() interceptor := NewAnkointerceptor(e) _, file, _, _ := runtime.Caller(0) scriptPath := filepath.Join(filepath.Dir(file), "testdata/test_loadso.ank") v, _ := interceptor.Exec(scriptPath) if v != "Hello, world!" { t.Errorf("Loadso test failed") } }