From 6eeda477ae206bdefffeec3bd01cc3c89734dd32 Mon Sep 17 00:00:00 2001 From: inthar-raven Date: Mon, 17 Jun 2024 17:14:47 -0400 Subject: [PATCH] Add test: captures outside variables in block expressions --- src/parser/__tests__/source.spec.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/parser/__tests__/source.spec.ts b/src/parser/__tests__/source.spec.ts index c5ed1e0e..658fdbd9 100644 --- a/src/parser/__tests__/source.spec.ts +++ b/src/parser/__tests__/source.spec.ts @@ -2061,4 +2061,28 @@ describe('SonicWeave parser', () => { `); expect(truth).toEqual(expand('true')); }); + + it('captures outside variables in block expressions', () => { + const pentic = expand(`{ + const octave = 2; + const fifth = 3/2; + const pentic = { + (fifth ^ 2) / octave + (fifth ^ 4) / (octave ^ 2) + fifth + (fifth ^ 3) / octave + octave + }; + pentic; + }`); + expect(pentic).toEqual( + expand(`{ + 9/8 + 81/64 + 3/2 + 27/16 + 2 + }`) + ); + }); });