Fix spyOn restore descriptor for re-spying#397
Conversation
📝 WalkthroughWalkthroughModified the spy/restore mechanism to preserve and restore the full original property descriptor instead of reconstructing it, ensuring that Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
source/units/Goccia.Builtins.TestingLibrary.Test.pas (1)
3500-3503: Prefer asserting the restored flags through the public Object API.This part of the test now depends on
TGocciaObjectValue.GetOwnPropertyDescriptor/TGocciaPropertyDescriptorrather than the user-visible surface. If you want to keep the flag check, exercisingObject.getOwnPropertyDescriptorhere would preserve the coverage without coupling the test to descriptor internals.Based on learnings, native Pascal tests should stay focused on visible public behavior where possible and keep implementation details private.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@source/units/Goccia.Builtins.TestingLibrary.Test.pas` around lines 3500 - 3503, The test inspects property flags via internal types (TGocciaObjectValue.GetOwnPropertyDescriptor / TGocciaPropertyDescriptor) — change it to assert flags using the public JS API by calling Object.getOwnPropertyDescriptor(Obj, 'method') and then checking the returned descriptor's configurable/writable/enumerable via the public surface (the result of Object.getOwnPropertyDescriptor) instead of referencing Descriptor or TGocciaPropertyDescriptor; update the Expect<Boolean>(...) assertions to read from the JS API result and remove direct uses of GetOwnPropertyDescriptor and TGocciaPropertyDescriptor so the test relies only on visible Object API behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@source/units/Goccia.Builtins.TestingLibrary.Test.pas`:
- Around line 3500-3503: The test inspects property flags via internal types
(TGocciaObjectValue.GetOwnPropertyDescriptor / TGocciaPropertyDescriptor) —
change it to assert flags using the public JS API by calling
Object.getOwnPropertyDescriptor(Obj, 'method') and then checking the returned
descriptor's configurable/writable/enumerable via the public surface (the result
of Object.getOwnPropertyDescriptor) instead of referencing Descriptor or
TGocciaPropertyDescriptor; update the Expect<Boolean>(...) assertions to read
from the JS API result and remove direct uses of GetOwnPropertyDescriptor and
TGocciaPropertyDescriptor so the test relies only on visible Object API
behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4955afc3-233f-48a0-b462-b878dd1b54b6
📒 Files selected for processing (2)
source/units/Goccia.Builtins.TestingLibrary.Test.passource/units/Goccia.Values.MockFunction.pas
Benchmark Results386 benchmarks Interpreted: 🟢 292 improved · 🔴 16 regressed · 78 unchanged · avg +7.1% arraybuffer.js — Interp: 🟢 11, 3 unch. · avg +5.8% · Bytecode: 🔴 13, 1 unch. · avg -21.2%
arrays.js — Interp: 🟢 16, 3 unch. · avg +9.2% · Bytecode: 🔴 19 · avg -20.7%
async-await.js — Interp: 🟢 3, 3 unch. · avg +4.2% · Bytecode: 🔴 4, 2 unch. · avg -20.0%
base64.js — Interp: 🟢 8, 2 unch. · avg +8.3% · Bytecode: 🔴 10 · avg -22.3%
classes.js — Interp: 🟢 20, 🔴 1, 10 unch. · avg +4.9% · Bytecode: 🔴 31 · avg -18.2%
closures.js — Interp: 🟢 11 · avg +9.8% · Bytecode: 🔴 11 · avg -19.3%
collections.js — Interp: 🟢 12 · avg +11.2% · Bytecode: 🔴 12 · avg -21.1%
csv.js — Interp: 🟢 13 · avg +11.2% · Bytecode: 🔴 13 · avg -21.0%
destructuring.js — Interp: 🟢 18, 4 unch. · avg +5.3% · Bytecode: 🔴 22 · avg -19.8%
fibonacci.js — Interp: 🟢 8 · avg +8.1% · Bytecode: 🔴 8 · avg -19.6%
float16array.js — Interp: 🟢 24, 🔴 4, 4 unch. · avg +3.7% · Bytecode: 🔴 32 · avg -20.4%
for-of.js — Interp: 🟢 4, 🔴 1, 2 unch. · avg +2.2% · Bytecode: 🔴 7 · avg -19.4%
helpers/bench-module.js — Interp: 0 · Bytecode: 0
iterators.js — Interp: 🟢 28, 14 unch. · avg +5.1% · Bytecode: 🔴 42 · avg -19.7%
json.js — Interp: 🟢 18, 2 unch. · avg +9.4% · Bytecode: 🔴 20 · avg -17.4%
jsx.jsx — Interp: 🟢 13, 8 unch. · avg +4.4% · Bytecode: 🔴 21 · avg -21.5%
modules.js — Interp: 🟢 9 · avg +8.3% · Bytecode: 🔴 9 · avg -21.1%
numbers.js — Interp: 🟢 10, 1 unch. · avg +10.0% · Bytecode: 🔴 11 · avg -21.0%
objects.js — Interp: 🟢 3, 4 unch. · avg +2.8% · Bytecode: 🔴 7 · avg -13.8%
promises.js — Interp: 🟢 4, 8 unch. · avg +2.1% · Bytecode: 🔴 12 · avg -18.1%
regexp.js — Interp: 🟢 10, 1 unch. · avg +10.4% · Bytecode: 🔴 11 · avg -16.9%
strings.js — Interp: 🟢 17, 2 unch. · avg +13.3% · Bytecode: 🔴 19 · avg -21.2%
tsv.js — Interp: 🟢 8, 1 unch. · avg +7.9% · Bytecode: 🔴 9 · avg -19.9%
typed-arrays.js — Interp: 🟢 14, 🔴 5, 3 unch. · avg +2.5% · Bytecode: 🔴 22 · avg -22.0%
uint8array-encoding.js — Interp: 🟢 10, 🔴 5, 3 unch. · avg +16.6% · Bytecode: 🟢 3, 🔴 15 · avg -13.4%
Measured on ubuntu-latest x64. Benchmark ranges compare cached main-branch min/max ops/sec with the PR run; overlapping ranges are treated as unchanged noise. Percentage deltas are secondary context. |
Suite Timing
Measured on ubuntu-latest x64. |
Summary
Testing
Additional checks: