Fix attributes of length property for builtin functions (#3689)
fix length property of builtin functions to be configurable (ECMA-262 v6, 19.2.4.1) JerryScript-DCO-1.0-Signed-off-by: HyukWoo Park hyukwoo.park@samsung.com
This commit is contained in:
@@ -39,8 +39,6 @@ var builtin_objects = [
|
||||
WeakSet,
|
||||
];
|
||||
|
||||
var builtin_prototypes = [Function.prototype]
|
||||
|
||||
var builtin_typedArrays = [
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
@@ -65,13 +63,6 @@ var builtin_typedArrays = [
|
||||
assert(desc.configurable === true);
|
||||
}
|
||||
|
||||
for (proto of builtin_prototypes) {
|
||||
desc = Object.getOwnPropertyDescriptor(proto, 'length');
|
||||
assert(desc.writable === false);
|
||||
assert(desc.enumerable === false);
|
||||
assert(desc.configurable === true);
|
||||
}
|
||||
|
||||
for (ta of builtin_typedArrays) {
|
||||
desc = Object.getOwnPropertyDescriptor(ta, 'length');
|
||||
assert(desc.writable === false);
|
||||
@@ -88,12 +79,6 @@ var builtin_typedArrays = [
|
||||
assert(obj.hasOwnProperty('length') === false);
|
||||
}
|
||||
|
||||
for (proto of builtin_prototypes) {
|
||||
assert(proto.hasOwnProperty('length') === true);
|
||||
assert(delete proto.length);
|
||||
assert(proto.hasOwnProperty('length') === false);
|
||||
}
|
||||
|
||||
for (ta of builtin_typedArrays) {
|
||||
assert(ta.hasOwnProperty('length') === true);
|
||||
assert(delete ta.length);
|
||||
@@ -101,6 +86,26 @@ var builtin_typedArrays = [
|
||||
}
|
||||
})();
|
||||
|
||||
(function () {
|
||||
/* test length property of builtin function */
|
||||
for (obj of builtin_objects) {
|
||||
var property_names = Object.getOwnPropertyNames(obj);
|
||||
for (var name of property_names) {
|
||||
if (typeof obj[name] == 'function') {
|
||||
var func = obj[name];
|
||||
var desc = Object.getOwnPropertyDescriptor(func, 'length');
|
||||
assert(desc.writable === false);
|
||||
assert(desc.enumerable === false);
|
||||
assert(desc.configurable === true);
|
||||
|
||||
assert(func.hasOwnProperty('length') === true);
|
||||
assert(delete func.length);
|
||||
assert(func.hasOwnProperty('length') === false);
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
(function () {
|
||||
/* test length property of function objects */
|
||||
var normal_func = function () {};
|
||||
|
||||
@@ -13,7 +13,17 @@
|
||||
// limitations under the License.
|
||||
|
||||
// check properties
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.charAt, 'length').configurable === false);
|
||||
|
||||
function length_configurable()
|
||||
{
|
||||
function is_es51() {
|
||||
return (typeof g === "function");
|
||||
{ function g() {} }
|
||||
}
|
||||
return is_es51() ? false : true;
|
||||
}
|
||||
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.charAt, 'length').configurable === length_configurable());
|
||||
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.charAt, 'length').enumerable === false);
|
||||
|
||||
|
||||
@@ -13,7 +13,17 @@
|
||||
// limitations under the License.
|
||||
|
||||
// check properties
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.charCodeAt, 'length').configurable === false);
|
||||
|
||||
function length_configurable()
|
||||
{
|
||||
function is_es51() {
|
||||
return (typeof g === "function");
|
||||
{ function g() {} }
|
||||
}
|
||||
return is_es51() ? false : true;
|
||||
}
|
||||
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.charCodeAt, 'length').configurable === length_configurable());
|
||||
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.charCodeAt, 'length').enumerable === false);
|
||||
|
||||
|
||||
@@ -13,7 +13,17 @@
|
||||
// limitations under the License.
|
||||
|
||||
// check properties
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.concat, 'length').configurable === false);
|
||||
|
||||
function length_configurable()
|
||||
{
|
||||
function is_es51() {
|
||||
return (typeof g === "function");
|
||||
{ function g() {} }
|
||||
}
|
||||
return is_es51() ? false : true;
|
||||
}
|
||||
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.concat, 'length').configurable === length_configurable());
|
||||
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.concat, 'length').enumerable === false);
|
||||
|
||||
|
||||
@@ -13,7 +13,17 @@
|
||||
// limitations under the License.
|
||||
|
||||
// check properties
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.indexOf, 'length').configurable === false);
|
||||
|
||||
function length_configurable()
|
||||
{
|
||||
function is_es51() {
|
||||
return (typeof g === "function");
|
||||
{ function g() {} }
|
||||
}
|
||||
return is_es51() ? false : true;
|
||||
}
|
||||
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.indexOf, 'length').configurable === length_configurable());
|
||||
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.indexOf, 'length').enumerable === false);
|
||||
|
||||
|
||||
@@ -13,7 +13,17 @@
|
||||
// limitations under the License.
|
||||
|
||||
// check properties
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.lastIndexOf, 'length').configurable === false);
|
||||
|
||||
function length_configurable()
|
||||
{
|
||||
function is_es51() {
|
||||
return (typeof g === "function");
|
||||
{ function g() {} }
|
||||
}
|
||||
return is_es51() ? false : true;
|
||||
}
|
||||
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.lastIndexOf, 'length').configurable === length_configurable());
|
||||
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.lastIndexOf, 'length').enumerable === false);
|
||||
|
||||
|
||||
@@ -13,7 +13,17 @@
|
||||
// limitations under the License.
|
||||
|
||||
// check properties
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.match, 'length').configurable === false);
|
||||
|
||||
function length_configurable()
|
||||
{
|
||||
function is_es51() {
|
||||
return (typeof g === "function");
|
||||
{ function g() {} }
|
||||
}
|
||||
return is_es51() ? false : true;
|
||||
}
|
||||
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.match, 'length').configurable === length_configurable());
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.match, 'length').enumerable === false);
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.match, 'length').writable === false);
|
||||
|
||||
|
||||
@@ -13,7 +13,17 @@
|
||||
// limitations under the License.
|
||||
|
||||
// check properties
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.substr, 'length').configurable === false);
|
||||
|
||||
function length_configurable()
|
||||
{
|
||||
function is_es51() {
|
||||
return (typeof g === "function");
|
||||
{ function g() {} }
|
||||
}
|
||||
return is_es51() ? false : true;
|
||||
}
|
||||
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.substr, 'length').configurable === length_configurable());
|
||||
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.substr, 'length').enumerable === false);
|
||||
|
||||
|
||||
@@ -13,7 +13,17 @@
|
||||
// limitations under the License.
|
||||
|
||||
// check properties
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.substring, 'length').configurable === false);
|
||||
|
||||
function length_configurable()
|
||||
{
|
||||
function is_es51() {
|
||||
return (typeof g === "function");
|
||||
{ function g() {} }
|
||||
}
|
||||
return is_es51() ? false : true;
|
||||
}
|
||||
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.substring, 'length').configurable === length_configurable());
|
||||
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.substring, 'length').enumerable === false);
|
||||
|
||||
|
||||
@@ -13,7 +13,17 @@
|
||||
// limitations under the License.
|
||||
|
||||
// check properties
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.trim, 'length').configurable === false);
|
||||
|
||||
function length_configurable()
|
||||
{
|
||||
function is_es51() {
|
||||
return (typeof g === "function");
|
||||
{ function g() {} }
|
||||
}
|
||||
return is_es51() ? false : true;
|
||||
}
|
||||
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.trim, 'length').configurable === length_configurable());
|
||||
|
||||
assert(Object.getOwnPropertyDescriptor(String.prototype.trim, 'length').enumerable === false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user