瀏覽代碼

Add tests to cover regressions in reduced repros for VSO 7399962.

Doug Ilijev 9 年之前
父節點
當前提交
efc0772266
共有 2 個文件被更改,包括 54 次插入0 次删除
  1. 48 0
      test/Object/propertyDescriptorNonObject.js
  2. 6 0
      test/Object/rlexe.xml

+ 48 - 0
test/Object/propertyDescriptorNonObject.js

@@ -0,0 +1,48 @@
+//-------------------------------------------------------------------------------------------------------
+// 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() {
+            a = 0;
+            assert.throws(function() { Object.create({}, this) },
+                TypeError,
+                "Should throw TypeError because property 'a' is defined on `this` and is a non-object.",
+                "Invalid descriptor for property 'a'")
+        }
+    },
+];
+
+testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" });

+ 6 - 0
test/Object/rlexe.xml

@@ -56,6 +56,12 @@
       <tags>Slow</tags>
     </default>
   </test>
+  <test>
+    <default>
+      <files>propertyDescriptorNonObject.js</files>
+      <compile-flags>-args summary -endargs</compile-flags>
+    </default>
+  </test>
   <test>
     <default>
         <files>toLocaleString2.js</files>