|
@@ -1,6 +1,7 @@
|
|
package goja
|
|
package goja
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "errors"
|
|
"fmt"
|
|
"fmt"
|
|
"reflect"
|
|
"reflect"
|
|
"strings"
|
|
"strings"
|
|
@@ -989,6 +990,18 @@ func TestPrimitivePtr(t *testing.T) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func TestStringer(t *testing.T) {
|
|
|
|
+ vm := New()
|
|
|
|
+ vm.Set("e", errors.New("test"))
|
|
|
|
+ res, err := vm.RunString("e.toString()")
|
|
|
|
+ if err != nil {
|
|
|
|
+ t.Fatal(err)
|
|
|
|
+ }
|
|
|
|
+ if v := res.Export(); v != "test" {
|
|
|
|
+ t.Fatalf("v: %v", v)
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
func ExampleTagFieldNameMapper() {
|
|
func ExampleTagFieldNameMapper() {
|
|
vm := New()
|
|
vm := New()
|
|
vm.SetFieldNameMapper(TagFieldNameMapper("json", true))
|
|
vm.SetFieldNameMapper(TagFieldNameMapper("json", true))
|