Skip to content

Commit 158bcd4

Browse files
sunnylqmclaude
andcommitted
test(hermes-base): run the wide DefineOwnById case on v98 only
Classic Hermes has no DefineOwnById: the same object literal compiles to PutNewOwnById, and both of its widths print the property text, so there is no asymmetry to reproduce on v96. Verified against RN 0.77.3's hermesc, where the case is now skipped and the rest of the file passes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 4ae45cc commit 158bcd4

1 file changed

Lines changed: 29 additions & 23 deletions

File tree

‎tests/hermes-raw.test.ts‎

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -242,29 +242,35 @@ describe.if(hasHermesc)('lossless Hermes operand audit (real compiler)', () => {
242242
// budget. A base whose string table spills past 16 bits makes the delta
243243
// build take the Long form, which used to read as a difference and threw
244244
// away a good base for any property name longer than the budget.
245-
test('a wide DefineOwnById against a foreign base is not a difference', async () => {
246-
const base = compile(
247-
'wide-base',
248-
Array.from(
249-
{ length: 70000 },
250-
(_, i) => `globalThis.s${i} = "base string ${i}";`,
251-
).join('\n'),
252-
);
253-
const source =
254-
'globalThis.h = function h(s, v){ return {...s, promotionRequestItemId: v, b: 1}; };';
255-
const plain = compile('wide-plain', source);
256-
const delta = compile('wide-delta', source, base);
257-
const pretty = (file: string) =>
258-
dump(file, true)
259-
.split('\n')
260-
.filter((line) => line.includes('DefineOwnById'));
261-
// the renderings really are the two the fold has to bridge
262-
expect(pretty(delta)[0]).toContain('DefineOwnByIdLong');
263-
expect(pretty(delta)[0]).toContain('"promotionRequestI"...');
264-
expect(pretty(plain)[0]).not.toContain('promotionRequest');
265-
const result = await compareHermesBytecode(hermesc!, delta, plain);
266-
expect(result.status, result.detail).toBe('equivalent');
267-
}, 30_000);
245+
// v96 and older print the text for both widths of PutNewOwnById, so only
246+
// v98's DefineOwnById carries the asymmetry.
247+
test.skipIf(!hasHermesc || probeHbcVersion(hermesc!) !== 98)(
248+
'a wide DefineOwnById against a foreign base is not a difference',
249+
async () => {
250+
const base = compile(
251+
'wide-base',
252+
Array.from(
253+
{ length: 70000 },
254+
(_, i) => `globalThis.s${i} = "base string ${i}";`,
255+
).join('\n'),
256+
);
257+
const source =
258+
'globalThis.h = function h(s, v){ return {...s, promotionRequestItemId: v, b: 1}; };';
259+
const plain = compile('wide-plain', source);
260+
const delta = compile('wide-delta', source, base);
261+
const pretty = (file: string) =>
262+
dump(file, true)
263+
.split('\n')
264+
.filter((line) => line.includes('DefineOwnById'));
265+
// the renderings really are the two the fold has to bridge
266+
expect(pretty(delta)[0]).toContain('DefineOwnByIdLong');
267+
expect(pretty(delta)[0]).toContain('"promotionRequestI"...');
268+
expect(pretty(plain)[0]).not.toContain('promotionRequest');
269+
const result = await compareHermesBytecode(hermesc!, delta, plain);
270+
expect(result.status, result.detail).toBe('equivalent');
271+
},
272+
30_000,
273+
);
268274

269275
test('a property name past the pretty limit still has to match', async () => {
270276
const object = (name: string) =>

0 commit comments

Comments
 (0)