-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathpropertyDescriptorNonObject.js
47 lines (44 loc) · 2.04 KB
/
propertyDescriptorNonObject.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js");
var tests = [
{
name: "Object.create with propertyDescriptor containing non-object keys",
body: function() {
assert.throws(function() { Object.create({}, {a: 0}) },
TypeError,
"Should throw TypeError because property 'a' is not an object.",
"Invalid descriptor for property 'a'")
}
},
{
name: "Object.defineProperty with number for propertyDescriptor",
body: function() {
assert.throws(function() { Object.defineProperty({}, "x", 0) },
TypeError,
"Should throw TypeError because property 'x' is a number.",
"Invalid descriptor for property 'x'")
}
},
{
name: "Object.create with array of non-objects for propertyDescriptor",
body: function() {
assert.throws(function() { Object.create({}, [0]) },
TypeError,
"Should throw TypeError because propertyDescriptor is an array containing non-objects.",
"Invalid descriptor for property '0'")
}
},
{
name: "Object.create in sloppy mode with `this` as a propertyDescriptor when it contains non-object properties",
body: function() {
assert.throws(function() { Object.create({}, this) },
TypeError,
"Should throw TypeError because property Symbol.toStringTag is defined on `this` and is a non-object.",
"Invalid descriptor for property 'Symbol.toStringTag'")
}
},
];
testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" });