function isConfigurable(obj, name) { try { delete obj[name]; } catch (e) { if (!(e instanceof TypeError)) { $ERROR("Expected TypeError, got " + e); } } return !Object.prototype.hasOwnProperty.call(obj, name); } function isEnumerable(obj, name) { for (var prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop) && assert._isSameValue(prop, name)) { return true; } } return false; } function isEqualTo(obj, name, expectedValue) { var actualValue = obj[name]; return assert._isSameValue(actualValue, expectedValue); } function isWritable(obj, name, verifyProp, value) { var newValue = value || "unlikelyValue"; try { obj[name] = newValue; } catch (e) { if (!(e instanceof TypeError)) { $ERROR("Expected TypeError, got " + e); } } if ((verifyProp && isEqualTo(obj, verifyProp, newValue)) || isEqualTo(obj, name, newValue)) { return true; } return false; } function verifyEqualTo(obj, name, value) { if (!isEqualTo(obj, name, value)) { $ERROR("Expected obj[" + String(name) + "] to equal " + value + ", actually " + obj[name]); } } function verifyWritable(obj, name, verifyProp, value) { if (!isWritable(obj, name, verifyProp, value)) { $ERROR("Expected obj[" + String(name) + "] to be writable, but was not."); } } function verifyNotWritable(obj, name, verifyProp, value) { if (isWritable(obj, name, verifyProp)) { $ERROR("Expected obj[" + String(name) + "] NOT to be writable, but was."); } } function verifyEnumerable(obj, name) { if (!isEnumerable(obj, name)) { $ERROR("Expected obj[" + String(name) + "] to be enumerable, but was not."); } } function verifyNotEnumerable(obj, name) { if (isEnumerable(obj, name)) { $ERROR("Expected obj[" + String(name) + "] NOT to be enumerable, but was."); } } function verifyConfigurable(obj, name) { if (!isConfigurable(obj, name)) { $ERROR("Expected obj[" + String(name) + "] to be configurable, but was not."); } } function verifyNotConfigurable(obj, name) { if (isConfigurable(obj, name)) { $ERROR("Expected obj[" + String(name) + "] NOT to be configurable, but was."); } }