test262/harness/propertyHelper.js

271 lines
7.6 KiB
JavaScript
Raw Normal View History

// Copyright (C) 2017 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: |
Collection of functions used to safely verify the correctness of
property descriptors.
defines:
- verifyProperty
- verifyEqualTo # deprecated
- verifyWritable # deprecated
- verifyNotWritable # deprecated
- verifyEnumerable # deprecated
- verifyNotEnumerable # deprecated
- verifyConfigurable # deprecated
- verifyNotConfigurable # deprecated
---*/
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
// @ts-check
/**
* @param {object} obj
* @param {string|symbol} name
* @param {PropertyDescriptor|undefined} desc
* @param {object} [options]
* @param {boolean} [options.restore]
*/
2017-04-15 18:56:29 +02:00
function verifyProperty(obj, name, desc, options) {
assert(
arguments.length > 2,
'verifyProperty should receive at least 3 arguments: obj, name, and descriptor'
);
var originalDesc = Object.getOwnPropertyDescriptor(obj, name);
var nameStr = String(name);
// Allows checking for undefined descriptor if it's explicitly given.
if (desc === undefined) {
assert.sameValue(
originalDesc,
undefined,
"obj['" + nameStr + "'] descriptor should be undefined"
2017-04-15 18:56:29 +02:00
);
// desc and originalDesc are both undefined, problem solved;
return true;
}
assert(
Object.prototype.hasOwnProperty.call(obj, name),
"obj should have an own property " + nameStr
2017-04-15 18:56:29 +02:00
);
assert.notSameValue(
desc,
null,
"The desc argument should be an object or undefined, null"
2017-04-15 18:56:29 +02:00
);
assert.sameValue(
typeof desc,
"object",
"The desc argument should be an object or undefined, " + String(desc)
2017-04-15 18:56:29 +02:00
);
2023-09-22 09:11:45 +02:00
var names = Object.getOwnPropertyNames(desc);
for (var i = 0; i < names.length; i++) {
assert(
names[i] === "value" ||
names[i] === "writable" ||
names[i] === "enumerable" ||
names[i] === "configurable" ||
names[i] === "get" ||
names[i] === "set",
"Invalid descriptor field: " + names[i],
);
}
2017-04-15 18:56:29 +02:00
var failures = [];
if (Object.prototype.hasOwnProperty.call(desc, 'value')) {
if (!isSameValue(desc.value, originalDesc.value)) {
failures.push("descriptor value should be " + desc.value);
}
if (!isSameValue(desc.value, obj[name])) {
2023-09-22 09:11:45 +02:00
failures.push("object value should be " + desc.value);
}
}
2017-04-15 18:56:29 +02:00
if (Object.prototype.hasOwnProperty.call(desc, 'enumerable')) {
if (desc.enumerable !== originalDesc.enumerable ||
desc.enumerable !== isEnumerable(obj, name)) {
failures.push('descriptor should ' + (desc.enumerable ? '' : 'not ') + 'be enumerable');
2017-04-15 18:56:29 +02:00
}
}
if (Object.prototype.hasOwnProperty.call(desc, 'writable')) {
if (desc.writable !== originalDesc.writable ||
desc.writable !== isWritable(obj, name)) {
failures.push('descriptor should ' + (desc.writable ? '' : 'not ') + 'be writable');
2017-04-15 18:56:29 +02:00
}
}
if (Object.prototype.hasOwnProperty.call(desc, 'configurable')) {
if (desc.configurable !== originalDesc.configurable ||
desc.configurable !== isConfigurable(obj, name)) {
failures.push('descriptor should ' + (desc.configurable ? '' : 'not ') + 'be configurable');
2017-04-15 18:56:29 +02:00
}
}
assert(!failures.length, failures.join('; '));
2017-04-15 18:56:29 +02:00
if (options && options.restore) {
Object.defineProperty(obj, name, originalDesc);
}
return true;
}
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
function isConfigurable(obj, name) {
var hasOwnProperty = Object.prototype.hasOwnProperty;
try {
delete obj[name];
} catch (e) {
if (!(e instanceof TypeError)) {
throw new Test262Error("Expected TypeError, got " + e);
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
}
}
return !hasOwnProperty.call(obj, name);
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
}
function isEnumerable(obj, name) {
2017-04-15 18:56:29 +02:00
var stringCheck = false;
if (typeof name === "string") {
for (var x in obj) {
if (x === name) {
stringCheck = true;
break;
}
}
} else {
// skip it if name is not string, works for Symbol names.
stringCheck = true;
}
return stringCheck &&
Object.prototype.hasOwnProperty.call(obj, name) &&
Object.prototype.propertyIsEnumerable.call(obj, name);
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
}
function isSameValue(a, b) {
if (a === 0 && b === 0) return 1 / a === 1 / b;
if (a !== a && b !== b) return true;
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
return a === b;
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
}
2020-03-25 13:45:14 +01:00
var __isArray = Array.isArray;
function isWritable(obj, name, verifyProp, value) {
2020-03-25 13:45:14 +01:00
var unlikelyValue = __isArray(obj) && name === "length" ?
2020-03-23 19:44:01 +01:00
Math.pow(2, 32) - 1 :
"unlikelyValue";
var newValue = value || unlikelyValue;
var hadValue = Object.prototype.hasOwnProperty.call(obj, name);
var oldValue = obj[name];
var writeSucceeded;
try {
obj[name] = newValue;
} catch (e) {
if (!(e instanceof TypeError)) {
throw new Test262Error("Expected TypeError, got " + e);
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
}
}
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
writeSucceeded = isSameValue(obj[verifyProp || name], newValue);
// Revert the change only if it was successful (in other cases, reverting
// is unnecessary and may trigger exceptions for certain property
// configurations)
if (writeSucceeded) {
if (hadValue) {
obj[name] = oldValue;
} else {
delete obj[name];
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
}
}
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
return writeSucceeded;
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
}
/**
* Deprecated; please use `verifyProperty` in new tests.
*/
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
function verifyEqualTo(obj, name, value) {
if (!isSameValue(obj[name], value)) {
throw new Test262Error("Expected obj[" + String(name) + "] to equal " + value +
", actually " + obj[name]);
}
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
}
/**
* Deprecated; please use `verifyProperty` in new tests.
*/
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
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)) {
throw new Test262Error("Expected obj[" + String(name) + "] to be writable, but was not.");
}
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
}
/**
* Deprecated; please use `verifyProperty` in new tests.
*/
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
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)) {
throw new Test262Error("Expected obj[" + String(name) + "] NOT to be writable, but was.");
}
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
}
/**
* Deprecated; please use `verifyProperty` in new tests.
*/
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
function verifyEnumerable(obj, name) {
assert(Object.getOwnPropertyDescriptor(obj, name).enumerable,
"Expected obj[" + String(name) + "] to have enumerable:true.");
if (!isEnumerable(obj, name)) {
throw new Test262Error("Expected obj[" + String(name) + "] to be enumerable, but was not.");
}
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
}
/**
* Deprecated; please use `verifyProperty` in new tests.
*/
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
function verifyNotEnumerable(obj, name) {
assert(!Object.getOwnPropertyDescriptor(obj, name).enumerable,
"Expected obj[" + String(name) + "] to have enumerable:false.");
if (isEnumerable(obj, name)) {
throw new Test262Error("Expected obj[" + String(name) + "] NOT to be enumerable, but was.");
}
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
}
/**
* Deprecated; please use `verifyProperty` in new tests.
*/
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
function verifyConfigurable(obj, name) {
assert(Object.getOwnPropertyDescriptor(obj, name).configurable,
"Expected obj[" + String(name) + "] to have configurable:true.");
if (!isConfigurable(obj, name)) {
throw new Test262Error("Expected obj[" + String(name) + "] to be configurable, but was not.");
}
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
}
/**
* Deprecated; please use `verifyProperty` in new tests.
*/
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
function verifyNotConfigurable(obj, name) {
assert(!Object.getOwnPropertyDescriptor(obj, name).configurable,
"Expected obj[" + String(name) + "] to have configurable:false.");
if (isConfigurable(obj, name)) {
throw new Test262Error("Expected obj[" + String(name) + "] NOT to be configurable, but was.");
}
rework: remove *PropertyAttributes fns - this change hits all files that use dataPropertyAttributesAreCorrect or acccessorPropertyAttributesAreCorrect Major changes: - remove include of runTestCase.js, dataPropertyAttributesAreCorrect.js and acccessorPropertyAttributesAreCorrect.js - add include of propertyHelper.js - remove function testCase() and call to function runTestCase() - instead of collecting test state into booleans, which are eventually returned from runTestCase, test conditions and throw errors immediately - use negative: to check error types instead of using `instanceof` in a catch() block Selected commit logs follow: manual conversion of accessorPropertyAttributesAreCorrect() test - remove runTestCase - remove wrapping testCase function - unindent - remove includes of runTestCase & accessor... - add include of propertyHelper.js - unpack final two args 'true, false' to explicit inline tests of isEnumerable and isConfigurable - unpack setter test into inline logic - unpack getter test into inline logic used script to replace includes: frontmatter with propertyHelper.js ; manually added back references to fnGlobalObject() where needed additional helper functions add helper functions for get and writable duplicate runTestCase so can remove runTestCase.js from includes of all tests in batch use keyboard macros to simplify repetitive conversions remove auto-save file accidentaly committed minor changes, manually remove runTestCase from remaining files lint etc. fixes remove now-obsolete harness files make strict/nonstrict variants tests where behavior is different in strict/nonstrict need two variants - strict mode throws on assign to read-only element (no setter fn) - strict mode separates named arguments from arguments[] fix indentation cleanup minor issues reviewing 15.2.3.7-9 tests, found some minor issues - indentation/spacing - duplicate test (eg, direct test of value and dataProp...) - remove needless try/finally - use assert.. helpers in place of if(is.. - rename some assertions to 'e' rename assertX to verifyX new helper fn sameValue test "set" as well as get reverse order of checks restore test of desc2 restore test of length restore test of ownProperty incorporate suggestions re order of ops, Object.prototype add test of sameValue helper restore return value in getter restore second defineProperty call restore check of explicit "false" restore explicit test of TypeError set noStrict flag on arguments changes rename catch var to "e" b4ad0e6 remove dataPropertyAttributesAreCorrect from tests 0d83ff2 remove accessorPropertyAttributesAreCorrect from tests bb926f3 remove {data,accessor}Property... fns from harness fix writable check on array.length call $ERROR if expected exception not thrown fix Epected => Expected typo use assert._isSamevalue
2014-11-12 14:41:09 +01:00
}