Files
scriptc/tests/corpus/native-array-frozen-noops.js
Chris Tate f8906d0b75 Expand static native object and array semantics (#569)
* Support primitive and function property descriptors

* Dispatch literal bracket calls to native class methods

* Handle numeric class method keys in bracket calls

* Call function values returned by class accessors

* Expand native object and array semantics

* Keep new corpus fixtures aligned with compiler gates

* Lower Object.isFrozen arguments once
2026-09-29 08:30:54 -05:00

22 lines
945 B
JavaScript

const empty = JSON.parse('[]');
Object.freeze(empty);
console.log(empty.sort().length, empty.reverse().length);
console.log(empty.fill(4).length, empty.copyWithin(0, 0).length);
for (const operation of [() => empty.push(), () => empty.pop(), () => empty.shift(), () => empty.unshift(), () => empty.splice(0, 0)]) {
try { operation(); } catch (error) { console.log(error.name); }
}
const one = JSON.parse('[1]');
Object.freeze(one);
console.log(one.sort().join(','), one.reverse().join(','));
console.log(one.fill(9, 0, 0).join(','), one.copyWithin(0, 1).join(','));
try { one.fill(9); } catch (error) { console.log(error.name); }
try { one.copyWithin(0, 0); } catch (error) { console.log(error.name); }
console.log(one.join(','));
const two = JSON.parse('[2,1]');
Object.freeze(two);
try { two.sort(); } catch (error) { console.log(error.name); }
try { two.reverse(); } catch (error) { console.log(error.name); }
console.log(two.join(','));