From 4dc2b197d737a5468a40cb62c5f379d2fbf0762a Mon Sep 17 00:00:00 2001 From: Chinesezjc Date: Sat, 1 Aug 2026 01:55:10 +0800 Subject: [PATCH] test(code-runtime): correct DUNDER_MEMBER edge cases for the __.+__ pattern `____` has an empty middle between the two `__` pairs and does not match `/^__.+__$/`; assert that (not a match) and add `__x__` as the shortest real dunder form that does. --- packages/code-runtime/code-runtime/tests/reserved.spec.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/code-runtime/code-runtime/tests/reserved.spec.ts b/packages/code-runtime/code-runtime/tests/reserved.spec.ts index ccd2c89211..f93b63b5ef 100644 --- a/packages/code-runtime/code-runtime/tests/reserved.spec.ts +++ b/packages/code-runtime/code-runtime/tests/reserved.spec.ts @@ -37,7 +37,10 @@ describe('seam-owned portable identifier exclusions', () => { expect(DUNDER_MEMBER.test('__mid')).toBe(false) // `__` has an empty middle — not a real CPython dunder, so not matched. expect(DUNDER_MEMBER.test('__')).toBe(false) - expect(DUNDER_MEMBER.test('____')).toBe(true) + // `____` also has an empty middle between the two `__` pairs — not matched. + expect(DUNDER_MEMBER.test('____')).toBe(false) + // A single character between the pairs is the shortest real dunder form. + expect(DUNDER_MEMBER.test('__x__')).toBe(true) }) it('PORTABLE_RESERVED_WORDS is the union of ECMAScript and Python reserved words', () => {