mirror of
https://github.com/tc39/test262.git
synced 2025-07-26 23:44:27 +02:00
Merge pull request #171 from smikes/gh-170-add-attribute-validation
harness: add checks of descriptor attributes
This commit is contained in:
commit
09b9f713be
@ -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.");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user