|
| 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" }); |
0 commit comments