Conversation
gibson042
left a comment
There was a problem hiding this comment.
@phoddie This is pretty noisy right now; please fix the lint issues:
- Add necessary front matter fields
- Update features.txt
- Fix the copyrights to a single year rather than a range
- etc.
|
Sure, will do. FWIW – "Fix the copyrights to a single year rather than a range" feels artificial. |
|
It's not; it ensures that the range doesn't need to be updated every year. |
|
Rebasing on main will also get the annotation improvements from #4449. |
??? The range only needs to be updated in years when the tests are modified, not when the calendar advances. Anyway. I will change the tests to conform with this peculiar requirement. |
|
The linter is now happy and I've attempted to resolve all comments. |
There was a problem hiding this comment.
I am a champion of the proposal and will not formally approve this PR would appreciate attention from other maintainers, but I have reviewed it and confirmed consistency with the proposal. Followups are expected to cover error handling and ArrayBuffer.prototype.sliceToImmutable, but this LGTM.
| var immutable = Object.getOwnPropertyDescriptor( | ||
| ArrayBuffer.prototype, "immutable" | ||
| ); | ||
|
|
||
| var getter = immutable.get; |
There was a problem hiding this comment.
Nit:
| var immutable = Object.getOwnPropertyDescriptor( | |
| ArrayBuffer.prototype, "immutable" | |
| ); | |
| var getter = immutable.get; | |
| var getter = Object.getOwnPropertyDescriptor( | |
| ArrayBuffer.prototype, "immutable" | |
| ).get; | |
| var immutable = Object.getOwnPropertyDescriptor( | ||
| ArrayBuffer.prototype, "immutable" | ||
| ); | ||
|
|
||
| var getter = immutable.get; |
There was a problem hiding this comment.
Nit:
| var immutable = Object.getOwnPropertyDescriptor( | |
| ArrayBuffer.prototype, "immutable" | |
| ); | |
| var getter = immutable.get; | |
| var getter = Object.getOwnPropertyDescriptor( | |
| ArrayBuffer.prototype, "immutable" | |
| ).get; | |
anba
left a comment
There was a problem hiding this comment.
There is still a bit of missing coverage:
ArrayBuffer.prototype.sliceToImmutable
- Missing coverage.
Atomics
- Missing coverage.
ArrayBuffer.prototype.resize
ArrayBuffer.prototype.slice
ArrayBuffer.prototype.transfer
ArrayBuffer.prototype.transferToFixedLength
ArrayBuffer.prototype.transferToImmutable
- Ensure throws with immutable ArrayBuffer.
ArrayBuffer.prototype.byteLength
ArrayBuffer.prototype.detached
ArrayBuffer.prototype.maxByteLength
ArrayBuffer.prototype.resizable
- Explicit tests calling with immutable ArrayBuffer instead of just as part of other tests?
DataView:
- Use throwing conversion to ensure TypeError is thrown before coercing index parameter.
%TypedArray%.prototype.filter
%TypedArray%.prototype.map
%TypedArray%.prototype.slice
%TypedArray%.prototype.subarray
- Species create returning TypedArray with immutable ArrayBuffer.
%TypedArray%.from
%TypedArray%.of
- Constructor returns TypedArray with immutable ArrayBuffer.
%TypedArray%.prototype.subarray
- Throws for immutable TypedArray before coercing
offsetparameter.
TypedArray [[Set]] coverage:
- Add
Reflect.setcoverage. - Ensure no value coercion for immutable TypedArrays.
- Ensure correct behaviour when
receiverisn't the current object. - Test out-bounds indices.
| var sample = new DataView(buffer.transferToImmutable(), 0); | ||
|
|
||
| assert.throws(TypeError, function() { | ||
| sample.setFloat16(0, 0n); |
There was a problem hiding this comment.
| sample.setFloat16(0, 0n); | |
| sample.setFloat16(0, 0); |
| var sample = new DataView(buffer.transferToImmutable(), 0); | ||
|
|
||
| assert.throws(TypeError, function() { | ||
| sample.setFloat32(0, 0n); |
There was a problem hiding this comment.
| sample.setFloat32(0, 0n); | |
| sample.setFloat32(0, 0); |
| var sample = new DataView(buffer.transferToImmutable(), 0); | ||
|
|
||
| assert.throws(TypeError, function() { | ||
| sample.setFloat64(0, 0n); |
There was a problem hiding this comment.
| sample.setFloat64(0, 0n); | |
| sample.setFloat64(0, 0); |
| var sample = new DataView(buffer.transferToImmutable(), 0); | ||
|
|
||
| assert.throws(TypeError, function() { | ||
| sample.setInt16(0, 0n); |
There was a problem hiding this comment.
| sample.setInt16(0, 0n); | |
| sample.setInt16(0, 0); |
| var sample = new DataView(buffer.transferToImmutable(), 0); | ||
|
|
||
| assert.throws(TypeError, function() { | ||
| sample.setInt32(0, 0n); |
There was a problem hiding this comment.
| sample.setInt32(0, 0n); | |
| sample.setInt32(0, 0); |
| var buffer = new ArrayBuffer(42 * TA.BYTES_PER_ELEMENT); | ||
| var sample = new TA(buffer.transferToImmutable()); | ||
| assert.throws(TypeError, function() { | ||
| Reflect.defineProperty(sample, "0", desc); |
There was a problem hiding this comment.
| Reflect.defineProperty(sample, "0", desc); | |
| Object.defineProperty(sample, "0", desc); |
Because Reflect.defineProperty returns false on failure. But also add a separate test for Reflect.defineProperty. And add coverage when desc has the current property descriptor attributes. For example:
js> ta = new Int8Array(new ArrayBuffer(1).transferToImmutable())
({0:0})
js> Reflect.defineProperty(ta, 0, {})
true
js> Reflect.defineProperty(ta, 0, {writable: false})
true
js> Reflect.defineProperty(ta, 0, {writable: true})
false
js> Reflect.defineProperty(ta, 0, {value: 1})
false
js> Reflect.defineProperty(ta, 0, {value: 0})
true
js> Reflect.defineProperty(ta, 0, {value: 0, writable: false, enumerable: true, configurable: false})
true
js> Reflect.defineProperty(ta, 0, {value: 1, writable: false, enumerable: true, configurable: false})
falseAnd probably also for floating point special cases NaN or -0 to ensure SameValue semantics are used:
js> ta = new Float64Array(new Float64Array([NaN]).buffer.transferToImmutable())
({0:NaN})
js> Reflect.defineProperty(ta, 0, {value: NaN})
true
js> ta = new Float64Array(new Float64Array([-0]).buffer.transferToImmutable())
({0:-0})
js> Reflect.defineProperty(ta, 0, {value: -0})
true
js> Reflect.defineProperty(ta, 0, {value: +0})
false| // Copyright (C) 2025 Moddable Tech, Inc. All rights reserved. | ||
| // This code is governed by the BSD license found in the LICENSE file. | ||
| /*--- | ||
| description: Reflect.defineProperty throws on indexed property if buffer is immutable |
There was a problem hiding this comment.
| description: Reflect.defineProperty throws on indexed property if buffer is immutable | |
| description: Object.defineProperty throws on indexed property if buffer is immutable |
| description: Reflect.defineProperty throws on indexed property if buffer is immutable | ||
| esid: sec-integer-indexed-exotic-objects-defineownproperty-p-desc | ||
| includes: [testTypedArray.js] | ||
| features: [Reflect, TypedArray, immutable-arraybuffer] |
There was a problem hiding this comment.
| features: [Reflect, TypedArray, immutable-arraybuffer] | |
| features: [TypedArray, immutable-arraybuffer] |
| description: setting indexed property throws if buffer is immutable | ||
| esid: sec-integer-indexed-exotic-objects-set-p-v-receiver | ||
| includes: [testTypedArray.js] | ||
| features: [TypedArray, immutable-arraybuffer] |
There was a problem hiding this comment.
Missing flags: [onlyStrict]. But please also add a flags: [noStrict] test which ensure no TypeError is thrown.
| var sample = new TA(buffer.transferToImmutable()); | ||
| assert.throws(TypeError, function() { | ||
| sample[0] = 1; | ||
| }); |
There was a problem hiding this comment.
Also assert assert.sameValue(sample[0], 0) to ensure no modification took place.
|
Thanks for the review @anba. This is very helpful. I'd prefer not to make this PR any bigger so let's not fix the missing coverage here, instead please consider opening an issue with a testing plan. |
|
The helpful feedback from @anba have been applied. As per discussion with @gibson042, we'll break this up into multiple PRs based on the test plan, when available. |
…spidermonkey-reviewers,dminor Test262 PR: <tc39/test262#4445>. Roughly half of the spec proposal is still missing coverage, see the review notes at <tc39/test262#4445 (review)>. Differential Revision: https://phabricator.services.mozilla.com/D249415
…spidermonkey-reviewers,dminor Test262 PR: <tc39/test262#4445>. Roughly half of the spec proposal is still missing coverage, see the review notes at <tc39/test262#4445 (review)>. Differential Revision: https://phabricator.services.mozilla.com/D249415
…spidermonkey-reviewers,dminor Test262 PR: <tc39/test262#4445>. Roughly half of the spec proposal is still missing coverage, see the review notes at <tc39/test262#4445 (review)>. Differential Revision: https://phabricator.services.mozilla.com/D249415
…spidermonkey-reviewers,dminor Test262 PR: <tc39/test262#4445>. Roughly half of the spec proposal is still missing coverage, see the review notes at <tc39/test262#4445 (review)>. Differential Revision: https://phabricator.services.mozilla.com/D249415
…spidermonkey-reviewers,dminor Test262 PR: <tc39/test262#4445>. Roughly half of the spec proposal is still missing coverage, see the review notes at <tc39/test262#4445 (review)>. Differential Revision: https://phabricator.services.mozilla.com/D249415 UltraBlame original commit: a2125b80c39422a420f5eae283f045d8d98d13ee
…spidermonkey-reviewers,dminor Test262 PR: <tc39/test262#4445>. Roughly half of the spec proposal is still missing coverage, see the review notes at <tc39/test262#4445 (review)>. Differential Revision: https://phabricator.services.mozilla.com/D249415 UltraBlame original commit: 8b6221835a28784ac50521fe790e6521aea5572e
…spidermonkey-reviewers,dminor Test262 PR: <tc39/test262#4445>. Roughly half of the spec proposal is still missing coverage, see the review notes at <tc39/test262#4445 (review)>. Differential Revision: https://phabricator.services.mozilla.com/D249415 UltraBlame original commit: a2125b80c39422a420f5eae283f045d8d98d13ee
…spidermonkey-reviewers,dminor Test262 PR: <tc39/test262#4445>. Roughly half of the spec proposal is still missing coverage, see the review notes at <tc39/test262#4445 (review)>. Differential Revision: https://phabricator.services.mozilla.com/D249415 UltraBlame original commit: 8b6221835a28784ac50521fe790e6521aea5572e
…spidermonkey-reviewers,dminor Test262 PR: <tc39/test262#4445>. Roughly half of the spec proposal is still missing coverage, see the review notes at <tc39/test262#4445 (review)>. Differential Revision: https://phabricator.services.mozilla.com/D249415 UltraBlame original commit: a2125b80c39422a420f5eae283f045d8d98d13ee
…spidermonkey-reviewers,dminor Test262 PR: <tc39/test262#4445>. Roughly half of the spec proposal is still missing coverage, see the review notes at <tc39/test262#4445 (review)>. Differential Revision: https://phabricator.services.mozilla.com/D249415 UltraBlame original commit: 8b6221835a28784ac50521fe790e6521aea5572e
|
The changes of this PR have now been incorporated into scoped PRs linked to from the test plan. |
Suite of test262 tests for the Immutable ArrayBuffer proposal.