Skip to content
Snippets Groups Projects
Unverified Commit 06f2f3e8 authored by Leo Balter's avatar Leo Balter
Browse files

Remove more unnecessary tests

These tests are not helpful for their respective APIs being tested.

They don't add any coverage for the built-in apis and basically check
behaviors that might conflict with a implementation defined global.
parent 5c8f4db9
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 536 deletions
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
When the Object constructor is called with one argument value and
the value is a native ECMAScript object, do not create a new object but simply return value
es5id: 15.2.2.1_A2_T4
description: The value is "this"
---*/
var x=1;
var obj = this;
var n_obj = new Object(obj);
//CHECK#1
if (n_obj !== obj) {
$ERROR('#1: When the Object constructor is called and if the value is an Object simply value returns.');
}
//CHECK#2
if (n_obj['x'] !== 1) {
$ERROR('#2: When the Object constructor is called and if the value is an Object simply value returns.');
}
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 15.2.3.6-4-354-13
description: >
Object.defineProperty will update [[Value]] attribute of indexed
property successfully when [[Configurable]] attribute is true and
[[Writable]] attribute is false, 'O' is the global object (8.12.9
- step Note)
includes: [propertyHelper.js]
---*/
var obj = this;
try {
Object.defineProperty(obj, "0", {
value: 1001,
writable: false,
configurable: true
});
Object.defineProperty(obj, "0", {
value: 1002
});
verifyEqualTo(obj, "0", 1002);
verifyNotWritable(obj, "0");
verifyNotEnumerable(obj, "0");
verifyConfigurable(obj, "0");
} finally {
delete obj[0];
}
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 15.2.3.6-4-354-4
description: >
Object.defineProperty will update [[Value]] attribute successfully
when [[Configurable]] attribute is true and [[Writable]] attribute
is false, 'O' is the global object (8.12.9 - step Note)
includes: [propertyHelper.js]
---*/
var obj = this;
try {
Object.defineProperty(obj, "property", {
value: 1001,
writable: false,
configurable: true
});
Object.defineProperty(obj, "property", {
value: 1002
});
verifyEqualTo(obj, "property", 1002);
verifyNotWritable(obj, "property");
verifyNotEnumerable(obj, "property");
verifyConfigurable(obj, "property");
} finally {
delete obj.property;
}
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 15.2.3.6-4-354-8
description: >
ES5 Attributes - property 'P' with attributes [[Writable]]: false,
[[Enumerable]]: true, [[Configurable]]: true is non-writable using
simple assignment, 'O' is the global object
includes: [propertyHelper.js]
---*/
var obj = this;
Object.defineProperty(obj, "prop", {
value: 2010,
writable: false,
enumerable: true,
configurable: true
});
assert.sameValue(obj.prop, 2010);
verifyNotWritable(obj, "prop");
assert.sameValue(obj.prop, 2010);
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 15.2.3.6-4-360-3
description: >
ES5 Attributes - Updating data property 'P' whose attributes are
[[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: true
to an accessor property, 'O' is the global object (8.12.9 - step
9.b.i)
includes: [propertyHelper.js]
---*/
var obj = this;
Object.defineProperty(obj, "prop", {
value: 2010,
writable: false,
enumerable: true,
configurable: true
});
var desc1 = Object.getOwnPropertyDescriptor(obj, "prop");
function getFunc() {
return 20;
}
Object.defineProperty(obj, "prop", {
get: getFunc
});
var desc2 = Object.getOwnPropertyDescriptor(obj, "prop");
assert(desc1.hasOwnProperty("value"));
assert(desc2.hasOwnProperty("get"));
assert.sameValue(desc2.enumerable, true);
assert.sameValue(desc2.configurable, true);
assert.sameValue(obj.prop, 20);
assert.sameValue(typeof desc2.set, "undefined");
assert.sameValue(desc2.get, getFunc);
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 15.2.3.6-4-360-7
description: >
ES5 Attributes - Updating indexed data property 'P' whose
attributes are [[Writable]]: false, [[Enumerable]]: true,
[[Configurable]]: true to an accessor property, 'O' is the global
object (8.12.9 - step 9.b.i)
includes: [propertyHelper.js]
---*/
function getFunc() {
return 20;
}
var obj = this;
try {
Object.defineProperty(obj, "0", {
value: 2010,
writable: false,
enumerable: true,
configurable: true
});
var desc1 = Object.getOwnPropertyDescriptor(obj, "0");
Object.defineProperty(obj, "0", {
get: getFunc
});
var desc2 = Object.getOwnPropertyDescriptor(obj, "0");
if (!Object.prototype.hasOwnProperty.call(desc1, "value")) {
$ERROR("Expected to find ownProperty 'value'");
}
if (!(desc2.hasOwnProperty("get") && desc2.enumerable === true &&
desc2.configurable === true && obj[0] === 20 &&
(typeof desc2.set === "undefined") && desc2.get === getFunc)) {
$ERROR("Expected desc2 to be as configured.");
}
verifyEqualTo(obj, "0", getFunc());
verifyEnumerable(obj, "0");
verifyConfigurable(obj, "0");
} finally {
delete obj[0];
}
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 15.2.3.6-4-531-13
description: >
Object.defineProperty will update [[Get]] and [[Set]] attributes
of indexed accessor property 'P' successfully when
[[Configurable]] attribute is true, 'O' is the global object
(8.12.9 step 11)
includes: [propertyHelper.js]
---*/
var obj = this;
try {
obj.verifySetFunction = "data";
Object.defineProperty(obj, "0", {
get: function () {
return obj.verifySetFunction;
},
set: function (value) {
obj.verifySetFunction = value;
},
configurable: true
});
obj.verifySetFunction1 = "data1";
var getFunc = function () {
return obj.verifySetFunction1;
};
var setFunc = function (value) {
obj.verifySetFunction1 = value;
};
Object.defineProperty(obj, "0", {
get: getFunc,
set: setFunc
});
verifyEqualTo(obj, "0", getFunc());
verifyWritable(obj, "0", "verifySetFunction1");
verifyNotEnumerable(obj, "0");
verifyConfigurable(obj, "0");
} finally {
delete obj[0];
delete obj.verifySetFunction;
delete obj.verifySetFunction1;
}
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 15.2.3.6-4-531-17
description: >
ES5 Attributes - Updating an indexed accessor property 'P' using
simple assignment is successful, 'O' is the global object (8.12.5
step 5.b)
---*/
var obj = this;
obj.verifySetFunc = "data";
var setFunc = function (value) {
obj.verifySetFunc = value;
};
var getFunc = function () {
return obj.verifySetFunc;
};
Object.defineProperty(obj, "0", {
get: getFunc,
set: setFunc,
enumerable: true,
configurable: true
});
obj[0] = "overrideData";
var propertyDefineCorrect = obj.hasOwnProperty("0");
var desc = Object.getOwnPropertyDescriptor(obj, "0");
assert(propertyDefineCorrect, 'propertyDefineCorrect !== true');
assert.sameValue(desc.set, setFunc, 'desc.set');
assert.sameValue(obj[0], "overrideData", 'obj[0]');
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 15.2.3.6-4-531-4
description: >
Object.defineProperty will update [[Get]] and [[Set]] attributes
of named accessor property 'P' successfully when [[Configurable]]
attribute is true, 'O' is the global object (8.12.9 step 11)
includes: [propertyHelper.js]
---*/
var obj = this;
try {
obj.verifySetFunction = "data";
Object.defineProperty(obj, "property", {
get: function () {
return obj.verifySetFunction;
},
set: function (value) {
obj.verifySetFunction = value;
},
configurable: true
});
obj.verifySetFunction1 = "data1";
var getFunc = function () {
return obj.verifySetFunction1;
};
var setFunc = function (value) {
obj.verifySetFunction1 = value;
};
Object.defineProperty(obj, "property", {
get: getFunc,
set: setFunc
});
verifyEqualTo(obj, "property", getFunc());
verifyWritable(obj, "property", "verifySetFunction1");
verifyNotEnumerable(obj, "property");
verifyConfigurable(obj, "property");
} finally {
delete obj.property;
delete obj.verifySetFunction;
delete obj.verifySetFunction1;
}
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 15.2.3.6-4-531-8
description: >
ES5 Attributes - Updating a named accessor property 'P' without
[[Set]] using simple assignment is failed, 'O' is the global
object (8.12.5 step 5.b)
includes: [propertyHelper.js]
---*/
var obj = this;
obj.verifySetFunc = "data";
var getFunc = function () {
return obj.verifySetFunc;
};
Object.defineProperty(obj, "prop", {
get: getFunc,
enumerable: true,
configurable: true
});
assert(obj.hasOwnProperty("prop"));
var desc = Object.getOwnPropertyDescriptor(obj, "prop");
verifyNotWritable(obj, "prop");
assert.sameValue(typeof desc.set, "undefined");
assert.sameValue(obj.prop, "data");
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 15.2.3.6-4-538-3
description: >
ES5 Attributes - Updating a named accessor property 'P' whose
[[Configurable]] attribute is true to a data property is
successful, 'O' is the global object
includes: [propertyHelper.js]
---*/
var obj = this;
obj.verifySetFunc = "data";
var getFunc = function () {
return obj.verifySetFunc;
};
var setFunc = function (value) {
obj.verifySetFunc = value;
};
try {
Object.defineProperty(obj, "prop", {
get: getFunc,
set: setFunc,
enumerable: true,
configurable: true
});
var desc1 = Object.getOwnPropertyDescriptor(obj, "prop");
Object.defineProperty(obj, "prop", {
value: 1001
});
var desc2 = Object.getOwnPropertyDescriptor(obj, "prop");
if (!desc1.hasOwnProperty("get")) {
$ERROR('Expected desc1.hasOwnProperty("get") to be true, actually ' + desc1.hasOwnProperty("get"));
}
if (!desc2.hasOwnProperty("value")) {
$ERROR('Expected desc2.hasOwnProperty("value") to be true, actually ' + desc2.hasOwnProperty("value"));
}
if (typeof desc2.get !== "undefined") {
$ERROR('Expected typeof desc2.get === "undefined", actually ' + typeof desc2.get);
}
if (typeof desc2.set !== "undefined") {
$ERROR('Expected typeof desc2.set === "undefined", actually ' + typeof desc2.set);
}
verifyEqualTo(obj, "prop", 1001);
verifyNotWritable(obj, "prop");
verifyEnumerable(obj, "prop");
verifyConfigurable(obj, "prop");
} finally {
delete obj.prop;
delete obj.verifySetFunc;
}
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 15.2.3.6-4-538-7
description: >
ES5 Attributes - Updating an indexed accessor property 'P' whose
[[Configurable]] attribute is true to a data property is
successful, 'O' is the global object
includes: [propertyHelper.js]
---*/
var obj = this;
obj.verifySetFunc = "data";
var getFunc = function () {
return obj.verifySetFunc;
};
var setFunc = function (value) {
obj.verifySetFunc = value;
};
try {
Object.defineProperty(obj, "0", {
get: getFunc,
set: setFunc,
enumerable: true,
configurable: true
});
var desc1 = Object.getOwnPropertyDescriptor(obj, "0");
Object.defineProperty(obj, "0", {
value: 1001
});
var desc2 = Object.getOwnPropertyDescriptor(obj, "0");
if (!desc1.hasOwnProperty("get")) {
$ERROR('Expected desc1.hasOwnProperty("get") to be true, actually ' + desc1.hasOwnProperty("get"));
}
if (!desc2.hasOwnProperty("value")) {
$ERROR('Expected desc2.hasOwnProperty("value") to be true, actually ' + desc2.hasOwnProperty("value"));
}
if (typeof desc2.get !== "undefined") {
$ERROR('Expected typeof desc2.get === "undefined", actually ' + typeof desc2.get);
}
if (typeof desc2.set !== "undefined") {
$ERROR('Expected typeof desc2.set === "undefined", actually ' + typeof desc2.get);
}
verifyEqualTo(obj, "0", 1001);
verifyNotWritable(obj, "0");
verifyEnumerable(obj, "0");
verifyConfigurable(obj, "0");
} finally {
delete obj[0];
delete obj.verifySetFunc;
}
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 15.2.3.14-6-6
description: >
Object.keys - the order of elements in returned array is the same
with the order of properties in 'O' (global Object)
---*/
var obj = this;
var tempArray = [];
for (var p in obj) {
if (obj.hasOwnProperty(p)) {
tempArray.push(p);
}
}
var returnedArray = Object.keys(obj);
for (var index in returnedArray) {
assert.sameValue(tempArray[index], returnedArray[index], 'tempArray[index]');
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment