Skip to content
Snippets Groups Projects
Commit 09b9f713 authored by Brian Terlson's avatar Brian Terlson
Browse files

Merge pull request #171 from smikes/gh-170-add-attribute-validation

harness: add checks of descriptor attributes
parents a01e1eab 9f884af5
No related branches found
No related tags found
No related merge requests found
...@@ -54,36 +54,52 @@ function verifyEqualTo(obj, name, value) { ...@@ -54,36 +54,52 @@ function verifyEqualTo(obj, name, value) {
} }
function verifyWritable(obj, name, verifyProp, value) { function verifyWritable(obj, name, verifyProp, value) {
if (!verifyProp) {
assert(Object.getOwnPropertyDescriptor(obj, name).writable,
"Expected obj[" + String(name) + "] to have writable:true.");
}
if (!isWritable(obj, name, verifyProp, value)) { if (!isWritable(obj, name, verifyProp, value)) {
$ERROR("Expected obj[" + String(name) + "] to be writable, but was not."); $ERROR("Expected obj[" + String(name) + "] to be writable, but was not.");
} }
} }
function verifyNotWritable(obj, name, verifyProp, value) { function verifyNotWritable(obj, name, verifyProp, value) {
if (!verifyProp) {
assert(!Object.getOwnPropertyDescriptor(obj, name).writable,
"Expected obj[" + String(name) + "] to have writable:false.");
}
if (isWritable(obj, name, verifyProp)) { if (isWritable(obj, name, verifyProp)) {
$ERROR("Expected obj[" + String(name) + "] NOT to be writable, but was."); $ERROR("Expected obj[" + String(name) + "] NOT to be writable, but was.");
} }
} }
function verifyEnumerable(obj, name) { function verifyEnumerable(obj, name) {
assert(Object.getOwnPropertyDescriptor(obj, name).enumerable,
"Expected obj[" + String(name) + "] to have enumerable:true.");
if (!isEnumerable(obj, name)) { if (!isEnumerable(obj, name)) {
$ERROR("Expected obj[" + String(name) + "] to be enumerable, but was not."); $ERROR("Expected obj[" + String(name) + "] to be enumerable, but was not.");
} }
} }
function verifyNotEnumerable(obj, name) { function verifyNotEnumerable(obj, name) {
assert(!Object.getOwnPropertyDescriptor(obj, name).enumerable,
"Expected obj[" + String(name) + "] to have enumerable:false.");
if (isEnumerable(obj, name)) { if (isEnumerable(obj, name)) {
$ERROR("Expected obj[" + String(name) + "] NOT to be enumerable, but was."); $ERROR("Expected obj[" + String(name) + "] NOT to be enumerable, but was.");
} }
} }
function verifyConfigurable(obj, name) { function verifyConfigurable(obj, name) {
assert(Object.getOwnPropertyDescriptor(obj, name).configurable,
"Expected obj[" + String(name) + "] to have configurable:true.");
if (!isConfigurable(obj, name)) { if (!isConfigurable(obj, name)) {
$ERROR("Expected obj[" + String(name) + "] to be configurable, but was not."); $ERROR("Expected obj[" + String(name) + "] to be configurable, but was not.");
} }
} }
function verifyNotConfigurable(obj, name) { function verifyNotConfigurable(obj, name) {
assert(!Object.getOwnPropertyDescriptor(obj, name).configurable,
"Expected obj[" + String(name) + "] to have configurable:false.");
if (isConfigurable(obj, name)) { if (isConfigurable(obj, name)) {
$ERROR("Expected obj[" + String(name) + "] NOT to be configurable, but was."); $ERROR("Expected obj[" + String(name) + "] NOT to be configurable, but was.");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment