From abfe031a96512945b6f3389d54ade1dec37ea34a 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 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/parser/__tests__/source.spec.ts b/src/parser/__tests__/source.spec.ts index c5ed1e0e..95947170 100644 --- a/src/parser/__tests__/source.spec.ts +++ b/src/parser/__tests__/source.spec.ts @@ -1707,6 +1707,7 @@ describe('SonicWeave parser', () => { expect(scale).toEqual([ 'MOS {LLLLLLs;L=9/8;s=524288/531441}', '9/8', + '81/64', '729/512', '6561/4096', @@ -2061,4 +2062,28 @@ describe('SonicWeave parser', () => { `); expect(truth).toEqual(expand('true')); }); + + it('captures outside variables in block expressions', () => { + const truth = expand(`{ + const octave = 2; + const fifth = 3/2; + const pentic = { + (fifth ^ 2) / octave + (fifth ^ 4) / (octave ^ 2) + fifth + (fifth ^ 3) / octave + octave + }; + pentic; + }`); + expect(truth).toEqual( + expand(`{ + 9/8 + 81/64 + 3/2 + 27/16 + 2 + }`) + ); + }); });