Prechádzať zdrojové kódy

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.
Chinesezjc 1 mesiac pred
rodič
commit
4dc2b197d7

+ 4 - 1
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', () => {