(t *testing.T)
| 137 | } |
| 138 | |
| 139 | func TestDynamicObjectCustomProto(t *testing.T) { |
| 140 | vm := New() |
| 141 | m := make(map[string]Value) |
| 142 | dynObj := &testDynObject{ |
| 143 | r: vm, |
| 144 | m: m, |
| 145 | } |
| 146 | o := vm.NewDynamicObject(dynObj) |
| 147 | vm.Set("o", o) |
| 148 | vm.testScriptWithTestLib(` |
| 149 | var proto = { |
| 150 | valueOf: function() { |
| 151 | return this.num; |
| 152 | } |
| 153 | }; |
| 154 | proto[Symbol.toStringTag] = "GoObject"; |
| 155 | Object.setPrototypeOf(o, proto); |
| 156 | o.num = 41; |
| 157 | assert(o instanceof Object, "instanceof"); |
| 158 | assert.sameValue(o+1, 42); |
| 159 | assert.sameValue(o.toString(), "[object GoObject]"); |
| 160 | `, _undefined, t) |
| 161 | |
| 162 | if v := m["num"]; v.Export() != int64(41) { |
| 163 | t.Fatal(v) |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | func TestDynamicArray(t *testing.T) { |
| 168 | vm := New() |
nothing calls this directly
no test coverage detected
searching dependent graphs…