-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testing the integrity level of non-extensible arrays.
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
graal-js/src/com.oracle.truffle.js.test/js/array_integrity_level.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) 2025, 2025, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. | ||
*/ | ||
|
||
load("assert.js"); | ||
|
||
[[], new Array(100)].forEach(function (array) { | ||
assertFalse(Object.isSealed(array)); | ||
assertFalse(Object.isFrozen(array)); | ||
|
||
Object.preventExtensions(array); | ||
|
||
assertTrue(Object.isSealed(array)); | ||
assertFalse(Object.isFrozen(array)); // length is writable still | ||
|
||
Object.defineProperty(array, 'length', { writable: false }); | ||
|
||
assertTrue(Object.isSealed(array)); | ||
assertTrue(Object.isFrozen(array)); | ||
}); | ||
|
||
var array = [,42]; | ||
Object.preventExtensions(array); | ||
assertFalse(Object.isSealed(array)); // has array[1] | ||
assertFalse(Object.isFrozen(array)); | ||
delete array[1]; | ||
assertTrue(Object.isSealed(array)); | ||
assertFalse(Object.isFrozen(array)); // length is writable still | ||
Object.defineProperty(array, 'length', { length: 2, writable: false }); | ||
assertTrue(Object.isSealed(array)); | ||
assertTrue(Object.isFrozen(array)); |