Tests for spec violation generically by enumerating properties.

This commit is contained in:
Mark Miller 2011-09-25 10:40:20 -07:00
parent ede572eced
commit eea2f45421
1 changed files with 17 additions and 7 deletions

View File

@ -11,12 +11,22 @@
* @onlyStrict
*/
"use strict";
var deleted = 'unassigned';
try {
deleted = delete RegExp.leftContext;
} catch (err) {
}
if (deleted === false) {
$ERROR('Strict delete returned false');
var reNames = Object.getOwnPropertyNames(RegExp);
for (var i = 0, len = reNames.length; i < len; i++) {
var reName = reNames[i];
if (reName !== 'prototype') {
var deleted = 'unassigned';
try {
deleted = delete RegExp[reName];
} catch (err) {
if (!(err instanceof TypeError)) {
$ERROR('#1: strict delete threw a non-TypeError: ' + err);
}
// fall through
}
if (deleted === false) {
$ERROR('#2: Strict delete returned false');
}
}
}