зеркало из https://github.com/mozilla/pjs.git
Bug 560566 - Add this particular failure mode to the Object.defineProperty megatests. r=jorendorff
This commit is contained in:
Родитель
bcbd0b2b60
Коммит
fd5b9097a9
|
@ -0,0 +1,5 @@
|
|||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
load("ecma_5/Object/defineProperty-setup.js");
|
||||
runDictionaryPropertyPresentTestsFraction(1, 8);
|
|
@ -0,0 +1,5 @@
|
|||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
load("ecma_5/Object/defineProperty-setup.js");
|
||||
runDictionaryPropertyPresentTestsFraction(2, 8);
|
|
@ -0,0 +1,5 @@
|
|||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
load("ecma_5/Object/defineProperty-setup.js");
|
||||
runDictionaryPropertyPresentTestsFraction(3, 8);
|
|
@ -0,0 +1,5 @@
|
|||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
load("ecma_5/Object/defineProperty-setup.js");
|
||||
runDictionaryPropertyPresentTestsFraction(4, 8);
|
|
@ -0,0 +1,5 @@
|
|||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
load("ecma_5/Object/defineProperty-setup.js");
|
||||
runDictionaryPropertyPresentTestsFraction(5, 8);
|
|
@ -0,0 +1,5 @@
|
|||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
load("ecma_5/Object/defineProperty-setup.js");
|
||||
runDictionaryPropertyPresentTestsFraction(6, 8);
|
|
@ -0,0 +1,5 @@
|
|||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
load("ecma_5/Object/defineProperty-setup.js");
|
||||
runDictionaryPropertyPresentTestsFraction(7, 8);
|
|
@ -0,0 +1,5 @@
|
|||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
load("ecma_5/Object/defineProperty-setup.js");
|
||||
runDictionaryPropertyPresentTestsFraction(8, 8);
|
|
@ -0,0 +1,5 @@
|
|||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
load("ecma_5/Object/defineProperty-setup.js");
|
||||
runNonTerminalPropertyPresentTestsFraction(1, 8);
|
|
@ -0,0 +1,5 @@
|
|||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
load("ecma_5/Object/defineProperty-setup.js");
|
||||
runNonTerminalPropertyPresentTestsFraction(2, 8);
|
|
@ -0,0 +1,5 @@
|
|||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
load("ecma_5/Object/defineProperty-setup.js");
|
||||
runNonTerminalPropertyPresentTestsFraction(3, 8);
|
|
@ -0,0 +1,5 @@
|
|||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
load("ecma_5/Object/defineProperty-setup.js");
|
||||
runNonTerminalPropertyPresentTestsFraction(4, 8);
|
|
@ -0,0 +1,5 @@
|
|||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
load("ecma_5/Object/defineProperty-setup.js");
|
||||
runNonTerminalPropertyPresentTestsFraction(5, 8);
|
|
@ -0,0 +1,5 @@
|
|||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
load("ecma_5/Object/defineProperty-setup.js");
|
||||
runNonTerminalPropertyPresentTestsFraction(6, 8);
|
|
@ -0,0 +1,5 @@
|
|||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
load("ecma_5/Object/defineProperty-setup.js");
|
||||
runNonTerminalPropertyPresentTestsFraction(7, 8);
|
|
@ -0,0 +1,5 @@
|
|||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
load("ecma_5/Object/defineProperty-setup.js");
|
||||
runNonTerminalPropertyPresentTestsFraction(8, 8);
|
|
@ -578,7 +578,7 @@ TestRunner.prototype =
|
|||
print("Starting test with old descriptor " + old.toSource() + "...");
|
||||
|
||||
for (var j = 0, sz2 = VALID_DESCRIPTORS.length; j < sz2; j++)
|
||||
self._runSinglePropertyPresentTest(old, VALID_DESCRIPTORS[j]);
|
||||
self._runSinglePropertyPresentTest(old, VALID_DESCRIPTORS[j], []);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -587,6 +587,107 @@ TestRunner.prototype =
|
|||
" completed!");
|
||||
},
|
||||
|
||||
runNonTerminalPropertyPresentTestsFraction:
|
||||
function runNonTerminalPropertyPresentTestsFraction(part, parts)
|
||||
{
|
||||
var self = this;
|
||||
|
||||
/*
|
||||
* A plain old property to define on the object before redefining the
|
||||
* originally-added property, to test redefinition of a property that's
|
||||
* not also lastProperty. NB: we could loop over every possible
|
||||
* descriptor here if we wanted, even try adding more than one, but we'd
|
||||
* hit cubic complexity and worse, and SpiderMonkey only distinguishes by
|
||||
* the mere presence of the middle property, not its precise details.
|
||||
*/
|
||||
var middleDefines =
|
||||
[{
|
||||
property: "middle",
|
||||
descriptor:
|
||||
{ value: 17, writable: true, configurable: true, enumerable: true }
|
||||
}];
|
||||
|
||||
function nonTerminalPropertyPresentTests()
|
||||
{
|
||||
print("Running non-terminal already-present tests now...");
|
||||
|
||||
var total = VALID_DESCRIPTORS.length;
|
||||
var start = Math.floor((part - 1) / parts * total);
|
||||
var end = Math.floor(part / parts * total);
|
||||
|
||||
for (var i = start; i < end; i++)
|
||||
{
|
||||
var old = VALID_DESCRIPTORS[i];
|
||||
print("Starting test with old descriptor " + old.toSource() + "...");
|
||||
|
||||
for (var j = 0, sz2 = VALID_DESCRIPTORS.length; j < sz2; j++)
|
||||
{
|
||||
self._runSinglePropertyPresentTest(old, VALID_DESCRIPTORS[j],
|
||||
middleDefines);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._runTestSet(nonTerminalPropertyPresentTests,
|
||||
"Non-terminal property-present fraction " +
|
||||
part + " of " + parts + " completed!");
|
||||
},
|
||||
|
||||
runDictionaryPropertyPresentTestsFraction:
|
||||
function runDictionaryPropertyPresentTestsFraction(part, parts)
|
||||
{
|
||||
var self = this;
|
||||
|
||||
/*
|
||||
* Add and readd properties such that the scope for the object is in
|
||||
* dictionary mode.
|
||||
*/
|
||||
var middleDefines =
|
||||
[
|
||||
{
|
||||
property: "mid1",
|
||||
descriptor:
|
||||
{ value: 17, writable: true, configurable: true, enumerable: true }
|
||||
},
|
||||
{
|
||||
property: "mid2",
|
||||
descriptor:
|
||||
{ value: 17, writable: true, configurable: true, enumerable: true }
|
||||
},
|
||||
{
|
||||
property: "mid1",
|
||||
descriptor:
|
||||
{ get: function g() { }, set: function s(v){}, configurable: false,
|
||||
enumerable: true }
|
||||
},
|
||||
];
|
||||
|
||||
function dictionaryPropertyPresentTests()
|
||||
{
|
||||
print("Running dictionary already-present tests now...");
|
||||
|
||||
var total = VALID_DESCRIPTORS.length;
|
||||
var start = Math.floor((part - 1) / parts * total);
|
||||
var end = Math.floor(part / parts * total);
|
||||
|
||||
for (var i = start; i < end; i++)
|
||||
{
|
||||
var old = VALID_DESCRIPTORS[i];
|
||||
print("Starting test with old descriptor " + old.toSource() + "...");
|
||||
|
||||
for (var j = 0, sz2 = VALID_DESCRIPTORS.length; j < sz2; j++)
|
||||
{
|
||||
self._runSinglePropertyPresentTest(old, VALID_DESCRIPTORS[j],
|
||||
middleDefines);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._runTestSet(dictionaryPropertyPresentTests,
|
||||
"Dictionary property-present fraction " +
|
||||
part + " of " + parts + " completed!");
|
||||
},
|
||||
|
||||
|
||||
// HELPERS
|
||||
|
||||
|
@ -600,7 +701,7 @@ TestRunner.prototype =
|
|||
print("Starting test with old descriptor " + old.toSource() + "...");
|
||||
|
||||
for (var j = 0, sz2 = VALID_DESCRIPTORS.length; j < sz2; j++)
|
||||
this._runSinglePropertyPresentTest(old, VALID_DESCRIPTORS[j]);
|
||||
this._runSinglePropertyPresentTest(old, VALID_DESCRIPTORS[j], []);
|
||||
}
|
||||
},
|
||||
_runTestSet: function _runTestSet(fun, completeMessage)
|
||||
|
@ -724,7 +825,8 @@ TestRunner.prototype =
|
|||
return;
|
||||
}
|
||||
},
|
||||
_runSinglePropertyPresentTest: function _runSinglePropertyPresentTest(old, add)
|
||||
_runSinglePropertyPresentTest:
|
||||
function _runSinglePropertyPresentTest(old, add, middleDefines)
|
||||
{
|
||||
var nativeObj = NativeTest.newObject();
|
||||
var reimplObj = ReimplTest.newObject();
|
||||
|
@ -781,6 +883,35 @@ TestRunner.prototype =
|
|||
return;
|
||||
}
|
||||
|
||||
// Now add (or even readd) however many properties were specified between
|
||||
// the original property to add and the new one, to test redefining
|
||||
// non-last-properties and properties in scopes in dictionary mode.
|
||||
for (var i = 0, sz = middleDefines.length; i < sz; i++)
|
||||
{
|
||||
var middle = middleDefines[i];
|
||||
var prop = middle.property;
|
||||
var desc = middle.descriptor;
|
||||
|
||||
try
|
||||
{
|
||||
NativeTest.defineProperty(nativeObj, prop, desc);
|
||||
ReimplTest.defineProperty(reimplObj, prop, desc);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
this._log("failure defining middle descriptor: " + desc.toSource() +
|
||||
", error " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
// Sanity check
|
||||
var nativeDesc = NativeTest.getDescriptor(nativeObj, prop);
|
||||
var reimplDesc = ReimplTest.getDescriptor(reimplObj, prop);
|
||||
|
||||
compareDescriptors(nativeDesc, reimplDesc);
|
||||
compareDescriptors(nativeDesc, desc);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NativeTest.defineProperty(nativeObj, "foo", add);
|
||||
|
@ -900,3 +1031,72 @@ TestRunner.prototype =
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
function runDictionaryPropertyPresentTestsFraction(PART, PARTS)
|
||||
{
|
||||
var testfile =
|
||||
'15.2.3.6-dictionary-redefinition-' + PART + '-of-' + PARTS + '.js';
|
||||
var BUGNUMBER = 560566;
|
||||
var summary =
|
||||
'ES5 Object.defineProperty(O, P, Attributes): dictionary redefinition ' +
|
||||
PART + ' of ' + PARTS;
|
||||
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
try
|
||||
{
|
||||
new TestRunner().runDictionaryPropertyPresentTestsFraction(PART, PARTS);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
throw "Error thrown during testing: " + e +
|
||||
" at line " + e.lineNumber + "\n" +
|
||||
(e.stack
|
||||
? "Stack: " + e.stack.split("\n").slice(2).join("\n") + "\n"
|
||||
: "");
|
||||
}
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
|
||||
print("Tests complete!");
|
||||
}
|
||||
|
||||
function runNonTerminalPropertyPresentTestsFraction(PART, PARTS)
|
||||
{
|
||||
var PART = 1, PARTS = 4;
|
||||
|
||||
var gTestfile =
|
||||
'15.2.3.6-middle-redefinition-' + PART + '-of-' + PARTS + '.js';
|
||||
var BUGNUMBER = 560566;
|
||||
var summary =
|
||||
'ES5 Object.defineProperty(O, P, Attributes): middle redefinition ' +
|
||||
PART + ' of ' + PARTS;
|
||||
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
|
||||
/**************
|
||||
* BEGIN TEST *
|
||||
**************/
|
||||
|
||||
try
|
||||
{
|
||||
new TestRunner().runNonTerminalPropertyPresentTestsFraction(PART, PARTS);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
throw "Error thrown during testing: " + e +
|
||||
" at line " + e.lineNumber + "\n" +
|
||||
(e.stack
|
||||
? "Stack: " + e.stack.split("\n").slice(2).join("\n") + "\n"
|
||||
: "");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
|
||||
print("Tests complete!");
|
||||
}
|
||||
|
|
|
@ -11,3 +11,19 @@ skip-if(!xulRuntime.shell) script 15.2.3.6-redefinition-3-of-4.js # uses shell l
|
|||
skip-if(!xulRuntime.shell) script 15.2.3.6-redefinition-4-of-4.js # uses shell load() function
|
||||
script 15.2.3.7-01.js
|
||||
script 15.2.3.14-01.js # does not use reportCompare
|
||||
skip-if(!xulRuntime.shell) script 15.2.3.6-middle-redefinition-1-of-8.js # uses shell load() function
|
||||
skip-if(!xulRuntime.shell) script 15.2.3.6-middle-redefinition-2-of-8.js # uses shell load() function
|
||||
skip-if(!xulRuntime.shell) script 15.2.3.6-middle-redefinition-3-of-8.js # uses shell load() function
|
||||
skip-if(!xulRuntime.shell) script 15.2.3.6-middle-redefinition-4-of-8.js # uses shell load() function
|
||||
skip-if(!xulRuntime.shell) script 15.2.3.6-middle-redefinition-5-of-8.js # uses shell load() function
|
||||
skip-if(!xulRuntime.shell) script 15.2.3.6-middle-redefinition-6-of-8.js # uses shell load() function
|
||||
skip-if(!xulRuntime.shell) script 15.2.3.6-middle-redefinition-7-of-8.js # uses shell load() function
|
||||
skip-if(!xulRuntime.shell) script 15.2.3.6-middle-redefinition-8-of-8.js # uses shell load() function
|
||||
skip-if(!xulRuntime.shell) script 15.2.3.6-dictionary-redefinition-1-of-8.js # uses shell load() function
|
||||
skip-if(!xulRuntime.shell) script 15.2.3.6-dictionary-redefinition-2-of-8.js # uses shell load() function
|
||||
skip-if(!xulRuntime.shell) script 15.2.3.6-dictionary-redefinition-3-of-8.js # uses shell load() function
|
||||
skip-if(!xulRuntime.shell) script 15.2.3.6-dictionary-redefinition-4-of-8.js # uses shell load() function
|
||||
skip-if(!xulRuntime.shell) script 15.2.3.6-dictionary-redefinition-5-of-8.js # uses shell load() function
|
||||
skip-if(!xulRuntime.shell) script 15.2.3.6-dictionary-redefinition-6-of-8.js # uses shell load() function
|
||||
skip-if(!xulRuntime.shell) script 15.2.3.6-dictionary-redefinition-7-of-8.js # uses shell load() function
|
||||
skip-if(!xulRuntime.shell) script 15.2.3.6-dictionary-redefinition-8-of-8.js # uses shell load() function
|
||||
|
|
Загрузка…
Ссылка в новой задаче