Skip to content

Commit

Permalink
Use getter to vet error handling in C.ObjectGet
Browse files Browse the repository at this point in the history
- Add back test for methodcall on not-a-function
  • Loading branch information
Genevieve L'Esperance committed Sep 2, 2021
1 parent e7e17fb commit e8c4d2b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ func TestObjectMethodCall(t *testing.T) {
if val.String() != "some val" {
t.Errorf("unexpected value: %q", val)
}
_, err = obj.MethodCall("prop")
if err == nil {
t.Errorf("expected an error, got none")
}

val, err = ctx.RunScript(`class Obj2 { print(str) { return str.toString() } }; new Obj2()`, "")
val, err = ctx.RunScript(`class Obj2 { print(str) { return str.toString() }; get fails() { throw "error" } }; new Obj2()`, "")
failIf(t, err)
obj, _ = val.AsObject()
arg, _ := v8go.NewValue(ctx.Isolate(), "arg")
_, err = obj.MethodCall("print", arg)
failIf(t, err)
_, err = obj.MethodCall("notamethod")
_, err = obj.MethodCall("fails")
if err == nil {
t.Errorf("expected an error, got none")
}
Expand Down

0 comments on commit e8c4d2b

Please sign in to comment.