Merge "length" tests

This commit is contained in:
Alexey Shvayka 2020-01-16 13:09:39 +02:00 committed by Rick Waldron
parent e756399793
commit 946a2a3fec
5 changed files with 29 additions and 134 deletions

View File

@ -1,33 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: The String.prototype.replace.length property has the attribute ReadOnly
es5id: 15.5.4.11_A10
description: >
Checking if varying the String.prototype.replace.length property
fails
includes: [propertyHelper.js]
---*/
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if (!(String.prototype.replace.hasOwnProperty('length'))) {
$ERROR('#1: String.prototype.replace.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.replace.hasOwnProperty('length'));
}
//
//////////////////////////////////////////////////////////////////////////////
var __obj = String.prototype.replace.length;
verifyNotWritable(String.prototype.replace, "length", null, function() {
return "shifted";
});
//////////////////////////////////////////////////////////////////////////////
//CHECK#2
if (String.prototype.replace.length !== __obj) {
$ERROR('#2: __obj = String.prototype.replace.length; String.prototype.replace.length = function(){return "shifted";}; String.prototype.replace.length === __obj. Actual: ' + String.prototype.replace.length);
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -1,24 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: The length property of the replace method is 2
es5id: 15.5.4.11_A11
description: Checking String.prototype.replace.length
---*/
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if (!(String.prototype.replace.hasOwnProperty("length"))) {
$ERROR('#1: String.prototype.replace.hasOwnProperty("length") return true. Actual: ' + String.prototype.replace.hasOwnProperty("length"));
}
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//CHECK#2
if (String.prototype.replace.length !== 2) {
$ERROR('#2: String.prototype.replace.length === 2. Actual: ' + String.prototype.replace.length);
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -1,41 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: The String.prototype.replace.length property has the attribute DontEnum
es5id: 15.5.4.11_A8
description: >
Checking if enumerating the String.prototype.replace.length
property fails
---*/
//////////////////////////////////////////////////////////////////////////////
//CHECK#0
if (!(String.prototype.replace.hasOwnProperty('length'))) {
$ERROR('#0: String.prototype.replace.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.replace.hasOwnProperty('length'));
}
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// CHECK#1
if (String.prototype.replace.propertyIsEnumerable('length')) {
$ERROR('#1: String.prototype.replace.propertyIsEnumerable(\'length\') return false');
}
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// CHECK#2
var count = 0;
for (var p in String.prototype.replace) {
if (p === "length") count++;
}
if (count !== 0) {
$ERROR('#2: count=0; for (p in String.prototype.replace){if (p==="length") count++;} count === 0. Actual: ' + count);
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -1,36 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: |
The String.prototype.replace.length property does not have the attribute
DontDelete
es5id: 15.5.4.11_A9
description: >
Checking if deleting the String.prototype.replace.length property
fails
---*/
//////////////////////////////////////////////////////////////////////////////
//CHECK#0
if (!(String.prototype.replace.hasOwnProperty('length'))) {
$ERROR('#0: String.prototype.replace.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.replace.hasOwnProperty('length'));
}
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if (!delete String.prototype.replace.length) {
$ERROR('#1: delete String.prototype.replace.length return true!');
}
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//CHECK#2
if (String.prototype.replace.hasOwnProperty('length')) {
$ERROR('#2: delete String.prototype.replace.length; String.prototype.replace.hasOwnProperty(\'length\') return false. Actual: ' + String.prototype.replace.hasOwnProperty('length'));
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,29 @@
// Copyright (C) 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-string.prototype.replace
description: >
String.prototype.replace.length is 2.
info: |
String.prototype.replace ( searchValue, replaceValue )
17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, has a length
property whose value is an integer. Unless otherwise specified, this
value is equal to the largest number of named arguments shown in the
subclause headings for the function description, including optional
parameters.
Unless otherwise specified, the length property of a built-in Function
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
---*/
verifyProperty(String.prototype.replace, "length", {
value: 2,
writable: false,
enumerable: false,
configurable: true,
});