From 29226bca2517512e7942146947c3474a8679708a Mon Sep 17 00:00:00 2001 From: mgreminger Date: Mon, 23 Dec 2024 00:29:47 -0600 Subject: [PATCH] fix: fix interpolation function plotting bug Since lower limit unit check always occurred at x=1 for unitless lower limit, an error occurred if 1 was outside of the interpolation range --- src/parser/LatexToSympy.ts | 6 ++---- tests/test_data_table.spec.mjs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/parser/LatexToSympy.ts b/src/parser/LatexToSympy.ts index de31d231..9986b70e 100644 --- a/src/parser/LatexToSympy.ts +++ b/src/parser/LatexToSympy.ts @@ -1282,7 +1282,7 @@ export class LatexToSympy extends LatexParserVisitor { let content = await page.textContent(`#result-value-1`); expect(content).toBe(String.raw`\begin{bmatrix} 2\left\lbrack m\right\rbrack \\ 4\left\lbrack m\right\rbrack \\ 8\left\lbrack m\right\rbrack \end{bmatrix}`); +}); + +test('Test linear interpolation with plotting', async () => { + const modifierKey = (await page.evaluate('window.modifierKey') )=== "metaKey" ? "Meta" : "Control"; + + await page.locator('#add-data-table-cell').click(); + + await page.locator('#data-table-input-1-0-0').click(); + + await page.keyboard.type('10'); + await page.keyboard.press('Tab'); + await page.keyboard.type('1'); + await page.keyboard.press('Enter'); + + await page.keyboard.type('20'); + await page.keyboard.press('Tab'); + await page.keyboard.type('2'); + await page.keyboard.press('Enter'); + + await page.keyboard.type('30'); + await page.keyboard.press('Tab'); + await page.keyboard.type('3'); + + await page.getByRole('button', { name: 'Add Interpolation' }).click(); + await page.getByLabel('Copy function name to').click(); + + await page.locator('#cell-0 >> math-field.editable').type('(x,'); + await page.locator('#cell-0 >> math-field.editable').press(modifierKey+'+v'); + await page.locator('#cell-0 >> math-field.editable').type('(x)) for (10<=x<=30)='); + + await page.waitForSelector('div.status-footer', {state: 'detached'}); + await expect(page.locator('g.trace.scatter')).toBeVisible(); }); \ No newline at end of file