Skip to content

Commit efc0772

Browse files
committed
Add tests to cover regressions in reduced repros for VSO 7399962.
1 parent c25389f commit efc0772

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

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

test/Object/rlexe.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@
5656
<tags>Slow</tags>
5757
</default>
5858
</test>
59+
<test>
60+
<default>
61+
<files>propertyDescriptorNonObject.js</files>
62+
<compile-flags>-args summary -endargs</compile-flags>
63+
</default>
64+
</test>
5965
<test>
6066
<default>
6167
<files>toLocaleString2.js</files>

0 commit comments

Comments
 (0)