(t *testing.T)
| 99 | } |
| 100 | |
| 101 | func TestDynamicObject(t *testing.T) { |
| 102 | vm := New() |
| 103 | dynObj := &testDynObject{ |
| 104 | r: vm, |
| 105 | m: make(map[string]Value), |
| 106 | } |
| 107 | o := vm.NewDynamicObject(dynObj) |
| 108 | vm.Set("o", o) |
| 109 | vm.testScriptWithTestLibX(` |
| 110 | assert(o instanceof Object, "instanceof Object"); |
| 111 | assert(o === o, "self equality"); |
| 112 | assert(o !== {}, "non-equality"); |
| 113 | |
| 114 | o.test = 42; |
| 115 | assert("test" in o, "'test' in o"); |
| 116 | assert(deepEqual(Object.getOwnPropertyDescriptor(o, "test"), {value: 42, writable: true, enumerable: true, configurable: true}), "prop desc"); |
| 117 | |
| 118 | assert.throws(TypeError, function() { |
| 119 | "use strict"; |
| 120 | Object.defineProperty(o, "test1", {value: 0, writable: false, enumerable: false, configurable: true}); |
| 121 | }, "define prop"); |
| 122 | |
| 123 | var keys = []; |
| 124 | for (var key in o) { |
| 125 | keys.push(key); |
| 126 | } |
| 127 | assert(compareArray(keys, ["test"]), "for-in"); |
| 128 | |
| 129 | assert(delete o.test, "delete"); |
| 130 | assert(!("test" in o), "'test' in o after delete"); |
| 131 | |
| 132 | assert("__proto__" in o, "__proto__ in o"); |
| 133 | assert.sameValue(o.__proto__, Object.prototype, "__proto__"); |
| 134 | o.__proto__ = null; |
| 135 | assert(!("__proto__" in o), "__proto__ in o after setting to null"); |
| 136 | `, _undefined, t) |
| 137 | } |
| 138 | |
| 139 | func TestDynamicObjectCustomProto(t *testing.T) { |
| 140 | vm := New() |
nothing calls this directly
no test coverage detected
searching dependent graphs…