|
| 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 | +if (this.WScript && this.WScript.LoadScriptFile) { // Check for running in ch |
| 7 | + this.WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js"); |
| 8 | + this.WScript.LoadScriptFile("util.js"); |
| 9 | +} |
| 10 | + |
| 11 | +var tests = [ |
| 12 | + { |
| 13 | + name: "Typed arrays support delete of non-indexed properties", |
| 14 | + body: function () { |
| 15 | + const ta = Int8Array.of(42); |
| 16 | + |
| 17 | + ta.non_indexed = 'whatever'; |
| 18 | + assert.areEqual('whatever', ta.non_indexed, "ta.non_indexed is set to 'whatever'"); |
| 19 | + |
| 20 | + delete ta.non_indexed; |
| 21 | + assert.areEqual(undefined, ta.non_indexed, "ta.non_indexed has been deleted"); |
| 22 | + } |
| 23 | + }, |
| 24 | + { |
| 25 | + name: "delete of nonconfigurable non-indexed properties on Typed arrays", |
| 26 | + body: function () { |
| 27 | + const ta = Int8Array.of(42); |
| 28 | + var id = 'id'; |
| 29 | + Object.defineProperty(ta, id, { value: 17, configurable: false }); |
| 30 | + |
| 31 | + delete ta[id]; |
| 32 | + assert.areEqual(17, ta[id], "ta['id'] value after failed delete"); |
| 33 | + |
| 34 | + assert.throws(function () { 'use strict'; delete ta[id]; }, TypeError, "Should throw on delete of indexed property in typed array", "Calling delete on 'id' is not allowed in strict mode"); |
| 35 | + } |
| 36 | + }, |
| 37 | + { |
| 38 | + name: "Typed arrays don't support delete of indexed properties", |
| 39 | + body: function () { |
| 40 | + const ta = Int8Array.of(42); |
| 41 | + |
| 42 | + delete ta[0]; |
| 43 | + assert.areEqual(42, ta[0], "ta[0] value after failed delete"); |
| 44 | + |
| 45 | + assert.throws(function () { 'use strict'; delete ta[0]; }, TypeError, "Should throw on delete of indexed property in typed array", "Calling delete on '0' is not allowed in strict mode"); |
| 46 | + } |
| 47 | + } |
| 48 | +]; |
| 49 | + |
| 50 | +testRunner.runTests(tests, { verbose: false /*so no need to provide baseline*/ }); |
0 commit comments