mirror of https://github.com/tc39/test262.git
test/built-ins/Object/prototype/toString/*.js: clean up and extended fixes from gh-1473 (#1475)
This commit is contained in:
parent
3207bf74d0
commit
3af53b8087
|
@ -1,11 +0,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.4.2-1-1
|
||||
description: >
|
||||
Object.prototype.toString - '[object Undefined]' will be returned
|
||||
when 'this' value is undefined
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(undefined), "[object Undefined]", 'Object.prototype.toString.call(undefined)');
|
|
@ -1,11 +0,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.4.2-1-2
|
||||
description: >
|
||||
Object.prototype.toString - '[object Undefined]' will be returned
|
||||
when 'this' value is undefined
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.prototype.toString.apply(undefined, []), "[object Undefined]", 'Object.prototype.toString.apply(undefined, [])');
|
|
@ -1,11 +0,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.4.2-2-1
|
||||
description: >
|
||||
Object.prototype.toString - '[object Null]' will be returned when
|
||||
'this' value is null
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(null), "[object Null]", 'Object.prototype.toString.call(null)');
|
|
@ -1,11 +0,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.4.2-2-2
|
||||
description: >
|
||||
Object.prototype.toString - '[object Null]' will be returned when
|
||||
'this' value is null
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.prototype.toString.apply(null, []), "[object Null]", 'Object.prototype.toString.apply(null, [])');
|
12
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-arguments.js
vendored
Normal file
12
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-arguments.js
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Copyright 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-object.prototype.tostring
|
||||
description: has a [[ParameterMap]] internal slot, let builtinTag be "Arguments".
|
||||
---*/
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(function() { return arguments; }()),
|
||||
"[object Arguments]",
|
||||
"Object.prototype.toString.call(function() { return arguments; }()) returns [object Arguments]"
|
||||
);
|
32
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-array.js
vendored
Normal file
32
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-array.js
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Copyright 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-object.prototype.tostring
|
||||
description: Let isArray be ? IsArray(O). If isArray is true, let builtinTag be "Array".
|
||||
---*/
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call([]),
|
||||
"[object Array]",
|
||||
"Object.prototype.toString.call([]) returns [object Array]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object([])),
|
||||
"[object Array]",
|
||||
"Object.prototype.toString.call(Object([])) returns [object Array]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Array()),
|
||||
"[object Array]",
|
||||
"Object.prototype.toString.call(Array()) returns [object Array]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object(Array())),
|
||||
"[object Array]",
|
||||
"Object.prototype.toString.call(Object(Array())) returns [object Array]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object(new Array())),
|
||||
"[object Array]",
|
||||
"Object.prototype.toString.call(Object(new Array())) returns [object Array]"
|
||||
);
|
14
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-bigint.js
vendored
Normal file
14
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-bigint.js
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Copyright (C) 2017 Igalia, S. L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-object.prototype.tostring
|
||||
description: BigInt.prototype[@@toStringTag] is BigInt
|
||||
info: |
|
||||
Let tag be ? Get(O, @@toStringTag).
|
||||
features: [BigInt]
|
||||
---*/
|
||||
assert.sameValue(Object.prototype.toString.call(3n), "[object BigInt]");
|
||||
assert.sameValue(Object.prototype.toString.call(Object(3n)), "[object BigInt]");
|
||||
assert.sameValue(Object.prototype.toString.call(BigInt(3n)), "[object BigInt]");
|
||||
assert.sameValue(Object.prototype.toString.call(Object(BigInt(3n))), "[object BigInt]");
|
37
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-boolean.js
vendored
Normal file
37
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-boolean.js
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-object.prototype.tostring
|
||||
description: has a [[BooleanData]] internal slot, let builtinTag be "Boolean".
|
||||
---*/
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(true),
|
||||
"[object Boolean]",
|
||||
"Object.prototype.toString.call(true) returns [object Boolean]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object(true)),
|
||||
"[object Boolean]",
|
||||
"Object.prototype.toString.call(Object(true)) returns [object Boolean]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Boolean(true)),
|
||||
"[object Boolean]",
|
||||
"Object.prototype.toString.call(Boolean(true)) returns [object Boolean]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object(Boolean(true))),
|
||||
"[object Boolean]",
|
||||
"Object.prototype.toString.call(Object(Boolean(true))) returns [object Boolean]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(new Boolean(true)),
|
||||
"[object Boolean]",
|
||||
"Object.prototype.toString.call(new Boolean(true)) returns [object Boolean]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object(new Boolean(true))),
|
||||
"[object Boolean]",
|
||||
"Object.prototype.toString.call(Object(new Boolean(true))) returns [object Boolean]"
|
||||
);
|
17
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-date.js
vendored
Normal file
17
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-date.js
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-object.prototype.tostring
|
||||
description: is a String exotic object, let builtinTag be "String".
|
||||
---*/
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(new Date()),
|
||||
"[object Date]",
|
||||
"Object.prototype.toString.call(new Date()) returns [object Date]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object(new Date())),
|
||||
"[object Date]",
|
||||
"Object.prototype.toString.call(Object(new Date())) returns [object Date]"
|
||||
);
|
27
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-error.js
vendored
Normal file
27
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-error.js
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Copyright 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-object.prototype.tostring
|
||||
description: has an [[ErrorData]] internal slot, let builtinTag be "Error".
|
||||
---*/
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Error()),
|
||||
"[object Error]",
|
||||
"Object.prototype.toString.call(Error()) returns [object Error]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object(Error())),
|
||||
"[object Error]",
|
||||
"Object.prototype.toString.call(Object(Error())) returns [object Error]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(new Error()),
|
||||
"[object Error]",
|
||||
"Object.prototype.toString.call(new Error()) returns [object Error]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object(new Error())),
|
||||
"[object Error]",
|
||||
"Object.prototype.toString.call(Object(new Error())) returns [object Error]"
|
||||
);
|
37
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-function.js
vendored
Normal file
37
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-function.js
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-object.prototype.tostring
|
||||
description: has a [[Call]] internal method, let builtinTag be "Function".
|
||||
---*/
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(function() {}),
|
||||
"[object Function]",
|
||||
"Object.prototype.toString.call(function() {}) returns [object Function]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object(function() {})),
|
||||
"[object Function]",
|
||||
"Object.prototype.toString.call(Object(function() {})) returns [object Function]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Function()),
|
||||
"[object Function]",
|
||||
"Object.prototype.toString.call(Function()) returns [object Function]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object(Function())),
|
||||
"[object Function]",
|
||||
"Object.prototype.toString.call(Object(Function())) returns [object Function]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(new Function()),
|
||||
"[object Function]",
|
||||
"Object.prototype.toString.call(new Function()) returns [object Function]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object(new Function())),
|
||||
"[object Function]",
|
||||
"Object.prototype.toString.call(Object(new Function())) returns [object Function]"
|
||||
);
|
12
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-null.js
vendored
Normal file
12
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-null.js
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Copyright 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-object.prototype.tostring
|
||||
description: If the this value is null, return "[object Null]".
|
||||
---*/
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(null),
|
||||
"[object Null]",
|
||||
"Object.prototype.toString.call(null) returns [object Null]"
|
||||
);
|
37
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-number.js
vendored
Normal file
37
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-number.js
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-object.prototype.tostring
|
||||
description: has a [[NumberData]] internal slot, let builtinTag be "Number"
|
||||
---*/
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(9),
|
||||
"[object Number]",
|
||||
"Object.prototype.toString.call(9) returns [object Number]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object(9)),
|
||||
"[object Number]",
|
||||
"Object.prototype.toString.call(Object(9)) returns [object Number]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Number(9)),
|
||||
"[object Number]",
|
||||
"Object.prototype.toString.call(Number(9)) returns [object Number]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object(Number(9))),
|
||||
"[object Number]",
|
||||
"Object.prototype.toString.call(Object(Number(9))) returns [object Number]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(new Number(9)),
|
||||
"[object Number]",
|
||||
"Object.prototype.toString.call(new Number(9)) returns [object Number]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object(new Number(9))),
|
||||
"[object Number]",
|
||||
"Object.prototype.toString.call(Object(new Number(9))) returns [object Number]"
|
||||
);
|
22
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-object.js
vendored
Normal file
22
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-object.js
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Copyright 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-object.prototype.tostring
|
||||
description: Else, let builtinTag be "Object".
|
||||
---*/
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call({}),
|
||||
"[object Object]",
|
||||
"Object.prototype.toString.call({}) returns [object Object]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object({})),
|
||||
"[object Object]",
|
||||
"Object.prototype.toString.call(Object({})) returns [object Object]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(new Object({})),
|
||||
"[object Object]",
|
||||
"Object.prototype.toString.call(new Object({})) returns [object Object]"
|
||||
);
|
27
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-regexp.js
vendored
Normal file
27
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-regexp.js
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Copyright 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-object.prototype.tostring
|
||||
description: has a [[RegExpMatcher]] internal slot, let builtinTag be "RegExp".
|
||||
---*/
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(/./),
|
||||
"[object RegExp]",
|
||||
"Object.prototype.toString.call(/./) returns [object RegExp]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object(/./)),
|
||||
"[object RegExp]",
|
||||
"Object.prototype.toString.call(Object(/./)) returns [object RegExp]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(new RegExp()),
|
||||
"[object RegExp]",
|
||||
"Object.prototype.toString.call(new RegExp()) returns [object RegExp]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object(new RegExp())),
|
||||
"[object RegExp]",
|
||||
"Object.prototype.toString.call(Object(new RegExp())) returns [object RegExp]"
|
||||
);
|
37
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-string.js
vendored
Normal file
37
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-string.js
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-object.prototype.tostring
|
||||
description: is a String exotic object, let builtinTag be "String".
|
||||
---*/
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(""),
|
||||
"[object String]",
|
||||
"Object.prototype.toString.call(\"\") returns [object String]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object("")),
|
||||
"[object String]",
|
||||
"Object.prototype.toString.call(Object(\"\")) returns [object String]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(String("")),
|
||||
"[object String]",
|
||||
"Object.prototype.toString.call(String(\"\")) returns [object String]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object(String(""))),
|
||||
"[object String]",
|
||||
"Object.prototype.toString.call(Object(String(\"\"))) returns [object String]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(new String("")),
|
||||
"[object String]",
|
||||
"Object.prototype.toString.call(new String(\"\")) returns [object String]"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Object(new String(""))),
|
||||
"[object String]",
|
||||
"Object.prototype.toString.call(Object(new String(\"\"))) returns [object String]"
|
||||
);
|
12
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-undefined.js
vendored
Normal file
12
test/built-ins/Object/prototype/toString/Object.prototype.toString.call-undefined.js
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Copyright 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-object.prototype.tostring
|
||||
description: If the this value is undefined, return "[object Undefined]".
|
||||
---*/
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(undefined),
|
||||
"[object Undefined]",
|
||||
"Object.prototype.toString.call(undefined) returns [object Undefined]"
|
||||
);
|
|
@ -1,29 +0,0 @@
|
|||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
info: |
|
||||
When the toString method is called, the following steps are taken:
|
||||
i) Get the [[Class]] property of this object
|
||||
ii) Compute a string value by concatenating the three strings "[object ", Result(1), and "]"
|
||||
iii) Return Result(2)
|
||||
es5id: 15.2.4.2_A1
|
||||
description: >
|
||||
Checking the type of Object.prototype.toString and the returned
|
||||
result
|
||||
---*/
|
||||
|
||||
//CHECK#1
|
||||
if (typeof Object.prototype.toString !== "function") {
|
||||
$ERROR('#1: toString method defined');
|
||||
}
|
||||
|
||||
//CHECK#2
|
||||
if (Object.prototype.toString() !== "[object " + "Object" + "]") {
|
||||
$ERROR('#2: return a string value by concatenating the three strings "[object ", the [[Class]] property of this object, and "]"');
|
||||
}
|
||||
|
||||
//CHECK#3
|
||||
if ({}.toString() !== "[object " + "Object" + "]") {
|
||||
$ERROR('#3: return a string value by concatenating the three strings "[object ", the [[Class]] property of this object, and "]"');
|
||||
}
|
|
@ -1,27 +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 Object.prototype.toString.length property has the attribute ReadOnly
|
||||
es5id: 15.2.4.2_A10
|
||||
description: >
|
||||
Checking if varying the Object.prototype.toString.length property
|
||||
fails
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
//CHECK#1
|
||||
if (!(Object.prototype.toString.hasOwnProperty('length'))) {
|
||||
$ERROR('#1: the Object.prototype.toString has length property.');
|
||||
}
|
||||
|
||||
var obj = Object.prototype.toString.length;
|
||||
|
||||
verifyNotWritable(Object.prototype.toString, "length", null, function() {
|
||||
return "shifted";
|
||||
});
|
||||
|
||||
//CHECK#2
|
||||
if (Object.prototype.toString.length !== obj) {
|
||||
$ERROR('#2: the Object.prototype.toString length property has the attributes ReadOnly.');
|
||||
}
|
|
@ -1,18 +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 toString method is 0
|
||||
es5id: 15.2.4.2_A11
|
||||
description: Checking the Object.prototype.toString.length property
|
||||
---*/
|
||||
|
||||
//CHECK#1
|
||||
if (!(Object.prototype.toString.hasOwnProperty("length"))) {
|
||||
$ERROR('#1: The length property of the toString method is 0');
|
||||
}
|
||||
|
||||
//CHECK#2
|
||||
if (Object.prototype.toString.length !== 0) {
|
||||
$ERROR('#2: The length property of the toString method is 0');
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
// Copyright 2011 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es5id: 15.2.4.2_A12
|
||||
description: If the this value is undefined, return "[object Undefined]".
|
||||
---*/
|
||||
|
||||
if (Object.prototype.toString.call(undefined) !== "[object Undefined]") {
|
||||
$ERROR('If the this value is undefined, return "[object Undefined]".');
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
// Copyright 2011 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es5id: 15.2.4.2_A13
|
||||
description: If the this value is null, return "[object Null]".
|
||||
---*/
|
||||
|
||||
if (Object.prototype.toString.call(null) !== "[object Null]") {
|
||||
$ERROR('If the this value is null, return "[object Null]".');
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
// Copyright 2011 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es5id: 15.2.4.2_A14
|
||||
description: >
|
||||
Let O be the result of calling ToObject passing the this value as
|
||||
the argument.
|
||||
---*/
|
||||
|
||||
if (Object.prototype.toString.call(33) !== "[object Number]") {
|
||||
$ERROR('Let O be the result of calling ToObject passing the this ' +
|
||||
'value as the argument.');
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
// Copyright 2011 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es5id: 15.2.4.2_A15
|
||||
description: >
|
||||
Let O be the result of calling ToObject passing the this value as
|
||||
the argument.
|
||||
---*/
|
||||
|
||||
if (Object.prototype.toString.call(true) !== "[object Boolean]") {
|
||||
$ERROR('Let O be the result of calling ToObject passing the this ' +
|
||||
'value as the argument.');
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
// Copyright 2011 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es5id: 15.2.4.2_A16
|
||||
description: >
|
||||
Let O be the result of calling ToObject passing the this value as
|
||||
the argument.
|
||||
---*/
|
||||
|
||||
if (Object.prototype.toString.call('foo') !== "[object String]") {
|
||||
$ERROR('Let O be the result of calling ToObject passing the this ' +
|
||||
'value as the argument.');
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
info: Object.prototype.toString has not prototype property
|
||||
es5id: 15.2.4.2_A6
|
||||
description: >
|
||||
Checking if obtaining the prototype property of
|
||||
Object.prototype.toString fails
|
||||
---*/
|
||||
|
||||
//CHECK#1
|
||||
if (Object.prototype.toString.prototype !== undefined) {
|
||||
$ERROR('#1: Object.prototype.toString has not prototype property' + Object.prototype.toString.prototype);
|
||||
}
|
||||
//
|
|
@ -1,14 +0,0 @@
|
|||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
info: Object.prototype.toString can't be used as a constructor
|
||||
es5id: 15.2.4.2_A7
|
||||
description: Checking if creating "new Object.prototype.toString" fails
|
||||
---*/
|
||||
|
||||
var FACTORY = Object.prototype.toString;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
new FACTORY;
|
||||
});
|
|
@ -1,28 +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 Object.prototype.toString.length property has the attribute DontEnum
|
||||
es5id: 15.2.4.2_A8
|
||||
description: >
|
||||
Checking if enumerating the Object.prototype.toString.length
|
||||
property fails
|
||||
---*/
|
||||
|
||||
//CHECK#0
|
||||
if (!(Object.prototype.toString.hasOwnProperty('length'))) {
|
||||
$ERROR('#0: the Object.prototype.toString has length property.');
|
||||
}
|
||||
|
||||
|
||||
// CHECK#1
|
||||
if (Object.prototype.toString.propertyIsEnumerable('length')) {
|
||||
$ERROR('#1: the Object.prototype.toString.length property has the attributes DontEnum');
|
||||
}
|
||||
|
||||
// CHECK#2
|
||||
for (var p in Object.prototype.toString) {
|
||||
if (p === "length")
|
||||
$ERROR('#2: the Object.prototype.toString.length property has the attributes DontEnum');
|
||||
}
|
||||
//
|
|
@ -1,27 +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 Object.prototype.toString.length property does not have the attribute
|
||||
DontDelete
|
||||
es5id: 15.2.4.2_A9
|
||||
description: >
|
||||
Checknig if deleting of the Object.prototype.toString.length
|
||||
property fails
|
||||
---*/
|
||||
|
||||
//CHECK#0
|
||||
if (!(Object.prototype.toString.hasOwnProperty('length'))) {
|
||||
$ERROR('#0: the Object.prototype.toString has length property');
|
||||
}
|
||||
|
||||
//CHECK#1
|
||||
if (!delete Object.prototype.toString.length) {
|
||||
$ERROR('#1: The Object.prototype.toString.length property does not have the attributes DontDelete');
|
||||
}
|
||||
|
||||
//CHECK#2
|
||||
if (Object.prototype.toString.hasOwnProperty('length')) {
|
||||
$ERROR('#2: The Object.prototype.toString.length property does not have the attributes DontDelete');
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-object.prototype.tostring
|
||||
description: Else, let builtinTag be "Object".
|
||||
---*/
|
||||
assert.sameValue(
|
||||
Object.prototype.toString(),
|
||||
"[object Object]",
|
||||
"Object.prototype.toString() returns [object Object]"
|
||||
);
|
||||
assert.sameValue(
|
||||
{}.toString(),
|
||||
"[object Object]",
|
||||
"({}).toString() returns [object Object]"
|
||||
);
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-object.prototype.tostring
|
||||
description: >
|
||||
Object.prototype.toString.length is 0.
|
||||
info: |
|
||||
Object.prototype.toString ( )
|
||||
|
||||
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. However, rest parameters shown using the form “...name”
|
||||
are not included in the default argument count.
|
||||
|
||||
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(Object.prototype.toString, "length", {
|
||||
value: 0,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
|
@ -19,8 +19,9 @@ info: |
|
|||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.prototype.toString.name, "toString");
|
||||
|
||||
verifyNotEnumerable(Object.prototype.toString, "name");
|
||||
verifyNotWritable(Object.prototype.toString, "name");
|
||||
verifyConfigurable(Object.prototype.toString, "name");
|
||||
verifyProperty(Object.prototype.toString, "name", {
|
||||
value: "toString",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es5id: sec-object.prototype.tostring
|
||||
description: Object.prototype.toString has no prototype property
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.hasOwnProperty("prototype"),
|
||||
false,
|
||||
"Object.prototype.toString.hasOwnProperty(\"prototype\") returns false"
|
||||
);
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-ecmascript-standard-built-in-objects
|
||||
description: Object.prototype.toString is not a constructor
|
||||
info: |
|
||||
Built-in function objects that are not identified as constructors do
|
||||
not implement the [[Construct]] internal method unless otherwise specified
|
||||
in the description of a particular function
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
new Object.prototype.toString();
|
||||
});
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-object.prototype.tostring
|
||||
description: >
|
||||
Object.prototype.toString property descriptor
|
||||
info: |
|
||||
17 ECMAScript Standard Built-in Objects:
|
||||
|
||||
...
|
||||
Every other data property described in clauses 18 through 26
|
||||
and in Annex B.2 has the attributes { [[Writable]]: true,
|
||||
[[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
verifyWritable(Object.prototype, "toString");
|
||||
verifyNotEnumerable(Object.prototype, "toString");
|
||||
verifyConfigurable(Object.prototype, "toString");
|
Loading…
Reference in New Issue