()
| 134 | } |
| 135 | |
| 136 | func ExampleAssertConstructor() { |
| 137 | vm := New() |
| 138 | res, err := vm.RunString(` |
| 139 | (class C { |
| 140 | constructor(x) { |
| 141 | this.x = x; |
| 142 | } |
| 143 | }) |
| 144 | `) |
| 145 | if err != nil { |
| 146 | panic(err) |
| 147 | } |
| 148 | if ctor, ok := AssertConstructor(res); ok { |
| 149 | obj, err := ctor(nil, vm.ToValue("Test")) |
| 150 | if err != nil { |
| 151 | panic(err) |
| 152 | } |
| 153 | fmt.Print(obj.Get("x")) |
| 154 | } else { |
| 155 | panic("Not a constructor") |
| 156 | } |
| 157 | // Output: Test |
| 158 | } |
| 159 | |
| 160 | type testAsyncCtx struct { |
| 161 | group string |
nothing calls this directly
no test coverage detected
searching dependent graphs…