diff --git a/.github/ci-cd-scripts/playwright-browser-chrome.sh b/.github/ci-cd-scripts/playwright-browser-chrome.sh index 676529d203..cba1d43fb4 100755 --- a/.github/ci-cd-scripts/playwright-browser-chrome.sh +++ b/.github/ci-cd-scripts/playwright-browser-chrome.sh @@ -4,9 +4,9 @@ set -euo pipefail if [[ ! -f "test-results/.last-run.json" ]]; then # if no last run artifact, than run plawright normally echo "run playwright normally" - if [[ "$3" == "ubuntu-latest" ]]; then + if [[ "$3" == ubuntu-latest* ]]; then yarn test:playwright:browser:chrome:ubuntu -- --shard=$1/$2 || true - elif [[ "$3" == "windows-latest" ]]; then + elif [[ "$3" == windows-latest* ]]; then yarn test:playwright:browser:chrome:windows -- --shard=$1/$2 || true else echo "Do not run playwright. Unable to detect os runtime." @@ -26,9 +26,9 @@ while [[ $retry -le $max_retrys ]]; do if [[ $failed_tests -gt 0 ]]; then echo "retried=true" >>$GITHUB_OUTPUT echo "run playwright with last failed tests and retry $retry" - if [[ "$3" == "ubuntu-latest" ]]; then + if [[ "$3" == ubuntu-latest* ]]; then yarn test:playwright:browser:chrome:ubuntu -- --last-failed || true - elif [[ "$3" == "windows-latest" ]]; then + elif [[ "$3" == windows-latest* ]]; then yarn test:playwright:browser:chrome:windows -- --last-failed || true else echo "Do not run playwright. Unable to detect os runtime." diff --git a/.github/ci-cd-scripts/playwright-electron.sh b/.github/ci-cd-scripts/playwright-electron.sh index f447b5a883..08b173bb83 100755 --- a/.github/ci-cd-scripts/playwright-electron.sh +++ b/.github/ci-cd-scripts/playwright-electron.sh @@ -4,11 +4,11 @@ set -euo pipefail if [[ ! -f "test-results/.last-run.json" ]]; then # if no last run artifact, than run plawright normally echo "run playwright normally" - if [[ "$1" == "ubuntu-latest" ]]; then + if [[ "$1" == ubuntu-latest* ]]; then xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn test:playwright:electron:ubuntu || true - elif [[ "$1" == "windows-latest" ]]; then + elif [[ "$1" == windows-latest* ]]; then yarn test:playwright:electron:windows || true - elif [[ "$1" == "macos-14" ]]; then + elif [[ "$1" == macos-14* ]]; then yarn test:playwright:electron:macos || true else echo "Do not run playwright. Unable to detect os runtime." @@ -28,11 +28,11 @@ while [[ $retry -le $max_retrys ]]; do if [[ $failed_tests -gt 0 ]]; then echo "retried=true" >>$GITHUB_OUTPUT echo "run playwright with last failed tests and retry $retry" - if [[ "$1" == "ubuntu-latest" ]]; then + if [[ "$1" == ubuntu-latest* ]]; then xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn test:playwright:electron:ubuntu -- --last-failed || true - elif [[ "$1" == "windows-latest" ]]; then + elif [[ "$1" == windows-latest* ]]; then yarn test:playwright:electron:windows -- --last-failed || true - elif [[ "$1" == "macos-14" ]]; then + elif [[ "$1" == macos-14* ]]; then yarn test:playwright:electron:macos -- --last-failed || true else echo "Do not run playwright. Unable to detect os runtime." diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 78daa5a1e5..ad2fd25a5a 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -39,7 +39,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest-8-cores, windows-latest-8-cores] shardIndex: [1, 2, 3, 4] shardTotal: [4] runs-on: ${{ matrix.os }} @@ -227,7 +227,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-14] + os: [ubuntu-latest-8-cores, windows-latest-8-cores, macos-14-large] timeout-minutes: 60 runs-on: ${{ matrix.os }} needs: check-rust-changes @@ -287,7 +287,7 @@ jobs: brew install gnu-sed echo "/opt/homebrew/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH - name: Install vector - if: ${{ !startsWith(matrix.os, 'windows') }} + if: ${{ startsWith(matrix.os, 'ubuntu') }} shell: bash run: | curl --proto '=https' --tlsv1.2 -sSfL https://sh.vector.dev > /tmp/vector.sh diff --git a/e2e/playwright/editor-tests.spec.ts b/e2e/playwright/editor-tests.spec.ts index b787118a58..8a42d026ee 100644 --- a/e2e/playwright/editor-tests.spec.ts +++ b/e2e/playwright/editor-tests.spec.ts @@ -985,7 +985,7 @@ test.describe('Editor tests', () => { |> extrude(5, %)`) }) - test( + test.fixme( `Can use the import stdlib function on a local OBJ file`, { tag: '@electron' }, async ({ browserName }, testInfo) => { diff --git a/e2e/playwright/file-tree.spec.ts b/e2e/playwright/file-tree.spec.ts index 96252bd9e8..384358708d 100644 --- a/e2e/playwright/file-tree.spec.ts +++ b/e2e/playwright/file-tree.spec.ts @@ -109,7 +109,7 @@ test.describe('when using the file tree to', () => { const fromFile = 'main.kcl' const toFile = 'hello.kcl' - test( + test.fixme( `rename ${fromFile} to ${toFile}, and doesn't crash on reload and settings load`, { tag: '@electron' }, async ({ browser: _, tronApp }, testInfo) => { @@ -157,7 +157,7 @@ test.describe('when using the file tree to', () => { } ) - test( + test.fixme( `create many new untitled files they increment their names`, { tag: '@electron' }, async ({ browser: _, tronApp }, testInfo) => { @@ -298,7 +298,7 @@ test.describe('when using the file tree to', () => { } ) - test( + test.fixme( 'loading small file, then large, then back to small', { tag: '@electron', diff --git a/e2e/playwright/projects.spec.ts b/e2e/playwright/projects.spec.ts index e45c173b74..5b1b6a6eed 100644 --- a/e2e/playwright/projects.spec.ts +++ b/e2e/playwright/projects.spec.ts @@ -854,7 +854,7 @@ test( } ) -test( +test.fixme( 'Deleting projects, can delete individual project, can still create projects after deleting all', { tag: '@electron' }, async ({ browserName }, testInfo) => { diff --git a/e2e/playwright/snapshot-tests.spec.ts b/e2e/playwright/snapshot-tests.spec.ts index 34dd1f543c..7b87ccdb96 100644 --- a/e2e/playwright/snapshot-tests.spec.ts +++ b/e2e/playwright/snapshot-tests.spec.ts @@ -1031,7 +1031,7 @@ test.describe('Grid visibility', { tag: '@snapshot' }, () => { }) }) -test('theme persists', async ({ page, context }) => { +test.fixme('theme persists', async ({ page, context }) => { const u = await getUtils(page) await context.addInitScript(async () => { localStorage.setItem( diff --git a/e2e/playwright/testing-settings.spec.ts b/e2e/playwright/testing-settings.spec.ts index 40c0fa6f38..4156d67eed 100644 --- a/e2e/playwright/testing-settings.spec.ts +++ b/e2e/playwright/testing-settings.spec.ts @@ -415,7 +415,7 @@ test.describe('Testing settings', () => { ) // It was much easier to test the logo color than the background stream color. - test( + test.fixme( 'user settings reload on external change, on project and modeling view', { tag: '@electron' }, async ({ browserName }, testInfo) => { diff --git a/e2e/playwright/various.spec.ts b/e2e/playwright/various.spec.ts index f606055f5e..e2ce531384 100644 --- a/e2e/playwright/various.spec.ts +++ b/e2e/playwright/various.spec.ts @@ -256,181 +256,186 @@ test('First escape in tool pops you out of tool, second exits sketch mode', asyn ).not.toBeVisible() }) -test('Basic default modeling and sketch hotkeys work', async ({ page }) => { - const u = await getUtils(page) - - // This test can run long if it takes a little too long to load - // the engine. - test.setTimeout(90000) - // This test has a weird bug on ubuntu - test.skip( - process.platform === 'linux', - 'weird playwright bug on ubuntu https://github.com/KittyCAD/modeling-app/issues/2444' - ) - // Load the app with the code pane open - - await test.step(`Set up test`, async () => { - await page.addInitScript(async () => { - localStorage.setItem( - 'store', - JSON.stringify({ - state: { - openPanes: ['code'], - }, - version: 0, - }) - ) +test.fixme( + 'Basic default modeling and sketch hotkeys work', + async ({ page }) => { + const u = await getUtils(page) + + // This test can run long if it takes a little too long to load + // the engine. + test.setTimeout(90000) + // This test has a weird bug on ubuntu + // Funny, it's flaking on Windows too :). I think there is just something + // actually wrong. + test.skip( + process.platform === 'linux', + 'weird playwright bug on ubuntu https://github.com/KittyCAD/modeling-app/issues/2444' + ) + // Load the app with the code pane open + + await test.step(`Set up test`, async () => { + await page.addInitScript(async () => { + localStorage.setItem( + 'store', + JSON.stringify({ + state: { + openPanes: ['code'], + }, + version: 0, + }) + ) + }) + await page.setViewportSize({ width: 1200, height: 500 }) + await u.waitForAuthSkipAppStart() + await u.openDebugPanel() + await u.expectCmdLog('[data-message-type="execution-done"]') + await u.closeDebugPanel() }) - await page.setViewportSize({ width: 1200, height: 500 }) - await u.waitForAuthSkipAppStart() - await u.openDebugPanel() - await u.expectCmdLog('[data-message-type="execution-done"]') - await u.closeDebugPanel() - }) - const codePane = page.locator('.cm-content') - const lineButton = page.getByRole('button', { - name: 'line Line', - exact: true, - }) - const arcButton = page.getByRole('button', { - name: 'arc Tangential Arc', - exact: true, - }) - const extrudeButton = page.getByRole('button', { name: 'Extrude' }) - const commandBarComboBox = page.getByPlaceholder('Search commands') - const exitSketchButton = page.getByRole('button', { name: 'Exit Sketch' }) - - await test.step(`Type code with modeling hotkeys, shouldn't fire`, async () => { - await codePane.click() - await page.keyboard.type('//') - await page.keyboard.press('s') - await expect(commandBarComboBox).not.toBeVisible() - await page.keyboard.press('e') - await expect(commandBarComboBox).not.toBeVisible() - await expect(codePane).toHaveText('//se') - }) - - // Blur focus from the code editor, use the s command to sketch - await test.step(`Blur editor focus, enter sketch`, async () => { - /** - * TODO: There is a bug somewhere that causes this test to fail - * if you toggle the codePane closed before your trigger the - * start of the sketch. - * and a separate Safari-only bug that causes the test to fail - * if the pane is open the entire test. The maintainer of CodeMirror - * has pinpointed this to the unusual browser behavior: - * https://discuss.codemirror.net/t/how-to-force-unfocus-of-the-codemirror-element-in-safari/8095/3 - */ - await blurCodeEditor() - await page.waitForTimeout(1000) - await page.keyboard.press('s') - await page.waitForTimeout(1000) - await page.mouse.move(800, 300, { steps: 5 }) - await page.mouse.click(800, 300) - await page.waitForTimeout(1000) - await expect(lineButton).toHaveAttribute('aria-pressed', 'true', { - timeout: 15_000, + const codePane = page.locator('.cm-content') + const lineButton = page.getByRole('button', { + name: 'line Line', + exact: true, }) - }) - - // Use some sketch hotkeys to create a sketch (l and a for now) - await test.step(`Incomplete sketch with hotkeys`, async () => { - await test.step(`Draw a line`, async () => { - await page.mouse.move(700, 200, { steps: 5 }) - await page.mouse.click(700, 200) - await page.mouse.move(800, 250, { steps: 5 }) - await page.mouse.click(800, 250) + const arcButton = page.getByRole('button', { + name: 'arc Tangential Arc', + exact: true, + }) + const extrudeButton = page.getByRole('button', { name: 'Extrude' }) + const commandBarComboBox = page.getByPlaceholder('Search commands') + const exitSketchButton = page.getByRole('button', { name: 'Exit Sketch' }) + + await test.step(`Type code with modeling hotkeys, shouldn't fire`, async () => { + await codePane.click() + await page.keyboard.type('//') + await page.keyboard.press('s') + await expect(commandBarComboBox).not.toBeVisible() + await page.keyboard.press('e') + await expect(commandBarComboBox).not.toBeVisible() + await expect(codePane).toHaveText('//se') }) - await test.step(`Unequip line tool`, async () => { - await page.keyboard.press('l') - await expect(lineButton).not.toHaveAttribute('aria-pressed', 'true') + // Blur focus from the code editor, use the s command to sketch + await test.step(`Blur editor focus, enter sketch`, async () => { + /** + * TODO: There is a bug somewhere that causes this test to fail + * if you toggle the codePane closed before your trigger the + * start of the sketch. + * and a separate Safari-only bug that causes the test to fail + * if the pane is open the entire test. The maintainer of CodeMirror + * has pinpointed this to the unusual browser behavior: + * https://discuss.codemirror.net/t/how-to-force-unfocus-of-the-codemirror-element-in-safari/8095/3 + */ + await blurCodeEditor() + await page.waitForTimeout(1000) + await page.keyboard.press('s') + await page.waitForTimeout(1000) + await page.mouse.move(800, 300, { steps: 5 }) + await page.mouse.click(800, 300) + await page.waitForTimeout(1000) + await expect(lineButton).toHaveAttribute('aria-pressed', 'true', { + timeout: 15_000, + }) }) - await test.step(`Draw a tangential arc`, async () => { - await page.keyboard.press('a') - await expect(arcButton).toHaveAttribute('aria-pressed', 'true', { - timeout: 10_000, + // Use some sketch hotkeys to create a sketch (l and a for now) + await test.step(`Incomplete sketch with hotkeys`, async () => { + await test.step(`Draw a line`, async () => { + await page.mouse.move(700, 200, { steps: 5 }) + await page.mouse.click(700, 200) + await page.mouse.move(800, 250, { steps: 5 }) + await page.mouse.click(800, 250) + }) + + await test.step(`Unequip line tool`, async () => { + await page.keyboard.press('l') + await expect(lineButton).not.toHaveAttribute('aria-pressed', 'true') + }) + + await test.step(`Draw a tangential arc`, async () => { + await page.keyboard.press('a') + await expect(arcButton).toHaveAttribute('aria-pressed', 'true', { + timeout: 10_000, + }) + await page.mouse.move(1000, 100, { steps: 5 }) + await page.mouse.click(1000, 100) + }) + + await test.step(`Unequip with escape, equip line tool`, async () => { + await page.keyboard.press('Escape') + await page.keyboard.press('l') + await page.waitForTimeout(50) + await expect(lineButton).toHaveAttribute('aria-pressed', 'true') }) - await page.mouse.move(1000, 100, { steps: 5 }) - await page.mouse.click(1000, 100) }) - await test.step(`Unequip with escape, equip line tool`, async () => { - await page.keyboard.press('Escape') + await test.step(`Type code with sketch hotkeys, shouldn't fire`, async () => { + // Since there's code now, we have to get to the end of the line + await page.locator('.cm-line').last().click() + await page.keyboard.down('ControlOrMeta') + await page.keyboard.press('ArrowRight') + await page.keyboard.up('ControlOrMeta') + + await page.keyboard.press('Enter') + await page.keyboard.type('//') await page.keyboard.press('l') - await page.waitForTimeout(50) await expect(lineButton).toHaveAttribute('aria-pressed', 'true') + await page.keyboard.press('a') + await expect(lineButton).toHaveAttribute('aria-pressed', 'true') + await expect(codePane).toContainText('//la') + await page.keyboard.press('Backspace') + await page.keyboard.press('Backspace') + await page.keyboard.press('Backspace') + await page.keyboard.press('Backspace') }) - }) - await test.step(`Type code with sketch hotkeys, shouldn't fire`, async () => { - // Since there's code now, we have to get to the end of the line - await page.locator('.cm-line').last().click() - await page.keyboard.down('ControlOrMeta') - await page.keyboard.press('ArrowRight') - await page.keyboard.up('ControlOrMeta') - - await page.keyboard.press('Enter') - await page.keyboard.type('//') - await page.keyboard.press('l') - await expect(lineButton).toHaveAttribute('aria-pressed', 'true') - await page.keyboard.press('a') - await expect(lineButton).toHaveAttribute('aria-pressed', 'true') - await expect(codePane).toContainText('//la') - await page.keyboard.press('Backspace') - await page.keyboard.press('Backspace') - await page.keyboard.press('Backspace') - await page.keyboard.press('Backspace') - }) - - await test.step(`Close profile and exit sketch`, async () => { - await blurCodeEditor() - await page.mouse.move(700, 200, { steps: 5 }) - await page.mouse.click(700, 200) - // On close it will unequip the line tool. - await expect(lineButton).toHaveAttribute('aria-pressed', 'false') - await expect(exitSketchButton).toBeEnabled() - await page.keyboard.press('Escape') - await expect( - page.getByRole('button', { name: 'Exit Sketch' }) - ).not.toBeVisible() - }) + await test.step(`Close profile and exit sketch`, async () => { + await blurCodeEditor() + await page.mouse.move(700, 200, { steps: 5 }) + await page.mouse.click(700, 200) + // On close it will unequip the line tool. + await expect(lineButton).toHaveAttribute('aria-pressed', 'false') + await expect(exitSketchButton).toBeEnabled() + await page.keyboard.press('Escape') + await expect( + page.getByRole('button', { name: 'Exit Sketch' }) + ).not.toBeVisible() + }) - // Extrude with e - await test.step(`Extrude the sketch`, async () => { - await page.mouse.click(750, 150) - await blurCodeEditor() - await expect(extrudeButton).toBeEnabled() - await page.keyboard.press('e') - await page.waitForTimeout(500) - await page.mouse.move(800, 200, { steps: 5 }) - await page.mouse.click(800, 200) - await expect(page.getByRole('button', { name: 'Continue' })).toBeVisible({ - timeout: 20_000, + // Extrude with e + await test.step(`Extrude the sketch`, async () => { + await page.mouse.click(750, 150) + await blurCodeEditor() + await expect(extrudeButton).toBeEnabled() + await page.keyboard.press('e') + await page.waitForTimeout(500) + await page.mouse.move(800, 200, { steps: 5 }) + await page.mouse.click(800, 200) + await expect(page.getByRole('button', { name: 'Continue' })).toBeVisible({ + timeout: 20_000, + }) + await page.getByRole('button', { name: 'Continue' }).click() + await expect( + page.getByRole('button', { name: 'Submit command' }) + ).toBeVisible() + await page.getByRole('button', { name: 'Submit command' }).click() + await expect(page.locator('.cm-content')).toContainText('extrude(') }) - await page.getByRole('button', { name: 'Continue' }).click() - await expect( - page.getByRole('button', { name: 'Submit command' }) - ).toBeVisible() - await page.getByRole('button', { name: 'Submit command' }).click() - await expect(page.locator('.cm-content')).toContainText('extrude(') - }) - // await codePaneButton.click() - // await expect(u.codeLocator).not.toBeVisible() - - /** - * work-around: to stop `keyboard.press()` from typing in the editor even when it should be blurred - */ - async function blurCodeEditor() { - await page.getByRole('button', { name: 'Commands' }).click() - await page.waitForTimeout(100) - await page.keyboard.press('Escape') - await page.waitForTimeout(100) + // await codePaneButton.click() + // await expect(u.codeLocator).not.toBeVisible() + + /** + * work-around: to stop `keyboard.press()` from typing in the editor even when it should be blurred + */ + async function blurCodeEditor() { + await page.getByRole('button', { name: 'Commands' }).click() + await page.waitForTimeout(100) + await page.keyboard.press('Escape') + await page.waitForTimeout(100) + } } -}) +) test('Delete key does not navigate back', async ({ page }) => { await page.setViewportSize({ width: 1200, height: 500 }) diff --git a/src/wasm-lib/kcl/src/simulation_tests.rs b/src/wasm-lib/kcl/src/simulation_tests.rs index f9d84f9486..cd7b75aa92 100644 --- a/src/wasm-lib/kcl/src/simulation_tests.rs +++ b/src/wasm-lib/kcl/src/simulation_tests.rs @@ -189,3 +189,246 @@ mod double_map_fn { super::execute(TEST_NAME, false).await } } +mod property_of_object { + const TEST_NAME: &str = "property_of_object"; + + /// Test tokenizing KCL. + #[test] + fn tokenize() { + super::tokenize(TEST_NAME) + } + + /// Test parsing KCL. + #[test] + fn parse() { + super::parse(TEST_NAME) + } + + /// Test that parsing and unparsing KCL produces the original KCL input. + #[test] + fn unparse() { + super::unparse(TEST_NAME) + } + + /// Test that KCL is executed correctly. + #[tokio::test(flavor = "multi_thread")] + async fn kcl_test_execute() { + super::execute(TEST_NAME, false).await + } +} +mod index_of_array { + const TEST_NAME: &str = "index_of_array"; + + /// Test tokenizing KCL. + #[test] + fn tokenize() { + super::tokenize(TEST_NAME) + } + + /// Test parsing KCL. + #[test] + fn parse() { + super::parse(TEST_NAME) + } + + /// Test that parsing and unparsing KCL produces the original KCL input. + #[test] + fn unparse() { + super::unparse(TEST_NAME) + } + + /// Test that KCL is executed correctly. + #[tokio::test(flavor = "multi_thread")] + async fn kcl_test_execute() { + super::execute(TEST_NAME, false).await + } +} +mod comparisons { + const TEST_NAME: &str = "comparisons"; + + /// Test tokenizing KCL. + #[test] + fn tokenize() { + super::tokenize(TEST_NAME) + } + + /// Test parsing KCL. + #[test] + fn parse() { + super::parse(TEST_NAME) + } + + /// Test that parsing and unparsing KCL produces the original KCL input. + #[test] + fn unparse() { + super::unparse(TEST_NAME) + } + + /// Test that KCL is executed correctly. + #[tokio::test(flavor = "multi_thread")] + async fn kcl_test_execute() { + super::execute(TEST_NAME, false).await + } +} +mod array_range_expr { + const TEST_NAME: &str = "array_range_expr"; + + /// Test tokenizing KCL. + #[test] + fn tokenize() { + super::tokenize(TEST_NAME) + } + + /// Test parsing KCL. + #[test] + fn parse() { + super::parse(TEST_NAME) + } + + /// Test that parsing and unparsing KCL produces the original KCL input. + #[test] + fn unparse() { + super::unparse(TEST_NAME) + } + + /// Test that KCL is executed correctly. + #[tokio::test(flavor = "multi_thread")] + async fn kcl_test_execute() { + super::execute(TEST_NAME, false).await + } +} +mod array_range_negative_expr { + const TEST_NAME: &str = "array_range_negative_expr"; + + /// Test tokenizing KCL. + #[test] + fn tokenize() { + super::tokenize(TEST_NAME) + } + + /// Test parsing KCL. + #[test] + fn parse() { + super::parse(TEST_NAME) + } + + /// Test that parsing and unparsing KCL produces the original KCL input. + #[test] + fn unparse() { + super::unparse(TEST_NAME) + } + + /// Test that KCL is executed correctly. + #[tokio::test(flavor = "multi_thread")] + async fn kcl_test_execute() { + super::execute(TEST_NAME, false).await + } +} +mod sketch_in_object { + const TEST_NAME: &str = "sketch_in_object"; + + /// Test tokenizing KCL. + #[test] + fn tokenize() { + super::tokenize(TEST_NAME) + } + + /// Test parsing KCL. + #[test] + fn parse() { + super::parse(TEST_NAME) + } + + /// Test that parsing and unparsing KCL produces the original KCL input. + #[test] + fn unparse() { + super::unparse(TEST_NAME) + } + + /// Test that KCL is executed correctly. + #[tokio::test(flavor = "multi_thread")] + async fn kcl_test_execute() { + super::execute(TEST_NAME, false).await + } +} +mod if_else { + const TEST_NAME: &str = "if_else"; + + /// Test tokenizing KCL. + #[test] + fn tokenize() { + super::tokenize(TEST_NAME) + } + + /// Test parsing KCL. + #[test] + fn parse() { + super::parse(TEST_NAME) + } + + /// Test that parsing and unparsing KCL produces the original KCL input. + #[test] + fn unparse() { + super::unparse(TEST_NAME) + } + + /// Test that KCL is executed correctly. + #[tokio::test(flavor = "multi_thread")] + async fn kcl_test_execute() { + super::execute(TEST_NAME, false).await + } +} +mod add_lots { + const TEST_NAME: &str = "add_lots"; + + /// Test tokenizing KCL. + #[test] + fn tokenize() { + super::tokenize(TEST_NAME) + } + + /// Test parsing KCL. + #[test] + fn parse() { + super::parse(TEST_NAME) + } + + /// Test that parsing and unparsing KCL produces the original KCL input. + #[test] + fn unparse() { + super::unparse(TEST_NAME) + } + + /// Test that KCL is executed correctly. + #[tokio::test(flavor = "multi_thread")] + async fn kcl_test_execute() { + super::execute(TEST_NAME, false).await + } +} +mod array_elem_push { + const TEST_NAME: &str = "array_elem_push"; + + /// Test tokenizing KCL. + #[test] + fn tokenize() { + super::tokenize(TEST_NAME) + } + + /// Test parsing KCL. + #[test] + fn parse() { + super::parse(TEST_NAME) + } + + /// Test that parsing and unparsing KCL produces the original KCL input. + #[test] + fn unparse() { + super::unparse(TEST_NAME) + } + + /// Test that KCL is executed correctly. + #[tokio::test(flavor = "multi_thread")] + async fn kcl_test_execute() { + super::execute(TEST_NAME, false).await + } +} diff --git a/src/wasm-lib/kcl/tests/add_lots/ast.snap b/src/wasm-lib/kcl/tests/add_lots/ast.snap new file mode 100644 index 0000000000..0d100ee384 --- /dev/null +++ b/src/wasm-lib/kcl/tests/add_lots/ast.snap @@ -0,0 +1,3205 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of parsing add_lots.kcl +snapshot_kind: text +--- +{ + "Ok": { + "body": [ + { + "declarations": [ + { + "end": 32, + "id": { + "end": 4, + "name": "f", + "start": 3, + "type": "Identifier" + }, + "init": { + "body": { + "body": [ + { + "argument": { + "end": 30, + "left": { + "end": 26, + "name": "i", + "start": 25, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "*", + "right": { + "end": 30, + "raw": "2", + "start": 29, + "type": "Literal", + "type": "Literal", + "value": 2 + }, + "start": 25, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "end": 30, + "start": 18, + "type": "ReturnStatement", + "type": "ReturnStatement" + } + ], + "end": 32, + "start": 14 + }, + "end": 32, + "params": [ + { + "type": "Parameter", + "identifier": { + "end": 9, + "name": "i", + "start": 8, + "type": "Identifier" + }, + "optional": false + } + ], + "start": 7, + "type": "FunctionExpression", + "type": "FunctionExpression" + }, + "start": 3, + "type": "VariableDeclarator" + } + ], + "end": 32, + "kind": "fn", + "start": 0, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declarations": [ + { + "end": 834, + "id": { + "end": 35, + "name": "x", + "start": 34, + "type": "Identifier" + }, + "init": { + "end": 834, + "left": { + "end": 825, + "left": { + "end": 817, + "left": { + "end": 809, + "left": { + "end": 801, + "left": { + "end": 793, + "left": { + "end": 785, + "left": { + "end": 777, + "left": { + "end": 769, + "left": { + "end": 761, + "left": { + "end": 753, + "left": { + "end": 745, + "left": { + "end": 737, + "left": { + "end": 729, + "left": { + "end": 721, + "left": { + "end": 713, + "left": { + "end": 705, + "left": { + "end": 697, + "left": { + "end": 689, + "left": { + "end": 681, + "left": { + "end": 673, + "left": { + "end": 665, + "left": { + "end": 657, + "left": { + "end": 649, + "left": { + "end": 641, + "left": { + "end": 633, + "left": { + "end": 625, + "left": { + "end": 617, + "left": { + "end": 609, + "left": { + "end": 601, + "left": { + "end": 593, + "left": { + "end": 585, + "left": { + "end": 577, + "left": { + "end": 569, + "left": { + "end": 561, + "left": { + "end": 553, + "left": { + "end": 545, + "left": { + "end": 537, + "left": { + "end": 529, + "left": { + "end": 521, + "left": { + "end": 513, + "left": { + "end": 505, + "left": { + "end": 497, + "left": { + "end": 489, + "left": { + "end": 481, + "left": { + "end": 473, + "left": { + "end": 465, + "left": { + "end": 457, + "left": { + "end": 449, + "left": { + "end": 441, + "left": { + "end": 433, + "left": { + "end": 425, + "left": { + "end": 417, + "left": { + "end": 409, + "left": { + "end": 401, + "left": { + "end": 393, + "left": { + "end": 385, + "left": { + "end": 377, + "left": { + "end": 369, + "left": { + "end": 361, + "left": { + "end": 353, + "left": { + "end": 345, + "left": { + "end": 337, + "left": { + "end": 329, + "left": { + "end": 321, + "left": { + "end": 313, + "left": { + "end": 305, + "left": { + "end": 297, + "left": { + "end": 289, + "left": { + "end": 281, + "left": { + "end": 273, + "left": { + "end": 265, + "left": { + "end": 257, + "left": { + "end": 249, + "left": { + "end": 241, + "left": { + "end": 233, + "left": { + "end": 225, + "left": { + "end": 217, + "left": { + "end": 209, + "left": { + "end": 201, + "left": { + "end": 193, + "left": { + "end": 185, + "left": { + "end": 177, + "left": { + "end": 169, + "left": { + "end": 161, + "left": { + "end": 153, + "left": { + "end": 145, + "left": { + "end": 137, + "left": { + "end": 129, + "left": { + "end": 121, + "left": { + "end": 113, + "left": { + "end": 105, + "left": { + "end": 98, + "left": { + "end": 91, + "left": { + "end": 84, + "left": { + "end": 77, + "left": { + "end": 70, + "left": { + "end": 63, + "left": { + "end": 56, + "left": { + "end": 49, + "left": { + "arguments": [ + { + "end": 41, + "raw": "0", + "start": 40, + "type": "Literal", + "type": "Literal", + "value": 0 + } + ], + "callee": { + "end": 39, + "name": "f", + "start": 38, + "type": "Identifier" + }, + "end": 42, + "optional": false, + "start": 38, + "type": "CallExpression", + "type": "CallExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 48, + "raw": "1", + "start": 47, + "type": "Literal", + "type": "Literal", + "value": 1 + } + ], + "callee": { + "end": 46, + "name": "f", + "start": 45, + "type": "Identifier" + }, + "end": 49, + "optional": false, + "start": 45, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 55, + "raw": "2", + "start": 54, + "type": "Literal", + "type": "Literal", + "value": 2 + } + ], + "callee": { + "end": 53, + "name": "f", + "start": 52, + "type": "Identifier" + }, + "end": 56, + "optional": false, + "start": 52, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 62, + "raw": "3", + "start": 61, + "type": "Literal", + "type": "Literal", + "value": 3 + } + ], + "callee": { + "end": 60, + "name": "f", + "start": 59, + "type": "Identifier" + }, + "end": 63, + "optional": false, + "start": 59, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 69, + "raw": "4", + "start": 68, + "type": "Literal", + "type": "Literal", + "value": 4 + } + ], + "callee": { + "end": 67, + "name": "f", + "start": 66, + "type": "Identifier" + }, + "end": 70, + "optional": false, + "start": 66, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 76, + "raw": "5", + "start": 75, + "type": "Literal", + "type": "Literal", + "value": 5 + } + ], + "callee": { + "end": 74, + "name": "f", + "start": 73, + "type": "Identifier" + }, + "end": 77, + "optional": false, + "start": 73, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 83, + "raw": "6", + "start": 82, + "type": "Literal", + "type": "Literal", + "value": 6 + } + ], + "callee": { + "end": 81, + "name": "f", + "start": 80, + "type": "Identifier" + }, + "end": 84, + "optional": false, + "start": 80, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 90, + "raw": "7", + "start": 89, + "type": "Literal", + "type": "Literal", + "value": 7 + } + ], + "callee": { + "end": 88, + "name": "f", + "start": 87, + "type": "Identifier" + }, + "end": 91, + "optional": false, + "start": 87, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 97, + "raw": "8", + "start": 96, + "type": "Literal", + "type": "Literal", + "value": 8 + } + ], + "callee": { + "end": 95, + "name": "f", + "start": 94, + "type": "Identifier" + }, + "end": 98, + "optional": false, + "start": 94, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 104, + "raw": "9", + "start": 103, + "type": "Literal", + "type": "Literal", + "value": 9 + } + ], + "callee": { + "end": 102, + "name": "f", + "start": 101, + "type": "Identifier" + }, + "end": 105, + "optional": false, + "start": 101, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 112, + "raw": "10", + "start": 110, + "type": "Literal", + "type": "Literal", + "value": 10 + } + ], + "callee": { + "end": 109, + "name": "f", + "start": 108, + "type": "Identifier" + }, + "end": 113, + "optional": false, + "start": 108, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 120, + "raw": "11", + "start": 118, + "type": "Literal", + "type": "Literal", + "value": 11 + } + ], + "callee": { + "end": 117, + "name": "f", + "start": 116, + "type": "Identifier" + }, + "end": 121, + "optional": false, + "start": 116, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 128, + "raw": "12", + "start": 126, + "type": "Literal", + "type": "Literal", + "value": 12 + } + ], + "callee": { + "end": 125, + "name": "f", + "start": 124, + "type": "Identifier" + }, + "end": 129, + "optional": false, + "start": 124, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 136, + "raw": "13", + "start": 134, + "type": "Literal", + "type": "Literal", + "value": 13 + } + ], + "callee": { + "end": 133, + "name": "f", + "start": 132, + "type": "Identifier" + }, + "end": 137, + "optional": false, + "start": 132, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 144, + "raw": "14", + "start": 142, + "type": "Literal", + "type": "Literal", + "value": 14 + } + ], + "callee": { + "end": 141, + "name": "f", + "start": 140, + "type": "Identifier" + }, + "end": 145, + "optional": false, + "start": 140, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 152, + "raw": "15", + "start": 150, + "type": "Literal", + "type": "Literal", + "value": 15 + } + ], + "callee": { + "end": 149, + "name": "f", + "start": 148, + "type": "Identifier" + }, + "end": 153, + "optional": false, + "start": 148, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 160, + "raw": "16", + "start": 158, + "type": "Literal", + "type": "Literal", + "value": 16 + } + ], + "callee": { + "end": 157, + "name": "f", + "start": 156, + "type": "Identifier" + }, + "end": 161, + "optional": false, + "start": 156, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 168, + "raw": "17", + "start": 166, + "type": "Literal", + "type": "Literal", + "value": 17 + } + ], + "callee": { + "end": 165, + "name": "f", + "start": 164, + "type": "Identifier" + }, + "end": 169, + "optional": false, + "start": 164, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 176, + "raw": "18", + "start": 174, + "type": "Literal", + "type": "Literal", + "value": 18 + } + ], + "callee": { + "end": 173, + "name": "f", + "start": 172, + "type": "Identifier" + }, + "end": 177, + "optional": false, + "start": 172, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 184, + "raw": "19", + "start": 182, + "type": "Literal", + "type": "Literal", + "value": 19 + } + ], + "callee": { + "end": 181, + "name": "f", + "start": 180, + "type": "Identifier" + }, + "end": 185, + "optional": false, + "start": 180, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 192, + "raw": "20", + "start": 190, + "type": "Literal", + "type": "Literal", + "value": 20 + } + ], + "callee": { + "end": 189, + "name": "f", + "start": 188, + "type": "Identifier" + }, + "end": 193, + "optional": false, + "start": 188, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 200, + "raw": "21", + "start": 198, + "type": "Literal", + "type": "Literal", + "value": 21 + } + ], + "callee": { + "end": 197, + "name": "f", + "start": 196, + "type": "Identifier" + }, + "end": 201, + "optional": false, + "start": 196, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 208, + "raw": "22", + "start": 206, + "type": "Literal", + "type": "Literal", + "value": 22 + } + ], + "callee": { + "end": 205, + "name": "f", + "start": 204, + "type": "Identifier" + }, + "end": 209, + "optional": false, + "start": 204, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 216, + "raw": "23", + "start": 214, + "type": "Literal", + "type": "Literal", + "value": 23 + } + ], + "callee": { + "end": 213, + "name": "f", + "start": 212, + "type": "Identifier" + }, + "end": 217, + "optional": false, + "start": 212, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 224, + "raw": "24", + "start": 222, + "type": "Literal", + "type": "Literal", + "value": 24 + } + ], + "callee": { + "end": 221, + "name": "f", + "start": 220, + "type": "Identifier" + }, + "end": 225, + "optional": false, + "start": 220, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 232, + "raw": "25", + "start": 230, + "type": "Literal", + "type": "Literal", + "value": 25 + } + ], + "callee": { + "end": 229, + "name": "f", + "start": 228, + "type": "Identifier" + }, + "end": 233, + "optional": false, + "start": 228, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 240, + "raw": "26", + "start": 238, + "type": "Literal", + "type": "Literal", + "value": 26 + } + ], + "callee": { + "end": 237, + "name": "f", + "start": 236, + "type": "Identifier" + }, + "end": 241, + "optional": false, + "start": 236, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 248, + "raw": "27", + "start": 246, + "type": "Literal", + "type": "Literal", + "value": 27 + } + ], + "callee": { + "end": 245, + "name": "f", + "start": 244, + "type": "Identifier" + }, + "end": 249, + "optional": false, + "start": 244, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 256, + "raw": "28", + "start": 254, + "type": "Literal", + "type": "Literal", + "value": 28 + } + ], + "callee": { + "end": 253, + "name": "f", + "start": 252, + "type": "Identifier" + }, + "end": 257, + "optional": false, + "start": 252, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 264, + "raw": "29", + "start": 262, + "type": "Literal", + "type": "Literal", + "value": 29 + } + ], + "callee": { + "end": 261, + "name": "f", + "start": 260, + "type": "Identifier" + }, + "end": 265, + "optional": false, + "start": 260, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 272, + "raw": "30", + "start": 270, + "type": "Literal", + "type": "Literal", + "value": 30 + } + ], + "callee": { + "end": 269, + "name": "f", + "start": 268, + "type": "Identifier" + }, + "end": 273, + "optional": false, + "start": 268, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 280, + "raw": "31", + "start": 278, + "type": "Literal", + "type": "Literal", + "value": 31 + } + ], + "callee": { + "end": 277, + "name": "f", + "start": 276, + "type": "Identifier" + }, + "end": 281, + "optional": false, + "start": 276, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 288, + "raw": "32", + "start": 286, + "type": "Literal", + "type": "Literal", + "value": 32 + } + ], + "callee": { + "end": 285, + "name": "f", + "start": 284, + "type": "Identifier" + }, + "end": 289, + "optional": false, + "start": 284, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 296, + "raw": "33", + "start": 294, + "type": "Literal", + "type": "Literal", + "value": 33 + } + ], + "callee": { + "end": 293, + "name": "f", + "start": 292, + "type": "Identifier" + }, + "end": 297, + "optional": false, + "start": 292, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 304, + "raw": "34", + "start": 302, + "type": "Literal", + "type": "Literal", + "value": 34 + } + ], + "callee": { + "end": 301, + "name": "f", + "start": 300, + "type": "Identifier" + }, + "end": 305, + "optional": false, + "start": 300, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 312, + "raw": "35", + "start": 310, + "type": "Literal", + "type": "Literal", + "value": 35 + } + ], + "callee": { + "end": 309, + "name": "f", + "start": 308, + "type": "Identifier" + }, + "end": 313, + "optional": false, + "start": 308, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 320, + "raw": "36", + "start": 318, + "type": "Literal", + "type": "Literal", + "value": 36 + } + ], + "callee": { + "end": 317, + "name": "f", + "start": 316, + "type": "Identifier" + }, + "end": 321, + "optional": false, + "start": 316, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 328, + "raw": "37", + "start": 326, + "type": "Literal", + "type": "Literal", + "value": 37 + } + ], + "callee": { + "end": 325, + "name": "f", + "start": 324, + "type": "Identifier" + }, + "end": 329, + "optional": false, + "start": 324, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 336, + "raw": "38", + "start": 334, + "type": "Literal", + "type": "Literal", + "value": 38 + } + ], + "callee": { + "end": 333, + "name": "f", + "start": 332, + "type": "Identifier" + }, + "end": 337, + "optional": false, + "start": 332, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 344, + "raw": "39", + "start": 342, + "type": "Literal", + "type": "Literal", + "value": 39 + } + ], + "callee": { + "end": 341, + "name": "f", + "start": 340, + "type": "Identifier" + }, + "end": 345, + "optional": false, + "start": 340, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 352, + "raw": "40", + "start": 350, + "type": "Literal", + "type": "Literal", + "value": 40 + } + ], + "callee": { + "end": 349, + "name": "f", + "start": 348, + "type": "Identifier" + }, + "end": 353, + "optional": false, + "start": 348, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 360, + "raw": "41", + "start": 358, + "type": "Literal", + "type": "Literal", + "value": 41 + } + ], + "callee": { + "end": 357, + "name": "f", + "start": 356, + "type": "Identifier" + }, + "end": 361, + "optional": false, + "start": 356, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 368, + "raw": "42", + "start": 366, + "type": "Literal", + "type": "Literal", + "value": 42 + } + ], + "callee": { + "end": 365, + "name": "f", + "start": 364, + "type": "Identifier" + }, + "end": 369, + "optional": false, + "start": 364, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 376, + "raw": "43", + "start": 374, + "type": "Literal", + "type": "Literal", + "value": 43 + } + ], + "callee": { + "end": 373, + "name": "f", + "start": 372, + "type": "Identifier" + }, + "end": 377, + "optional": false, + "start": 372, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 384, + "raw": "44", + "start": 382, + "type": "Literal", + "type": "Literal", + "value": 44 + } + ], + "callee": { + "end": 381, + "name": "f", + "start": 380, + "type": "Identifier" + }, + "end": 385, + "optional": false, + "start": 380, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 392, + "raw": "45", + "start": 390, + "type": "Literal", + "type": "Literal", + "value": 45 + } + ], + "callee": { + "end": 389, + "name": "f", + "start": 388, + "type": "Identifier" + }, + "end": 393, + "optional": false, + "start": 388, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 400, + "raw": "46", + "start": 398, + "type": "Literal", + "type": "Literal", + "value": 46 + } + ], + "callee": { + "end": 397, + "name": "f", + "start": 396, + "type": "Identifier" + }, + "end": 401, + "optional": false, + "start": 396, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 408, + "raw": "47", + "start": 406, + "type": "Literal", + "type": "Literal", + "value": 47 + } + ], + "callee": { + "end": 405, + "name": "f", + "start": 404, + "type": "Identifier" + }, + "end": 409, + "optional": false, + "start": 404, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 416, + "raw": "48", + "start": 414, + "type": "Literal", + "type": "Literal", + "value": 48 + } + ], + "callee": { + "end": 413, + "name": "f", + "start": 412, + "type": "Identifier" + }, + "end": 417, + "optional": false, + "start": 412, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 424, + "raw": "49", + "start": 422, + "type": "Literal", + "type": "Literal", + "value": 49 + } + ], + "callee": { + "end": 421, + "name": "f", + "start": 420, + "type": "Identifier" + }, + "end": 425, + "optional": false, + "start": 420, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 432, + "raw": "50", + "start": 430, + "type": "Literal", + "type": "Literal", + "value": 50 + } + ], + "callee": { + "end": 429, + "name": "f", + "start": 428, + "type": "Identifier" + }, + "end": 433, + "optional": false, + "start": 428, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 440, + "raw": "51", + "start": 438, + "type": "Literal", + "type": "Literal", + "value": 51 + } + ], + "callee": { + "end": 437, + "name": "f", + "start": 436, + "type": "Identifier" + }, + "end": 441, + "optional": false, + "start": 436, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 448, + "raw": "52", + "start": 446, + "type": "Literal", + "type": "Literal", + "value": 52 + } + ], + "callee": { + "end": 445, + "name": "f", + "start": 444, + "type": "Identifier" + }, + "end": 449, + "optional": false, + "start": 444, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 456, + "raw": "53", + "start": 454, + "type": "Literal", + "type": "Literal", + "value": 53 + } + ], + "callee": { + "end": 453, + "name": "f", + "start": 452, + "type": "Identifier" + }, + "end": 457, + "optional": false, + "start": 452, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 464, + "raw": "54", + "start": 462, + "type": "Literal", + "type": "Literal", + "value": 54 + } + ], + "callee": { + "end": 461, + "name": "f", + "start": 460, + "type": "Identifier" + }, + "end": 465, + "optional": false, + "start": 460, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 472, + "raw": "55", + "start": 470, + "type": "Literal", + "type": "Literal", + "value": 55 + } + ], + "callee": { + "end": 469, + "name": "f", + "start": 468, + "type": "Identifier" + }, + "end": 473, + "optional": false, + "start": 468, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 480, + "raw": "56", + "start": 478, + "type": "Literal", + "type": "Literal", + "value": 56 + } + ], + "callee": { + "end": 477, + "name": "f", + "start": 476, + "type": "Identifier" + }, + "end": 481, + "optional": false, + "start": 476, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 488, + "raw": "57", + "start": 486, + "type": "Literal", + "type": "Literal", + "value": 57 + } + ], + "callee": { + "end": 485, + "name": "f", + "start": 484, + "type": "Identifier" + }, + "end": 489, + "optional": false, + "start": 484, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 496, + "raw": "58", + "start": 494, + "type": "Literal", + "type": "Literal", + "value": 58 + } + ], + "callee": { + "end": 493, + "name": "f", + "start": 492, + "type": "Identifier" + }, + "end": 497, + "optional": false, + "start": 492, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 504, + "raw": "59", + "start": 502, + "type": "Literal", + "type": "Literal", + "value": 59 + } + ], + "callee": { + "end": 501, + "name": "f", + "start": 500, + "type": "Identifier" + }, + "end": 505, + "optional": false, + "start": 500, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 512, + "raw": "60", + "start": 510, + "type": "Literal", + "type": "Literal", + "value": 60 + } + ], + "callee": { + "end": 509, + "name": "f", + "start": 508, + "type": "Identifier" + }, + "end": 513, + "optional": false, + "start": 508, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 520, + "raw": "61", + "start": 518, + "type": "Literal", + "type": "Literal", + "value": 61 + } + ], + "callee": { + "end": 517, + "name": "f", + "start": 516, + "type": "Identifier" + }, + "end": 521, + "optional": false, + "start": 516, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 528, + "raw": "62", + "start": 526, + "type": "Literal", + "type": "Literal", + "value": 62 + } + ], + "callee": { + "end": 525, + "name": "f", + "start": 524, + "type": "Identifier" + }, + "end": 529, + "optional": false, + "start": 524, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 536, + "raw": "63", + "start": 534, + "type": "Literal", + "type": "Literal", + "value": 63 + } + ], + "callee": { + "end": 533, + "name": "f", + "start": 532, + "type": "Identifier" + }, + "end": 537, + "optional": false, + "start": 532, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 544, + "raw": "64", + "start": 542, + "type": "Literal", + "type": "Literal", + "value": 64 + } + ], + "callee": { + "end": 541, + "name": "f", + "start": 540, + "type": "Identifier" + }, + "end": 545, + "optional": false, + "start": 540, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 552, + "raw": "65", + "start": 550, + "type": "Literal", + "type": "Literal", + "value": 65 + } + ], + "callee": { + "end": 549, + "name": "f", + "start": 548, + "type": "Identifier" + }, + "end": 553, + "optional": false, + "start": 548, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 560, + "raw": "66", + "start": 558, + "type": "Literal", + "type": "Literal", + "value": 66 + } + ], + "callee": { + "end": 557, + "name": "f", + "start": 556, + "type": "Identifier" + }, + "end": 561, + "optional": false, + "start": 556, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 568, + "raw": "67", + "start": 566, + "type": "Literal", + "type": "Literal", + "value": 67 + } + ], + "callee": { + "end": 565, + "name": "f", + "start": 564, + "type": "Identifier" + }, + "end": 569, + "optional": false, + "start": 564, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 576, + "raw": "68", + "start": 574, + "type": "Literal", + "type": "Literal", + "value": 68 + } + ], + "callee": { + "end": 573, + "name": "f", + "start": 572, + "type": "Identifier" + }, + "end": 577, + "optional": false, + "start": 572, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 584, + "raw": "69", + "start": 582, + "type": "Literal", + "type": "Literal", + "value": 69 + } + ], + "callee": { + "end": 581, + "name": "f", + "start": 580, + "type": "Identifier" + }, + "end": 585, + "optional": false, + "start": 580, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 592, + "raw": "70", + "start": 590, + "type": "Literal", + "type": "Literal", + "value": 70 + } + ], + "callee": { + "end": 589, + "name": "f", + "start": 588, + "type": "Identifier" + }, + "end": 593, + "optional": false, + "start": 588, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 600, + "raw": "71", + "start": 598, + "type": "Literal", + "type": "Literal", + "value": 71 + } + ], + "callee": { + "end": 597, + "name": "f", + "start": 596, + "type": "Identifier" + }, + "end": 601, + "optional": false, + "start": 596, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 608, + "raw": "72", + "start": 606, + "type": "Literal", + "type": "Literal", + "value": 72 + } + ], + "callee": { + "end": 605, + "name": "f", + "start": 604, + "type": "Identifier" + }, + "end": 609, + "optional": false, + "start": 604, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 616, + "raw": "73", + "start": 614, + "type": "Literal", + "type": "Literal", + "value": 73 + } + ], + "callee": { + "end": 613, + "name": "f", + "start": 612, + "type": "Identifier" + }, + "end": 617, + "optional": false, + "start": 612, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 624, + "raw": "74", + "start": 622, + "type": "Literal", + "type": "Literal", + "value": 74 + } + ], + "callee": { + "end": 621, + "name": "f", + "start": 620, + "type": "Identifier" + }, + "end": 625, + "optional": false, + "start": 620, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 632, + "raw": "75", + "start": 630, + "type": "Literal", + "type": "Literal", + "value": 75 + } + ], + "callee": { + "end": 629, + "name": "f", + "start": 628, + "type": "Identifier" + }, + "end": 633, + "optional": false, + "start": 628, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 640, + "raw": "76", + "start": 638, + "type": "Literal", + "type": "Literal", + "value": 76 + } + ], + "callee": { + "end": 637, + "name": "f", + "start": 636, + "type": "Identifier" + }, + "end": 641, + "optional": false, + "start": 636, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 648, + "raw": "77", + "start": 646, + "type": "Literal", + "type": "Literal", + "value": 77 + } + ], + "callee": { + "end": 645, + "name": "f", + "start": 644, + "type": "Identifier" + }, + "end": 649, + "optional": false, + "start": 644, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 656, + "raw": "78", + "start": 654, + "type": "Literal", + "type": "Literal", + "value": 78 + } + ], + "callee": { + "end": 653, + "name": "f", + "start": 652, + "type": "Identifier" + }, + "end": 657, + "optional": false, + "start": 652, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 664, + "raw": "79", + "start": 662, + "type": "Literal", + "type": "Literal", + "value": 79 + } + ], + "callee": { + "end": 661, + "name": "f", + "start": 660, + "type": "Identifier" + }, + "end": 665, + "optional": false, + "start": 660, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 672, + "raw": "80", + "start": 670, + "type": "Literal", + "type": "Literal", + "value": 80 + } + ], + "callee": { + "end": 669, + "name": "f", + "start": 668, + "type": "Identifier" + }, + "end": 673, + "optional": false, + "start": 668, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 680, + "raw": "81", + "start": 678, + "type": "Literal", + "type": "Literal", + "value": 81 + } + ], + "callee": { + "end": 677, + "name": "f", + "start": 676, + "type": "Identifier" + }, + "end": 681, + "optional": false, + "start": 676, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 688, + "raw": "82", + "start": 686, + "type": "Literal", + "type": "Literal", + "value": 82 + } + ], + "callee": { + "end": 685, + "name": "f", + "start": 684, + "type": "Identifier" + }, + "end": 689, + "optional": false, + "start": 684, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 696, + "raw": "83", + "start": 694, + "type": "Literal", + "type": "Literal", + "value": 83 + } + ], + "callee": { + "end": 693, + "name": "f", + "start": 692, + "type": "Identifier" + }, + "end": 697, + "optional": false, + "start": 692, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 704, + "raw": "84", + "start": 702, + "type": "Literal", + "type": "Literal", + "value": 84 + } + ], + "callee": { + "end": 701, + "name": "f", + "start": 700, + "type": "Identifier" + }, + "end": 705, + "optional": false, + "start": 700, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 712, + "raw": "85", + "start": 710, + "type": "Literal", + "type": "Literal", + "value": 85 + } + ], + "callee": { + "end": 709, + "name": "f", + "start": 708, + "type": "Identifier" + }, + "end": 713, + "optional": false, + "start": 708, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 720, + "raw": "86", + "start": 718, + "type": "Literal", + "type": "Literal", + "value": 86 + } + ], + "callee": { + "end": 717, + "name": "f", + "start": 716, + "type": "Identifier" + }, + "end": 721, + "optional": false, + "start": 716, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 728, + "raw": "87", + "start": 726, + "type": "Literal", + "type": "Literal", + "value": 87 + } + ], + "callee": { + "end": 725, + "name": "f", + "start": 724, + "type": "Identifier" + }, + "end": 729, + "optional": false, + "start": 724, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 736, + "raw": "88", + "start": 734, + "type": "Literal", + "type": "Literal", + "value": 88 + } + ], + "callee": { + "end": 733, + "name": "f", + "start": 732, + "type": "Identifier" + }, + "end": 737, + "optional": false, + "start": 732, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 744, + "raw": "89", + "start": 742, + "type": "Literal", + "type": "Literal", + "value": 89 + } + ], + "callee": { + "end": 741, + "name": "f", + "start": 740, + "type": "Identifier" + }, + "end": 745, + "optional": false, + "start": 740, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 752, + "raw": "90", + "start": 750, + "type": "Literal", + "type": "Literal", + "value": 90 + } + ], + "callee": { + "end": 749, + "name": "f", + "start": 748, + "type": "Identifier" + }, + "end": 753, + "optional": false, + "start": 748, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 760, + "raw": "91", + "start": 758, + "type": "Literal", + "type": "Literal", + "value": 91 + } + ], + "callee": { + "end": 757, + "name": "f", + "start": 756, + "type": "Identifier" + }, + "end": 761, + "optional": false, + "start": 756, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 768, + "raw": "92", + "start": 766, + "type": "Literal", + "type": "Literal", + "value": 92 + } + ], + "callee": { + "end": 765, + "name": "f", + "start": 764, + "type": "Identifier" + }, + "end": 769, + "optional": false, + "start": 764, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 776, + "raw": "93", + "start": 774, + "type": "Literal", + "type": "Literal", + "value": 93 + } + ], + "callee": { + "end": 773, + "name": "f", + "start": 772, + "type": "Identifier" + }, + "end": 777, + "optional": false, + "start": 772, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 784, + "raw": "94", + "start": 782, + "type": "Literal", + "type": "Literal", + "value": 94 + } + ], + "callee": { + "end": 781, + "name": "f", + "start": 780, + "type": "Identifier" + }, + "end": 785, + "optional": false, + "start": 780, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 792, + "raw": "95", + "start": 790, + "type": "Literal", + "type": "Literal", + "value": 95 + } + ], + "callee": { + "end": 789, + "name": "f", + "start": 788, + "type": "Identifier" + }, + "end": 793, + "optional": false, + "start": 788, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 800, + "raw": "96", + "start": 798, + "type": "Literal", + "type": "Literal", + "value": 96 + } + ], + "callee": { + "end": 797, + "name": "f", + "start": 796, + "type": "Identifier" + }, + "end": 801, + "optional": false, + "start": 796, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 808, + "raw": "97", + "start": 806, + "type": "Literal", + "type": "Literal", + "value": 97 + } + ], + "callee": { + "end": 805, + "name": "f", + "start": 804, + "type": "Identifier" + }, + "end": 809, + "optional": false, + "start": 804, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 816, + "raw": "98", + "start": 814, + "type": "Literal", + "type": "Literal", + "value": 98 + } + ], + "callee": { + "end": 813, + "name": "f", + "start": 812, + "type": "Identifier" + }, + "end": 817, + "optional": false, + "start": 812, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 824, + "raw": "99", + "start": 822, + "type": "Literal", + "type": "Literal", + "value": 99 + } + ], + "callee": { + "end": 821, + "name": "f", + "start": 820, + "type": "Identifier" + }, + "end": 825, + "optional": false, + "start": 820, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "operator": "+", + "right": { + "arguments": [ + { + "end": 833, + "raw": "100", + "start": 830, + "type": "Literal", + "type": "Literal", + "value": 100 + } + ], + "callee": { + "end": 829, + "name": "f", + "start": 828, + "type": "Identifier" + }, + "end": 834, + "optional": false, + "start": 828, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 38, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "start": 34, + "type": "VariableDeclarator" + } + ], + "end": 834, + "kind": "const", + "start": 34, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "end": 873, + "expression": { + "arguments": [ + { + "end": 849, + "name": "x", + "start": 848, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 856, + "raw": "10100", + "start": 851, + "type": "Literal", + "type": "Literal", + "value": 10100 + }, + { + "end": 861, + "raw": "0.1", + "start": 858, + "type": "Literal", + "type": "Literal", + "value": 0.1 + }, + { + "end": 872, + "raw": "\"Big sum\"", + "start": 863, + "type": "Literal", + "type": "Literal", + "value": "Big sum" + } + ], + "callee": { + "end": 847, + "name": "assertEqual", + "start": 836, + "type": "Identifier" + }, + "end": 873, + "optional": false, + "start": 836, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 836, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 874, + "nonCodeMeta": { + "nonCodeNodes": { + "0": [ + { + "end": 34, + "start": 32, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "1": [ + { + "end": 836, + "start": 834, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ] + }, + "startNodes": [] + }, + "start": 0 + } +} diff --git a/src/wasm-lib/kcl/tests/add_lots/input.kcl b/src/wasm-lib/kcl/tests/add_lots/input.kcl new file mode 100644 index 0000000000..eec7ea22d1 --- /dev/null +++ b/src/wasm-lib/kcl/tests/add_lots/input.kcl @@ -0,0 +1,7 @@ +fn f = (i) => { + return i * 2 +} + +x = f(0) + f(1) + f(2) + f(3) + f(4) + f(5) + f(6) + f(7) + f(8) + f(9) + f(10) + f(11) + f(12) + f(13) + f(14) + f(15) + f(16) + f(17) + f(18) + f(19) + f(20) + f(21) + f(22) + f(23) + f(24) + f(25) + f(26) + f(27) + f(28) + f(29) + f(30) + f(31) + f(32) + f(33) + f(34) + f(35) + f(36) + f(37) + f(38) + f(39) + f(40) + f(41) + f(42) + f(43) + f(44) + f(45) + f(46) + f(47) + f(48) + f(49) + f(50) + f(51) + f(52) + f(53) + f(54) + f(55) + f(56) + f(57) + f(58) + f(59) + f(60) + f(61) + f(62) + f(63) + f(64) + f(65) + f(66) + f(67) + f(68) + f(69) + f(70) + f(71) + f(72) + f(73) + f(74) + f(75) + f(76) + f(77) + f(78) + f(79) + f(80) + f(81) + f(82) + f(83) + f(84) + f(85) + f(86) + f(87) + f(88) + f(89) + f(90) + f(91) + f(92) + f(93) + f(94) + f(95) + f(96) + f(97) + f(98) + f(99) + f(100) + +assertEqual(x, 10100, 0.1, "Big sum") diff --git a/src/wasm-lib/kcl/tests/add_lots/program_memory.snap b/src/wasm-lib/kcl/tests/add_lots/program_memory.snap new file mode 100644 index 0000000000..24acbd15d3 --- /dev/null +++ b/src/wasm-lib/kcl/tests/add_lots/program_memory.snap @@ -0,0 +1,150 @@ +--- +source: kcl/src/simulation_tests.rs +description: Program memory after executing add_lots.kcl +snapshot_kind: text +--- +{ + "environments": [ + { + "bindings": { + "HALF_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 180, + "__meta": [] + }, + "QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 90, + "__meta": [] + }, + "THREE_QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 270, + "__meta": [] + }, + "ZERO": { + "type": "UserVal", + "type": "UserVal", + "value": 0, + "__meta": [] + }, + "f": { + "type": "Function", + "expression": { + "body": { + "body": [ + { + "argument": { + "end": 30, + "left": { + "end": 26, + "name": "i", + "start": 25, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "*", + "right": { + "end": 30, + "raw": "2", + "start": 29, + "type": "Literal", + "type": "Literal", + "value": 2 + }, + "start": 25, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "end": 30, + "start": 18, + "type": "ReturnStatement", + "type": "ReturnStatement" + } + ], + "end": 32, + "start": 14 + }, + "end": 32, + "params": [ + { + "type": "Parameter", + "identifier": { + "end": 9, + "name": "i", + "start": 8, + "type": "Identifier" + }, + "optional": false + } + ], + "start": 7, + "type": "FunctionExpression" + }, + "memory": { + "environments": [ + { + "bindings": { + "HALF_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 180, + "__meta": [] + }, + "QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 90, + "__meta": [] + }, + "THREE_QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 270, + "__meta": [] + }, + "ZERO": { + "type": "UserVal", + "type": "UserVal", + "value": 0, + "__meta": [] + } + }, + "parent": null + } + ], + "currentEnv": 0, + "return": null + }, + "__meta": [ + { + "sourceRange": [ + 7, + 32 + ] + } + ] + }, + "x": { + "type": "UserVal", + "type": "UserVal", + "value": 10100.0, + "__meta": [ + { + "sourceRange": [ + 38, + 834 + ] + } + ] + } + }, + "parent": null + } + ], + "currentEnv": 0, + "return": null +} diff --git a/src/wasm-lib/kcl/tests/add_lots/tokens.snap b/src/wasm-lib/kcl/tests/add_lots/tokens.snap new file mode 100644 index 0000000000..d6f2f3b574 --- /dev/null +++ b/src/wasm-lib/kcl/tests/add_lots/tokens.snap @@ -0,0 +1,4491 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of tokenizing add_lots.kcl +snapshot_kind: text +--- +{ + "Ok": [ + { + "type": "keyword", + "start": 0, + "end": 2, + "value": "fn" + }, + { + "type": "whitespace", + "start": 2, + "end": 3, + "value": " " + }, + { + "type": "word", + "start": 3, + "end": 4, + "value": "f" + }, + { + "type": "whitespace", + "start": 4, + "end": 5, + "value": " " + }, + { + "type": "operator", + "start": 5, + "end": 6, + "value": "=" + }, + { + "type": "whitespace", + "start": 6, + "end": 7, + "value": " " + }, + { + "type": "brace", + "start": 7, + "end": 8, + "value": "(" + }, + { + "type": "word", + "start": 8, + "end": 9, + "value": "i" + }, + { + "type": "brace", + "start": 9, + "end": 10, + "value": ")" + }, + { + "type": "whitespace", + "start": 10, + "end": 11, + "value": " " + }, + { + "type": "operator", + "start": 11, + "end": 13, + "value": "=>" + }, + { + "type": "whitespace", + "start": 13, + "end": 14, + "value": " " + }, + { + "type": "brace", + "start": 14, + "end": 15, + "value": "{" + }, + { + "type": "whitespace", + "start": 15, + "end": 18, + "value": "\n " + }, + { + "type": "keyword", + "start": 18, + "end": 24, + "value": "return" + }, + { + "type": "whitespace", + "start": 24, + "end": 25, + "value": " " + }, + { + "type": "word", + "start": 25, + "end": 26, + "value": "i" + }, + { + "type": "whitespace", + "start": 26, + "end": 27, + "value": " " + }, + { + "type": "operator", + "start": 27, + "end": 28, + "value": "*" + }, + { + "type": "whitespace", + "start": 28, + "end": 29, + "value": " " + }, + { + "type": "number", + "start": 29, + "end": 30, + "value": "2" + }, + { + "type": "whitespace", + "start": 30, + "end": 31, + "value": "\n" + }, + { + "type": "brace", + "start": 31, + "end": 32, + "value": "}" + }, + { + "type": "whitespace", + "start": 32, + "end": 34, + "value": "\n\n" + }, + { + "type": "word", + "start": 34, + "end": 35, + "value": "x" + }, + { + "type": "whitespace", + "start": 35, + "end": 36, + "value": " " + }, + { + "type": "operator", + "start": 36, + "end": 37, + "value": "=" + }, + { + "type": "whitespace", + "start": 37, + "end": 38, + "value": " " + }, + { + "type": "word", + "start": 38, + "end": 39, + "value": "f" + }, + { + "type": "brace", + "start": 39, + "end": 40, + "value": "(" + }, + { + "type": "number", + "start": 40, + "end": 41, + "value": "0" + }, + { + "type": "brace", + "start": 41, + "end": 42, + "value": ")" + }, + { + "type": "whitespace", + "start": 42, + "end": 43, + "value": " " + }, + { + "type": "operator", + "start": 43, + "end": 44, + "value": "+" + }, + { + "type": "whitespace", + "start": 44, + "end": 45, + "value": " " + }, + { + "type": "word", + "start": 45, + "end": 46, + "value": "f" + }, + { + "type": "brace", + "start": 46, + "end": 47, + "value": "(" + }, + { + "type": "number", + "start": 47, + "end": 48, + "value": "1" + }, + { + "type": "brace", + "start": 48, + "end": 49, + "value": ")" + }, + { + "type": "whitespace", + "start": 49, + "end": 50, + "value": " " + }, + { + "type": "operator", + "start": 50, + "end": 51, + "value": "+" + }, + { + "type": "whitespace", + "start": 51, + "end": 52, + "value": " " + }, + { + "type": "word", + "start": 52, + "end": 53, + "value": "f" + }, + { + "type": "brace", + "start": 53, + "end": 54, + "value": "(" + }, + { + "type": "number", + "start": 54, + "end": 55, + "value": "2" + }, + { + "type": "brace", + "start": 55, + "end": 56, + "value": ")" + }, + { + "type": "whitespace", + "start": 56, + "end": 57, + "value": " " + }, + { + "type": "operator", + "start": 57, + "end": 58, + "value": "+" + }, + { + "type": "whitespace", + "start": 58, + "end": 59, + "value": " " + }, + { + "type": "word", + "start": 59, + "end": 60, + "value": "f" + }, + { + "type": "brace", + "start": 60, + "end": 61, + "value": "(" + }, + { + "type": "number", + "start": 61, + "end": 62, + "value": "3" + }, + { + "type": "brace", + "start": 62, + "end": 63, + "value": ")" + }, + { + "type": "whitespace", + "start": 63, + "end": 64, + "value": " " + }, + { + "type": "operator", + "start": 64, + "end": 65, + "value": "+" + }, + { + "type": "whitespace", + "start": 65, + "end": 66, + "value": " " + }, + { + "type": "word", + "start": 66, + "end": 67, + "value": "f" + }, + { + "type": "brace", + "start": 67, + "end": 68, + "value": "(" + }, + { + "type": "number", + "start": 68, + "end": 69, + "value": "4" + }, + { + "type": "brace", + "start": 69, + "end": 70, + "value": ")" + }, + { + "type": "whitespace", + "start": 70, + "end": 71, + "value": " " + }, + { + "type": "operator", + "start": 71, + "end": 72, + "value": "+" + }, + { + "type": "whitespace", + "start": 72, + "end": 73, + "value": " " + }, + { + "type": "word", + "start": 73, + "end": 74, + "value": "f" + }, + { + "type": "brace", + "start": 74, + "end": 75, + "value": "(" + }, + { + "type": "number", + "start": 75, + "end": 76, + "value": "5" + }, + { + "type": "brace", + "start": 76, + "end": 77, + "value": ")" + }, + { + "type": "whitespace", + "start": 77, + "end": 78, + "value": " " + }, + { + "type": "operator", + "start": 78, + "end": 79, + "value": "+" + }, + { + "type": "whitespace", + "start": 79, + "end": 80, + "value": " " + }, + { + "type": "word", + "start": 80, + "end": 81, + "value": "f" + }, + { + "type": "brace", + "start": 81, + "end": 82, + "value": "(" + }, + { + "type": "number", + "start": 82, + "end": 83, + "value": "6" + }, + { + "type": "brace", + "start": 83, + "end": 84, + "value": ")" + }, + { + "type": "whitespace", + "start": 84, + "end": 85, + "value": " " + }, + { + "type": "operator", + "start": 85, + "end": 86, + "value": "+" + }, + { + "type": "whitespace", + "start": 86, + "end": 87, + "value": " " + }, + { + "type": "word", + "start": 87, + "end": 88, + "value": "f" + }, + { + "type": "brace", + "start": 88, + "end": 89, + "value": "(" + }, + { + "type": "number", + "start": 89, + "end": 90, + "value": "7" + }, + { + "type": "brace", + "start": 90, + "end": 91, + "value": ")" + }, + { + "type": "whitespace", + "start": 91, + "end": 92, + "value": " " + }, + { + "type": "operator", + "start": 92, + "end": 93, + "value": "+" + }, + { + "type": "whitespace", + "start": 93, + "end": 94, + "value": " " + }, + { + "type": "word", + "start": 94, + "end": 95, + "value": "f" + }, + { + "type": "brace", + "start": 95, + "end": 96, + "value": "(" + }, + { + "type": "number", + "start": 96, + "end": 97, + "value": "8" + }, + { + "type": "brace", + "start": 97, + "end": 98, + "value": ")" + }, + { + "type": "whitespace", + "start": 98, + "end": 99, + "value": " " + }, + { + "type": "operator", + "start": 99, + "end": 100, + "value": "+" + }, + { + "type": "whitespace", + "start": 100, + "end": 101, + "value": " " + }, + { + "type": "word", + "start": 101, + "end": 102, + "value": "f" + }, + { + "type": "brace", + "start": 102, + "end": 103, + "value": "(" + }, + { + "type": "number", + "start": 103, + "end": 104, + "value": "9" + }, + { + "type": "brace", + "start": 104, + "end": 105, + "value": ")" + }, + { + "type": "whitespace", + "start": 105, + "end": 106, + "value": " " + }, + { + "type": "operator", + "start": 106, + "end": 107, + "value": "+" + }, + { + "type": "whitespace", + "start": 107, + "end": 108, + "value": " " + }, + { + "type": "word", + "start": 108, + "end": 109, + "value": "f" + }, + { + "type": "brace", + "start": 109, + "end": 110, + "value": "(" + }, + { + "type": "number", + "start": 110, + "end": 112, + "value": "10" + }, + { + "type": "brace", + "start": 112, + "end": 113, + "value": ")" + }, + { + "type": "whitespace", + "start": 113, + "end": 114, + "value": " " + }, + { + "type": "operator", + "start": 114, + "end": 115, + "value": "+" + }, + { + "type": "whitespace", + "start": 115, + "end": 116, + "value": " " + }, + { + "type": "word", + "start": 116, + "end": 117, + "value": "f" + }, + { + "type": "brace", + "start": 117, + "end": 118, + "value": "(" + }, + { + "type": "number", + "start": 118, + "end": 120, + "value": "11" + }, + { + "type": "brace", + "start": 120, + "end": 121, + "value": ")" + }, + { + "type": "whitespace", + "start": 121, + "end": 122, + "value": " " + }, + { + "type": "operator", + "start": 122, + "end": 123, + "value": "+" + }, + { + "type": "whitespace", + "start": 123, + "end": 124, + "value": " " + }, + { + "type": "word", + "start": 124, + "end": 125, + "value": "f" + }, + { + "type": "brace", + "start": 125, + "end": 126, + "value": "(" + }, + { + "type": "number", + "start": 126, + "end": 128, + "value": "12" + }, + { + "type": "brace", + "start": 128, + "end": 129, + "value": ")" + }, + { + "type": "whitespace", + "start": 129, + "end": 130, + "value": " " + }, + { + "type": "operator", + "start": 130, + "end": 131, + "value": "+" + }, + { + "type": "whitespace", + "start": 131, + "end": 132, + "value": " " + }, + { + "type": "word", + "start": 132, + "end": 133, + "value": "f" + }, + { + "type": "brace", + "start": 133, + "end": 134, + "value": "(" + }, + { + "type": "number", + "start": 134, + "end": 136, + "value": "13" + }, + { + "type": "brace", + "start": 136, + "end": 137, + "value": ")" + }, + { + "type": "whitespace", + "start": 137, + "end": 138, + "value": " " + }, + { + "type": "operator", + "start": 138, + "end": 139, + "value": "+" + }, + { + "type": "whitespace", + "start": 139, + "end": 140, + "value": " " + }, + { + "type": "word", + "start": 140, + "end": 141, + "value": "f" + }, + { + "type": "brace", + "start": 141, + "end": 142, + "value": "(" + }, + { + "type": "number", + "start": 142, + "end": 144, + "value": "14" + }, + { + "type": "brace", + "start": 144, + "end": 145, + "value": ")" + }, + { + "type": "whitespace", + "start": 145, + "end": 146, + "value": " " + }, + { + "type": "operator", + "start": 146, + "end": 147, + "value": "+" + }, + { + "type": "whitespace", + "start": 147, + "end": 148, + "value": " " + }, + { + "type": "word", + "start": 148, + "end": 149, + "value": "f" + }, + { + "type": "brace", + "start": 149, + "end": 150, + "value": "(" + }, + { + "type": "number", + "start": 150, + "end": 152, + "value": "15" + }, + { + "type": "brace", + "start": 152, + "end": 153, + "value": ")" + }, + { + "type": "whitespace", + "start": 153, + "end": 154, + "value": " " + }, + { + "type": "operator", + "start": 154, + "end": 155, + "value": "+" + }, + { + "type": "whitespace", + "start": 155, + "end": 156, + "value": " " + }, + { + "type": "word", + "start": 156, + "end": 157, + "value": "f" + }, + { + "type": "brace", + "start": 157, + "end": 158, + "value": "(" + }, + { + "type": "number", + "start": 158, + "end": 160, + "value": "16" + }, + { + "type": "brace", + "start": 160, + "end": 161, + "value": ")" + }, + { + "type": "whitespace", + "start": 161, + "end": 162, + "value": " " + }, + { + "type": "operator", + "start": 162, + "end": 163, + "value": "+" + }, + { + "type": "whitespace", + "start": 163, + "end": 164, + "value": " " + }, + { + "type": "word", + "start": 164, + "end": 165, + "value": "f" + }, + { + "type": "brace", + "start": 165, + "end": 166, + "value": "(" + }, + { + "type": "number", + "start": 166, + "end": 168, + "value": "17" + }, + { + "type": "brace", + "start": 168, + "end": 169, + "value": ")" + }, + { + "type": "whitespace", + "start": 169, + "end": 170, + "value": " " + }, + { + "type": "operator", + "start": 170, + "end": 171, + "value": "+" + }, + { + "type": "whitespace", + "start": 171, + "end": 172, + "value": " " + }, + { + "type": "word", + "start": 172, + "end": 173, + "value": "f" + }, + { + "type": "brace", + "start": 173, + "end": 174, + "value": "(" + }, + { + "type": "number", + "start": 174, + "end": 176, + "value": "18" + }, + { + "type": "brace", + "start": 176, + "end": 177, + "value": ")" + }, + { + "type": "whitespace", + "start": 177, + "end": 178, + "value": " " + }, + { + "type": "operator", + "start": 178, + "end": 179, + "value": "+" + }, + { + "type": "whitespace", + "start": 179, + "end": 180, + "value": " " + }, + { + "type": "word", + "start": 180, + "end": 181, + "value": "f" + }, + { + "type": "brace", + "start": 181, + "end": 182, + "value": "(" + }, + { + "type": "number", + "start": 182, + "end": 184, + "value": "19" + }, + { + "type": "brace", + "start": 184, + "end": 185, + "value": ")" + }, + { + "type": "whitespace", + "start": 185, + "end": 186, + "value": " " + }, + { + "type": "operator", + "start": 186, + "end": 187, + "value": "+" + }, + { + "type": "whitespace", + "start": 187, + "end": 188, + "value": " " + }, + { + "type": "word", + "start": 188, + "end": 189, + "value": "f" + }, + { + "type": "brace", + "start": 189, + "end": 190, + "value": "(" + }, + { + "type": "number", + "start": 190, + "end": 192, + "value": "20" + }, + { + "type": "brace", + "start": 192, + "end": 193, + "value": ")" + }, + { + "type": "whitespace", + "start": 193, + "end": 194, + "value": " " + }, + { + "type": "operator", + "start": 194, + "end": 195, + "value": "+" + }, + { + "type": "whitespace", + "start": 195, + "end": 196, + "value": " " + }, + { + "type": "word", + "start": 196, + "end": 197, + "value": "f" + }, + { + "type": "brace", + "start": 197, + "end": 198, + "value": "(" + }, + { + "type": "number", + "start": 198, + "end": 200, + "value": "21" + }, + { + "type": "brace", + "start": 200, + "end": 201, + "value": ")" + }, + { + "type": "whitespace", + "start": 201, + "end": 202, + "value": " " + }, + { + "type": "operator", + "start": 202, + "end": 203, + "value": "+" + }, + { + "type": "whitespace", + "start": 203, + "end": 204, + "value": " " + }, + { + "type": "word", + "start": 204, + "end": 205, + "value": "f" + }, + { + "type": "brace", + "start": 205, + "end": 206, + "value": "(" + }, + { + "type": "number", + "start": 206, + "end": 208, + "value": "22" + }, + { + "type": "brace", + "start": 208, + "end": 209, + "value": ")" + }, + { + "type": "whitespace", + "start": 209, + "end": 210, + "value": " " + }, + { + "type": "operator", + "start": 210, + "end": 211, + "value": "+" + }, + { + "type": "whitespace", + "start": 211, + "end": 212, + "value": " " + }, + { + "type": "word", + "start": 212, + "end": 213, + "value": "f" + }, + { + "type": "brace", + "start": 213, + "end": 214, + "value": "(" + }, + { + "type": "number", + "start": 214, + "end": 216, + "value": "23" + }, + { + "type": "brace", + "start": 216, + "end": 217, + "value": ")" + }, + { + "type": "whitespace", + "start": 217, + "end": 218, + "value": " " + }, + { + "type": "operator", + "start": 218, + "end": 219, + "value": "+" + }, + { + "type": "whitespace", + "start": 219, + "end": 220, + "value": " " + }, + { + "type": "word", + "start": 220, + "end": 221, + "value": "f" + }, + { + "type": "brace", + "start": 221, + "end": 222, + "value": "(" + }, + { + "type": "number", + "start": 222, + "end": 224, + "value": "24" + }, + { + "type": "brace", + "start": 224, + "end": 225, + "value": ")" + }, + { + "type": "whitespace", + "start": 225, + "end": 226, + "value": " " + }, + { + "type": "operator", + "start": 226, + "end": 227, + "value": "+" + }, + { + "type": "whitespace", + "start": 227, + "end": 228, + "value": " " + }, + { + "type": "word", + "start": 228, + "end": 229, + "value": "f" + }, + { + "type": "brace", + "start": 229, + "end": 230, + "value": "(" + }, + { + "type": "number", + "start": 230, + "end": 232, + "value": "25" + }, + { + "type": "brace", + "start": 232, + "end": 233, + "value": ")" + }, + { + "type": "whitespace", + "start": 233, + "end": 234, + "value": " " + }, + { + "type": "operator", + "start": 234, + "end": 235, + "value": "+" + }, + { + "type": "whitespace", + "start": 235, + "end": 236, + "value": " " + }, + { + "type": "word", + "start": 236, + "end": 237, + "value": "f" + }, + { + "type": "brace", + "start": 237, + "end": 238, + "value": "(" + }, + { + "type": "number", + "start": 238, + "end": 240, + "value": "26" + }, + { + "type": "brace", + "start": 240, + "end": 241, + "value": ")" + }, + { + "type": "whitespace", + "start": 241, + "end": 242, + "value": " " + }, + { + "type": "operator", + "start": 242, + "end": 243, + "value": "+" + }, + { + "type": "whitespace", + "start": 243, + "end": 244, + "value": " " + }, + { + "type": "word", + "start": 244, + "end": 245, + "value": "f" + }, + { + "type": "brace", + "start": 245, + "end": 246, + "value": "(" + }, + { + "type": "number", + "start": 246, + "end": 248, + "value": "27" + }, + { + "type": "brace", + "start": 248, + "end": 249, + "value": ")" + }, + { + "type": "whitespace", + "start": 249, + "end": 250, + "value": " " + }, + { + "type": "operator", + "start": 250, + "end": 251, + "value": "+" + }, + { + "type": "whitespace", + "start": 251, + "end": 252, + "value": " " + }, + { + "type": "word", + "start": 252, + "end": 253, + "value": "f" + }, + { + "type": "brace", + "start": 253, + "end": 254, + "value": "(" + }, + { + "type": "number", + "start": 254, + "end": 256, + "value": "28" + }, + { + "type": "brace", + "start": 256, + "end": 257, + "value": ")" + }, + { + "type": "whitespace", + "start": 257, + "end": 258, + "value": " " + }, + { + "type": "operator", + "start": 258, + "end": 259, + "value": "+" + }, + { + "type": "whitespace", + "start": 259, + "end": 260, + "value": " " + }, + { + "type": "word", + "start": 260, + "end": 261, + "value": "f" + }, + { + "type": "brace", + "start": 261, + "end": 262, + "value": "(" + }, + { + "type": "number", + "start": 262, + "end": 264, + "value": "29" + }, + { + "type": "brace", + "start": 264, + "end": 265, + "value": ")" + }, + { + "type": "whitespace", + "start": 265, + "end": 266, + "value": " " + }, + { + "type": "operator", + "start": 266, + "end": 267, + "value": "+" + }, + { + "type": "whitespace", + "start": 267, + "end": 268, + "value": " " + }, + { + "type": "word", + "start": 268, + "end": 269, + "value": "f" + }, + { + "type": "brace", + "start": 269, + "end": 270, + "value": "(" + }, + { + "type": "number", + "start": 270, + "end": 272, + "value": "30" + }, + { + "type": "brace", + "start": 272, + "end": 273, + "value": ")" + }, + { + "type": "whitespace", + "start": 273, + "end": 274, + "value": " " + }, + { + "type": "operator", + "start": 274, + "end": 275, + "value": "+" + }, + { + "type": "whitespace", + "start": 275, + "end": 276, + "value": " " + }, + { + "type": "word", + "start": 276, + "end": 277, + "value": "f" + }, + { + "type": "brace", + "start": 277, + "end": 278, + "value": "(" + }, + { + "type": "number", + "start": 278, + "end": 280, + "value": "31" + }, + { + "type": "brace", + "start": 280, + "end": 281, + "value": ")" + }, + { + "type": "whitespace", + "start": 281, + "end": 282, + "value": " " + }, + { + "type": "operator", + "start": 282, + "end": 283, + "value": "+" + }, + { + "type": "whitespace", + "start": 283, + "end": 284, + "value": " " + }, + { + "type": "word", + "start": 284, + "end": 285, + "value": "f" + }, + { + "type": "brace", + "start": 285, + "end": 286, + "value": "(" + }, + { + "type": "number", + "start": 286, + "end": 288, + "value": "32" + }, + { + "type": "brace", + "start": 288, + "end": 289, + "value": ")" + }, + { + "type": "whitespace", + "start": 289, + "end": 290, + "value": " " + }, + { + "type": "operator", + "start": 290, + "end": 291, + "value": "+" + }, + { + "type": "whitespace", + "start": 291, + "end": 292, + "value": " " + }, + { + "type": "word", + "start": 292, + "end": 293, + "value": "f" + }, + { + "type": "brace", + "start": 293, + "end": 294, + "value": "(" + }, + { + "type": "number", + "start": 294, + "end": 296, + "value": "33" + }, + { + "type": "brace", + "start": 296, + "end": 297, + "value": ")" + }, + { + "type": "whitespace", + "start": 297, + "end": 298, + "value": " " + }, + { + "type": "operator", + "start": 298, + "end": 299, + "value": "+" + }, + { + "type": "whitespace", + "start": 299, + "end": 300, + "value": " " + }, + { + "type": "word", + "start": 300, + "end": 301, + "value": "f" + }, + { + "type": "brace", + "start": 301, + "end": 302, + "value": "(" + }, + { + "type": "number", + "start": 302, + "end": 304, + "value": "34" + }, + { + "type": "brace", + "start": 304, + "end": 305, + "value": ")" + }, + { + "type": "whitespace", + "start": 305, + "end": 306, + "value": " " + }, + { + "type": "operator", + "start": 306, + "end": 307, + "value": "+" + }, + { + "type": "whitespace", + "start": 307, + "end": 308, + "value": " " + }, + { + "type": "word", + "start": 308, + "end": 309, + "value": "f" + }, + { + "type": "brace", + "start": 309, + "end": 310, + "value": "(" + }, + { + "type": "number", + "start": 310, + "end": 312, + "value": "35" + }, + { + "type": "brace", + "start": 312, + "end": 313, + "value": ")" + }, + { + "type": "whitespace", + "start": 313, + "end": 314, + "value": " " + }, + { + "type": "operator", + "start": 314, + "end": 315, + "value": "+" + }, + { + "type": "whitespace", + "start": 315, + "end": 316, + "value": " " + }, + { + "type": "word", + "start": 316, + "end": 317, + "value": "f" + }, + { + "type": "brace", + "start": 317, + "end": 318, + "value": "(" + }, + { + "type": "number", + "start": 318, + "end": 320, + "value": "36" + }, + { + "type": "brace", + "start": 320, + "end": 321, + "value": ")" + }, + { + "type": "whitespace", + "start": 321, + "end": 322, + "value": " " + }, + { + "type": "operator", + "start": 322, + "end": 323, + "value": "+" + }, + { + "type": "whitespace", + "start": 323, + "end": 324, + "value": " " + }, + { + "type": "word", + "start": 324, + "end": 325, + "value": "f" + }, + { + "type": "brace", + "start": 325, + "end": 326, + "value": "(" + }, + { + "type": "number", + "start": 326, + "end": 328, + "value": "37" + }, + { + "type": "brace", + "start": 328, + "end": 329, + "value": ")" + }, + { + "type": "whitespace", + "start": 329, + "end": 330, + "value": " " + }, + { + "type": "operator", + "start": 330, + "end": 331, + "value": "+" + }, + { + "type": "whitespace", + "start": 331, + "end": 332, + "value": " " + }, + { + "type": "word", + "start": 332, + "end": 333, + "value": "f" + }, + { + "type": "brace", + "start": 333, + "end": 334, + "value": "(" + }, + { + "type": "number", + "start": 334, + "end": 336, + "value": "38" + }, + { + "type": "brace", + "start": 336, + "end": 337, + "value": ")" + }, + { + "type": "whitespace", + "start": 337, + "end": 338, + "value": " " + }, + { + "type": "operator", + "start": 338, + "end": 339, + "value": "+" + }, + { + "type": "whitespace", + "start": 339, + "end": 340, + "value": " " + }, + { + "type": "word", + "start": 340, + "end": 341, + "value": "f" + }, + { + "type": "brace", + "start": 341, + "end": 342, + "value": "(" + }, + { + "type": "number", + "start": 342, + "end": 344, + "value": "39" + }, + { + "type": "brace", + "start": 344, + "end": 345, + "value": ")" + }, + { + "type": "whitespace", + "start": 345, + "end": 346, + "value": " " + }, + { + "type": "operator", + "start": 346, + "end": 347, + "value": "+" + }, + { + "type": "whitespace", + "start": 347, + "end": 348, + "value": " " + }, + { + "type": "word", + "start": 348, + "end": 349, + "value": "f" + }, + { + "type": "brace", + "start": 349, + "end": 350, + "value": "(" + }, + { + "type": "number", + "start": 350, + "end": 352, + "value": "40" + }, + { + "type": "brace", + "start": 352, + "end": 353, + "value": ")" + }, + { + "type": "whitespace", + "start": 353, + "end": 354, + "value": " " + }, + { + "type": "operator", + "start": 354, + "end": 355, + "value": "+" + }, + { + "type": "whitespace", + "start": 355, + "end": 356, + "value": " " + }, + { + "type": "word", + "start": 356, + "end": 357, + "value": "f" + }, + { + "type": "brace", + "start": 357, + "end": 358, + "value": "(" + }, + { + "type": "number", + "start": 358, + "end": 360, + "value": "41" + }, + { + "type": "brace", + "start": 360, + "end": 361, + "value": ")" + }, + { + "type": "whitespace", + "start": 361, + "end": 362, + "value": " " + }, + { + "type": "operator", + "start": 362, + "end": 363, + "value": "+" + }, + { + "type": "whitespace", + "start": 363, + "end": 364, + "value": " " + }, + { + "type": "word", + "start": 364, + "end": 365, + "value": "f" + }, + { + "type": "brace", + "start": 365, + "end": 366, + "value": "(" + }, + { + "type": "number", + "start": 366, + "end": 368, + "value": "42" + }, + { + "type": "brace", + "start": 368, + "end": 369, + "value": ")" + }, + { + "type": "whitespace", + "start": 369, + "end": 370, + "value": " " + }, + { + "type": "operator", + "start": 370, + "end": 371, + "value": "+" + }, + { + "type": "whitespace", + "start": 371, + "end": 372, + "value": " " + }, + { + "type": "word", + "start": 372, + "end": 373, + "value": "f" + }, + { + "type": "brace", + "start": 373, + "end": 374, + "value": "(" + }, + { + "type": "number", + "start": 374, + "end": 376, + "value": "43" + }, + { + "type": "brace", + "start": 376, + "end": 377, + "value": ")" + }, + { + "type": "whitespace", + "start": 377, + "end": 378, + "value": " " + }, + { + "type": "operator", + "start": 378, + "end": 379, + "value": "+" + }, + { + "type": "whitespace", + "start": 379, + "end": 380, + "value": " " + }, + { + "type": "word", + "start": 380, + "end": 381, + "value": "f" + }, + { + "type": "brace", + "start": 381, + "end": 382, + "value": "(" + }, + { + "type": "number", + "start": 382, + "end": 384, + "value": "44" + }, + { + "type": "brace", + "start": 384, + "end": 385, + "value": ")" + }, + { + "type": "whitespace", + "start": 385, + "end": 386, + "value": " " + }, + { + "type": "operator", + "start": 386, + "end": 387, + "value": "+" + }, + { + "type": "whitespace", + "start": 387, + "end": 388, + "value": " " + }, + { + "type": "word", + "start": 388, + "end": 389, + "value": "f" + }, + { + "type": "brace", + "start": 389, + "end": 390, + "value": "(" + }, + { + "type": "number", + "start": 390, + "end": 392, + "value": "45" + }, + { + "type": "brace", + "start": 392, + "end": 393, + "value": ")" + }, + { + "type": "whitespace", + "start": 393, + "end": 394, + "value": " " + }, + { + "type": "operator", + "start": 394, + "end": 395, + "value": "+" + }, + { + "type": "whitespace", + "start": 395, + "end": 396, + "value": " " + }, + { + "type": "word", + "start": 396, + "end": 397, + "value": "f" + }, + { + "type": "brace", + "start": 397, + "end": 398, + "value": "(" + }, + { + "type": "number", + "start": 398, + "end": 400, + "value": "46" + }, + { + "type": "brace", + "start": 400, + "end": 401, + "value": ")" + }, + { + "type": "whitespace", + "start": 401, + "end": 402, + "value": " " + }, + { + "type": "operator", + "start": 402, + "end": 403, + "value": "+" + }, + { + "type": "whitespace", + "start": 403, + "end": 404, + "value": " " + }, + { + "type": "word", + "start": 404, + "end": 405, + "value": "f" + }, + { + "type": "brace", + "start": 405, + "end": 406, + "value": "(" + }, + { + "type": "number", + "start": 406, + "end": 408, + "value": "47" + }, + { + "type": "brace", + "start": 408, + "end": 409, + "value": ")" + }, + { + "type": "whitespace", + "start": 409, + "end": 410, + "value": " " + }, + { + "type": "operator", + "start": 410, + "end": 411, + "value": "+" + }, + { + "type": "whitespace", + "start": 411, + "end": 412, + "value": " " + }, + { + "type": "word", + "start": 412, + "end": 413, + "value": "f" + }, + { + "type": "brace", + "start": 413, + "end": 414, + "value": "(" + }, + { + "type": "number", + "start": 414, + "end": 416, + "value": "48" + }, + { + "type": "brace", + "start": 416, + "end": 417, + "value": ")" + }, + { + "type": "whitespace", + "start": 417, + "end": 418, + "value": " " + }, + { + "type": "operator", + "start": 418, + "end": 419, + "value": "+" + }, + { + "type": "whitespace", + "start": 419, + "end": 420, + "value": " " + }, + { + "type": "word", + "start": 420, + "end": 421, + "value": "f" + }, + { + "type": "brace", + "start": 421, + "end": 422, + "value": "(" + }, + { + "type": "number", + "start": 422, + "end": 424, + "value": "49" + }, + { + "type": "brace", + "start": 424, + "end": 425, + "value": ")" + }, + { + "type": "whitespace", + "start": 425, + "end": 426, + "value": " " + }, + { + "type": "operator", + "start": 426, + "end": 427, + "value": "+" + }, + { + "type": "whitespace", + "start": 427, + "end": 428, + "value": " " + }, + { + "type": "word", + "start": 428, + "end": 429, + "value": "f" + }, + { + "type": "brace", + "start": 429, + "end": 430, + "value": "(" + }, + { + "type": "number", + "start": 430, + "end": 432, + "value": "50" + }, + { + "type": "brace", + "start": 432, + "end": 433, + "value": ")" + }, + { + "type": "whitespace", + "start": 433, + "end": 434, + "value": " " + }, + { + "type": "operator", + "start": 434, + "end": 435, + "value": "+" + }, + { + "type": "whitespace", + "start": 435, + "end": 436, + "value": " " + }, + { + "type": "word", + "start": 436, + "end": 437, + "value": "f" + }, + { + "type": "brace", + "start": 437, + "end": 438, + "value": "(" + }, + { + "type": "number", + "start": 438, + "end": 440, + "value": "51" + }, + { + "type": "brace", + "start": 440, + "end": 441, + "value": ")" + }, + { + "type": "whitespace", + "start": 441, + "end": 442, + "value": " " + }, + { + "type": "operator", + "start": 442, + "end": 443, + "value": "+" + }, + { + "type": "whitespace", + "start": 443, + "end": 444, + "value": " " + }, + { + "type": "word", + "start": 444, + "end": 445, + "value": "f" + }, + { + "type": "brace", + "start": 445, + "end": 446, + "value": "(" + }, + { + "type": "number", + "start": 446, + "end": 448, + "value": "52" + }, + { + "type": "brace", + "start": 448, + "end": 449, + "value": ")" + }, + { + "type": "whitespace", + "start": 449, + "end": 450, + "value": " " + }, + { + "type": "operator", + "start": 450, + "end": 451, + "value": "+" + }, + { + "type": "whitespace", + "start": 451, + "end": 452, + "value": " " + }, + { + "type": "word", + "start": 452, + "end": 453, + "value": "f" + }, + { + "type": "brace", + "start": 453, + "end": 454, + "value": "(" + }, + { + "type": "number", + "start": 454, + "end": 456, + "value": "53" + }, + { + "type": "brace", + "start": 456, + "end": 457, + "value": ")" + }, + { + "type": "whitespace", + "start": 457, + "end": 458, + "value": " " + }, + { + "type": "operator", + "start": 458, + "end": 459, + "value": "+" + }, + { + "type": "whitespace", + "start": 459, + "end": 460, + "value": " " + }, + { + "type": "word", + "start": 460, + "end": 461, + "value": "f" + }, + { + "type": "brace", + "start": 461, + "end": 462, + "value": "(" + }, + { + "type": "number", + "start": 462, + "end": 464, + "value": "54" + }, + { + "type": "brace", + "start": 464, + "end": 465, + "value": ")" + }, + { + "type": "whitespace", + "start": 465, + "end": 466, + "value": " " + }, + { + "type": "operator", + "start": 466, + "end": 467, + "value": "+" + }, + { + "type": "whitespace", + "start": 467, + "end": 468, + "value": " " + }, + { + "type": "word", + "start": 468, + "end": 469, + "value": "f" + }, + { + "type": "brace", + "start": 469, + "end": 470, + "value": "(" + }, + { + "type": "number", + "start": 470, + "end": 472, + "value": "55" + }, + { + "type": "brace", + "start": 472, + "end": 473, + "value": ")" + }, + { + "type": "whitespace", + "start": 473, + "end": 474, + "value": " " + }, + { + "type": "operator", + "start": 474, + "end": 475, + "value": "+" + }, + { + "type": "whitespace", + "start": 475, + "end": 476, + "value": " " + }, + { + "type": "word", + "start": 476, + "end": 477, + "value": "f" + }, + { + "type": "brace", + "start": 477, + "end": 478, + "value": "(" + }, + { + "type": "number", + "start": 478, + "end": 480, + "value": "56" + }, + { + "type": "brace", + "start": 480, + "end": 481, + "value": ")" + }, + { + "type": "whitespace", + "start": 481, + "end": 482, + "value": " " + }, + { + "type": "operator", + "start": 482, + "end": 483, + "value": "+" + }, + { + "type": "whitespace", + "start": 483, + "end": 484, + "value": " " + }, + { + "type": "word", + "start": 484, + "end": 485, + "value": "f" + }, + { + "type": "brace", + "start": 485, + "end": 486, + "value": "(" + }, + { + "type": "number", + "start": 486, + "end": 488, + "value": "57" + }, + { + "type": "brace", + "start": 488, + "end": 489, + "value": ")" + }, + { + "type": "whitespace", + "start": 489, + "end": 490, + "value": " " + }, + { + "type": "operator", + "start": 490, + "end": 491, + "value": "+" + }, + { + "type": "whitespace", + "start": 491, + "end": 492, + "value": " " + }, + { + "type": "word", + "start": 492, + "end": 493, + "value": "f" + }, + { + "type": "brace", + "start": 493, + "end": 494, + "value": "(" + }, + { + "type": "number", + "start": 494, + "end": 496, + "value": "58" + }, + { + "type": "brace", + "start": 496, + "end": 497, + "value": ")" + }, + { + "type": "whitespace", + "start": 497, + "end": 498, + "value": " " + }, + { + "type": "operator", + "start": 498, + "end": 499, + "value": "+" + }, + { + "type": "whitespace", + "start": 499, + "end": 500, + "value": " " + }, + { + "type": "word", + "start": 500, + "end": 501, + "value": "f" + }, + { + "type": "brace", + "start": 501, + "end": 502, + "value": "(" + }, + { + "type": "number", + "start": 502, + "end": 504, + "value": "59" + }, + { + "type": "brace", + "start": 504, + "end": 505, + "value": ")" + }, + { + "type": "whitespace", + "start": 505, + "end": 506, + "value": " " + }, + { + "type": "operator", + "start": 506, + "end": 507, + "value": "+" + }, + { + "type": "whitespace", + "start": 507, + "end": 508, + "value": " " + }, + { + "type": "word", + "start": 508, + "end": 509, + "value": "f" + }, + { + "type": "brace", + "start": 509, + "end": 510, + "value": "(" + }, + { + "type": "number", + "start": 510, + "end": 512, + "value": "60" + }, + { + "type": "brace", + "start": 512, + "end": 513, + "value": ")" + }, + { + "type": "whitespace", + "start": 513, + "end": 514, + "value": " " + }, + { + "type": "operator", + "start": 514, + "end": 515, + "value": "+" + }, + { + "type": "whitespace", + "start": 515, + "end": 516, + "value": " " + }, + { + "type": "word", + "start": 516, + "end": 517, + "value": "f" + }, + { + "type": "brace", + "start": 517, + "end": 518, + "value": "(" + }, + { + "type": "number", + "start": 518, + "end": 520, + "value": "61" + }, + { + "type": "brace", + "start": 520, + "end": 521, + "value": ")" + }, + { + "type": "whitespace", + "start": 521, + "end": 522, + "value": " " + }, + { + "type": "operator", + "start": 522, + "end": 523, + "value": "+" + }, + { + "type": "whitespace", + "start": 523, + "end": 524, + "value": " " + }, + { + "type": "word", + "start": 524, + "end": 525, + "value": "f" + }, + { + "type": "brace", + "start": 525, + "end": 526, + "value": "(" + }, + { + "type": "number", + "start": 526, + "end": 528, + "value": "62" + }, + { + "type": "brace", + "start": 528, + "end": 529, + "value": ")" + }, + { + "type": "whitespace", + "start": 529, + "end": 530, + "value": " " + }, + { + "type": "operator", + "start": 530, + "end": 531, + "value": "+" + }, + { + "type": "whitespace", + "start": 531, + "end": 532, + "value": " " + }, + { + "type": "word", + "start": 532, + "end": 533, + "value": "f" + }, + { + "type": "brace", + "start": 533, + "end": 534, + "value": "(" + }, + { + "type": "number", + "start": 534, + "end": 536, + "value": "63" + }, + { + "type": "brace", + "start": 536, + "end": 537, + "value": ")" + }, + { + "type": "whitespace", + "start": 537, + "end": 538, + "value": " " + }, + { + "type": "operator", + "start": 538, + "end": 539, + "value": "+" + }, + { + "type": "whitespace", + "start": 539, + "end": 540, + "value": " " + }, + { + "type": "word", + "start": 540, + "end": 541, + "value": "f" + }, + { + "type": "brace", + "start": 541, + "end": 542, + "value": "(" + }, + { + "type": "number", + "start": 542, + "end": 544, + "value": "64" + }, + { + "type": "brace", + "start": 544, + "end": 545, + "value": ")" + }, + { + "type": "whitespace", + "start": 545, + "end": 546, + "value": " " + }, + { + "type": "operator", + "start": 546, + "end": 547, + "value": "+" + }, + { + "type": "whitespace", + "start": 547, + "end": 548, + "value": " " + }, + { + "type": "word", + "start": 548, + "end": 549, + "value": "f" + }, + { + "type": "brace", + "start": 549, + "end": 550, + "value": "(" + }, + { + "type": "number", + "start": 550, + "end": 552, + "value": "65" + }, + { + "type": "brace", + "start": 552, + "end": 553, + "value": ")" + }, + { + "type": "whitespace", + "start": 553, + "end": 554, + "value": " " + }, + { + "type": "operator", + "start": 554, + "end": 555, + "value": "+" + }, + { + "type": "whitespace", + "start": 555, + "end": 556, + "value": " " + }, + { + "type": "word", + "start": 556, + "end": 557, + "value": "f" + }, + { + "type": "brace", + "start": 557, + "end": 558, + "value": "(" + }, + { + "type": "number", + "start": 558, + "end": 560, + "value": "66" + }, + { + "type": "brace", + "start": 560, + "end": 561, + "value": ")" + }, + { + "type": "whitespace", + "start": 561, + "end": 562, + "value": " " + }, + { + "type": "operator", + "start": 562, + "end": 563, + "value": "+" + }, + { + "type": "whitespace", + "start": 563, + "end": 564, + "value": " " + }, + { + "type": "word", + "start": 564, + "end": 565, + "value": "f" + }, + { + "type": "brace", + "start": 565, + "end": 566, + "value": "(" + }, + { + "type": "number", + "start": 566, + "end": 568, + "value": "67" + }, + { + "type": "brace", + "start": 568, + "end": 569, + "value": ")" + }, + { + "type": "whitespace", + "start": 569, + "end": 570, + "value": " " + }, + { + "type": "operator", + "start": 570, + "end": 571, + "value": "+" + }, + { + "type": "whitespace", + "start": 571, + "end": 572, + "value": " " + }, + { + "type": "word", + "start": 572, + "end": 573, + "value": "f" + }, + { + "type": "brace", + "start": 573, + "end": 574, + "value": "(" + }, + { + "type": "number", + "start": 574, + "end": 576, + "value": "68" + }, + { + "type": "brace", + "start": 576, + "end": 577, + "value": ")" + }, + { + "type": "whitespace", + "start": 577, + "end": 578, + "value": " " + }, + { + "type": "operator", + "start": 578, + "end": 579, + "value": "+" + }, + { + "type": "whitespace", + "start": 579, + "end": 580, + "value": " " + }, + { + "type": "word", + "start": 580, + "end": 581, + "value": "f" + }, + { + "type": "brace", + "start": 581, + "end": 582, + "value": "(" + }, + { + "type": "number", + "start": 582, + "end": 584, + "value": "69" + }, + { + "type": "brace", + "start": 584, + "end": 585, + "value": ")" + }, + { + "type": "whitespace", + "start": 585, + "end": 586, + "value": " " + }, + { + "type": "operator", + "start": 586, + "end": 587, + "value": "+" + }, + { + "type": "whitespace", + "start": 587, + "end": 588, + "value": " " + }, + { + "type": "word", + "start": 588, + "end": 589, + "value": "f" + }, + { + "type": "brace", + "start": 589, + "end": 590, + "value": "(" + }, + { + "type": "number", + "start": 590, + "end": 592, + "value": "70" + }, + { + "type": "brace", + "start": 592, + "end": 593, + "value": ")" + }, + { + "type": "whitespace", + "start": 593, + "end": 594, + "value": " " + }, + { + "type": "operator", + "start": 594, + "end": 595, + "value": "+" + }, + { + "type": "whitespace", + "start": 595, + "end": 596, + "value": " " + }, + { + "type": "word", + "start": 596, + "end": 597, + "value": "f" + }, + { + "type": "brace", + "start": 597, + "end": 598, + "value": "(" + }, + { + "type": "number", + "start": 598, + "end": 600, + "value": "71" + }, + { + "type": "brace", + "start": 600, + "end": 601, + "value": ")" + }, + { + "type": "whitespace", + "start": 601, + "end": 602, + "value": " " + }, + { + "type": "operator", + "start": 602, + "end": 603, + "value": "+" + }, + { + "type": "whitespace", + "start": 603, + "end": 604, + "value": " " + }, + { + "type": "word", + "start": 604, + "end": 605, + "value": "f" + }, + { + "type": "brace", + "start": 605, + "end": 606, + "value": "(" + }, + { + "type": "number", + "start": 606, + "end": 608, + "value": "72" + }, + { + "type": "brace", + "start": 608, + "end": 609, + "value": ")" + }, + { + "type": "whitespace", + "start": 609, + "end": 610, + "value": " " + }, + { + "type": "operator", + "start": 610, + "end": 611, + "value": "+" + }, + { + "type": "whitespace", + "start": 611, + "end": 612, + "value": " " + }, + { + "type": "word", + "start": 612, + "end": 613, + "value": "f" + }, + { + "type": "brace", + "start": 613, + "end": 614, + "value": "(" + }, + { + "type": "number", + "start": 614, + "end": 616, + "value": "73" + }, + { + "type": "brace", + "start": 616, + "end": 617, + "value": ")" + }, + { + "type": "whitespace", + "start": 617, + "end": 618, + "value": " " + }, + { + "type": "operator", + "start": 618, + "end": 619, + "value": "+" + }, + { + "type": "whitespace", + "start": 619, + "end": 620, + "value": " " + }, + { + "type": "word", + "start": 620, + "end": 621, + "value": "f" + }, + { + "type": "brace", + "start": 621, + "end": 622, + "value": "(" + }, + { + "type": "number", + "start": 622, + "end": 624, + "value": "74" + }, + { + "type": "brace", + "start": 624, + "end": 625, + "value": ")" + }, + { + "type": "whitespace", + "start": 625, + "end": 626, + "value": " " + }, + { + "type": "operator", + "start": 626, + "end": 627, + "value": "+" + }, + { + "type": "whitespace", + "start": 627, + "end": 628, + "value": " " + }, + { + "type": "word", + "start": 628, + "end": 629, + "value": "f" + }, + { + "type": "brace", + "start": 629, + "end": 630, + "value": "(" + }, + { + "type": "number", + "start": 630, + "end": 632, + "value": "75" + }, + { + "type": "brace", + "start": 632, + "end": 633, + "value": ")" + }, + { + "type": "whitespace", + "start": 633, + "end": 634, + "value": " " + }, + { + "type": "operator", + "start": 634, + "end": 635, + "value": "+" + }, + { + "type": "whitespace", + "start": 635, + "end": 636, + "value": " " + }, + { + "type": "word", + "start": 636, + "end": 637, + "value": "f" + }, + { + "type": "brace", + "start": 637, + "end": 638, + "value": "(" + }, + { + "type": "number", + "start": 638, + "end": 640, + "value": "76" + }, + { + "type": "brace", + "start": 640, + "end": 641, + "value": ")" + }, + { + "type": "whitespace", + "start": 641, + "end": 642, + "value": " " + }, + { + "type": "operator", + "start": 642, + "end": 643, + "value": "+" + }, + { + "type": "whitespace", + "start": 643, + "end": 644, + "value": " " + }, + { + "type": "word", + "start": 644, + "end": 645, + "value": "f" + }, + { + "type": "brace", + "start": 645, + "end": 646, + "value": "(" + }, + { + "type": "number", + "start": 646, + "end": 648, + "value": "77" + }, + { + "type": "brace", + "start": 648, + "end": 649, + "value": ")" + }, + { + "type": "whitespace", + "start": 649, + "end": 650, + "value": " " + }, + { + "type": "operator", + "start": 650, + "end": 651, + "value": "+" + }, + { + "type": "whitespace", + "start": 651, + "end": 652, + "value": " " + }, + { + "type": "word", + "start": 652, + "end": 653, + "value": "f" + }, + { + "type": "brace", + "start": 653, + "end": 654, + "value": "(" + }, + { + "type": "number", + "start": 654, + "end": 656, + "value": "78" + }, + { + "type": "brace", + "start": 656, + "end": 657, + "value": ")" + }, + { + "type": "whitespace", + "start": 657, + "end": 658, + "value": " " + }, + { + "type": "operator", + "start": 658, + "end": 659, + "value": "+" + }, + { + "type": "whitespace", + "start": 659, + "end": 660, + "value": " " + }, + { + "type": "word", + "start": 660, + "end": 661, + "value": "f" + }, + { + "type": "brace", + "start": 661, + "end": 662, + "value": "(" + }, + { + "type": "number", + "start": 662, + "end": 664, + "value": "79" + }, + { + "type": "brace", + "start": 664, + "end": 665, + "value": ")" + }, + { + "type": "whitespace", + "start": 665, + "end": 666, + "value": " " + }, + { + "type": "operator", + "start": 666, + "end": 667, + "value": "+" + }, + { + "type": "whitespace", + "start": 667, + "end": 668, + "value": " " + }, + { + "type": "word", + "start": 668, + "end": 669, + "value": "f" + }, + { + "type": "brace", + "start": 669, + "end": 670, + "value": "(" + }, + { + "type": "number", + "start": 670, + "end": 672, + "value": "80" + }, + { + "type": "brace", + "start": 672, + "end": 673, + "value": ")" + }, + { + "type": "whitespace", + "start": 673, + "end": 674, + "value": " " + }, + { + "type": "operator", + "start": 674, + "end": 675, + "value": "+" + }, + { + "type": "whitespace", + "start": 675, + "end": 676, + "value": " " + }, + { + "type": "word", + "start": 676, + "end": 677, + "value": "f" + }, + { + "type": "brace", + "start": 677, + "end": 678, + "value": "(" + }, + { + "type": "number", + "start": 678, + "end": 680, + "value": "81" + }, + { + "type": "brace", + "start": 680, + "end": 681, + "value": ")" + }, + { + "type": "whitespace", + "start": 681, + "end": 682, + "value": " " + }, + { + "type": "operator", + "start": 682, + "end": 683, + "value": "+" + }, + { + "type": "whitespace", + "start": 683, + "end": 684, + "value": " " + }, + { + "type": "word", + "start": 684, + "end": 685, + "value": "f" + }, + { + "type": "brace", + "start": 685, + "end": 686, + "value": "(" + }, + { + "type": "number", + "start": 686, + "end": 688, + "value": "82" + }, + { + "type": "brace", + "start": 688, + "end": 689, + "value": ")" + }, + { + "type": "whitespace", + "start": 689, + "end": 690, + "value": " " + }, + { + "type": "operator", + "start": 690, + "end": 691, + "value": "+" + }, + { + "type": "whitespace", + "start": 691, + "end": 692, + "value": " " + }, + { + "type": "word", + "start": 692, + "end": 693, + "value": "f" + }, + { + "type": "brace", + "start": 693, + "end": 694, + "value": "(" + }, + { + "type": "number", + "start": 694, + "end": 696, + "value": "83" + }, + { + "type": "brace", + "start": 696, + "end": 697, + "value": ")" + }, + { + "type": "whitespace", + "start": 697, + "end": 698, + "value": " " + }, + { + "type": "operator", + "start": 698, + "end": 699, + "value": "+" + }, + { + "type": "whitespace", + "start": 699, + "end": 700, + "value": " " + }, + { + "type": "word", + "start": 700, + "end": 701, + "value": "f" + }, + { + "type": "brace", + "start": 701, + "end": 702, + "value": "(" + }, + { + "type": "number", + "start": 702, + "end": 704, + "value": "84" + }, + { + "type": "brace", + "start": 704, + "end": 705, + "value": ")" + }, + { + "type": "whitespace", + "start": 705, + "end": 706, + "value": " " + }, + { + "type": "operator", + "start": 706, + "end": 707, + "value": "+" + }, + { + "type": "whitespace", + "start": 707, + "end": 708, + "value": " " + }, + { + "type": "word", + "start": 708, + "end": 709, + "value": "f" + }, + { + "type": "brace", + "start": 709, + "end": 710, + "value": "(" + }, + { + "type": "number", + "start": 710, + "end": 712, + "value": "85" + }, + { + "type": "brace", + "start": 712, + "end": 713, + "value": ")" + }, + { + "type": "whitespace", + "start": 713, + "end": 714, + "value": " " + }, + { + "type": "operator", + "start": 714, + "end": 715, + "value": "+" + }, + { + "type": "whitespace", + "start": 715, + "end": 716, + "value": " " + }, + { + "type": "word", + "start": 716, + "end": 717, + "value": "f" + }, + { + "type": "brace", + "start": 717, + "end": 718, + "value": "(" + }, + { + "type": "number", + "start": 718, + "end": 720, + "value": "86" + }, + { + "type": "brace", + "start": 720, + "end": 721, + "value": ")" + }, + { + "type": "whitespace", + "start": 721, + "end": 722, + "value": " " + }, + { + "type": "operator", + "start": 722, + "end": 723, + "value": "+" + }, + { + "type": "whitespace", + "start": 723, + "end": 724, + "value": " " + }, + { + "type": "word", + "start": 724, + "end": 725, + "value": "f" + }, + { + "type": "brace", + "start": 725, + "end": 726, + "value": "(" + }, + { + "type": "number", + "start": 726, + "end": 728, + "value": "87" + }, + { + "type": "brace", + "start": 728, + "end": 729, + "value": ")" + }, + { + "type": "whitespace", + "start": 729, + "end": 730, + "value": " " + }, + { + "type": "operator", + "start": 730, + "end": 731, + "value": "+" + }, + { + "type": "whitespace", + "start": 731, + "end": 732, + "value": " " + }, + { + "type": "word", + "start": 732, + "end": 733, + "value": "f" + }, + { + "type": "brace", + "start": 733, + "end": 734, + "value": "(" + }, + { + "type": "number", + "start": 734, + "end": 736, + "value": "88" + }, + { + "type": "brace", + "start": 736, + "end": 737, + "value": ")" + }, + { + "type": "whitespace", + "start": 737, + "end": 738, + "value": " " + }, + { + "type": "operator", + "start": 738, + "end": 739, + "value": "+" + }, + { + "type": "whitespace", + "start": 739, + "end": 740, + "value": " " + }, + { + "type": "word", + "start": 740, + "end": 741, + "value": "f" + }, + { + "type": "brace", + "start": 741, + "end": 742, + "value": "(" + }, + { + "type": "number", + "start": 742, + "end": 744, + "value": "89" + }, + { + "type": "brace", + "start": 744, + "end": 745, + "value": ")" + }, + { + "type": "whitespace", + "start": 745, + "end": 746, + "value": " " + }, + { + "type": "operator", + "start": 746, + "end": 747, + "value": "+" + }, + { + "type": "whitespace", + "start": 747, + "end": 748, + "value": " " + }, + { + "type": "word", + "start": 748, + "end": 749, + "value": "f" + }, + { + "type": "brace", + "start": 749, + "end": 750, + "value": "(" + }, + { + "type": "number", + "start": 750, + "end": 752, + "value": "90" + }, + { + "type": "brace", + "start": 752, + "end": 753, + "value": ")" + }, + { + "type": "whitespace", + "start": 753, + "end": 754, + "value": " " + }, + { + "type": "operator", + "start": 754, + "end": 755, + "value": "+" + }, + { + "type": "whitespace", + "start": 755, + "end": 756, + "value": " " + }, + { + "type": "word", + "start": 756, + "end": 757, + "value": "f" + }, + { + "type": "brace", + "start": 757, + "end": 758, + "value": "(" + }, + { + "type": "number", + "start": 758, + "end": 760, + "value": "91" + }, + { + "type": "brace", + "start": 760, + "end": 761, + "value": ")" + }, + { + "type": "whitespace", + "start": 761, + "end": 762, + "value": " " + }, + { + "type": "operator", + "start": 762, + "end": 763, + "value": "+" + }, + { + "type": "whitespace", + "start": 763, + "end": 764, + "value": " " + }, + { + "type": "word", + "start": 764, + "end": 765, + "value": "f" + }, + { + "type": "brace", + "start": 765, + "end": 766, + "value": "(" + }, + { + "type": "number", + "start": 766, + "end": 768, + "value": "92" + }, + { + "type": "brace", + "start": 768, + "end": 769, + "value": ")" + }, + { + "type": "whitespace", + "start": 769, + "end": 770, + "value": " " + }, + { + "type": "operator", + "start": 770, + "end": 771, + "value": "+" + }, + { + "type": "whitespace", + "start": 771, + "end": 772, + "value": " " + }, + { + "type": "word", + "start": 772, + "end": 773, + "value": "f" + }, + { + "type": "brace", + "start": 773, + "end": 774, + "value": "(" + }, + { + "type": "number", + "start": 774, + "end": 776, + "value": "93" + }, + { + "type": "brace", + "start": 776, + "end": 777, + "value": ")" + }, + { + "type": "whitespace", + "start": 777, + "end": 778, + "value": " " + }, + { + "type": "operator", + "start": 778, + "end": 779, + "value": "+" + }, + { + "type": "whitespace", + "start": 779, + "end": 780, + "value": " " + }, + { + "type": "word", + "start": 780, + "end": 781, + "value": "f" + }, + { + "type": "brace", + "start": 781, + "end": 782, + "value": "(" + }, + { + "type": "number", + "start": 782, + "end": 784, + "value": "94" + }, + { + "type": "brace", + "start": 784, + "end": 785, + "value": ")" + }, + { + "type": "whitespace", + "start": 785, + "end": 786, + "value": " " + }, + { + "type": "operator", + "start": 786, + "end": 787, + "value": "+" + }, + { + "type": "whitespace", + "start": 787, + "end": 788, + "value": " " + }, + { + "type": "word", + "start": 788, + "end": 789, + "value": "f" + }, + { + "type": "brace", + "start": 789, + "end": 790, + "value": "(" + }, + { + "type": "number", + "start": 790, + "end": 792, + "value": "95" + }, + { + "type": "brace", + "start": 792, + "end": 793, + "value": ")" + }, + { + "type": "whitespace", + "start": 793, + "end": 794, + "value": " " + }, + { + "type": "operator", + "start": 794, + "end": 795, + "value": "+" + }, + { + "type": "whitespace", + "start": 795, + "end": 796, + "value": " " + }, + { + "type": "word", + "start": 796, + "end": 797, + "value": "f" + }, + { + "type": "brace", + "start": 797, + "end": 798, + "value": "(" + }, + { + "type": "number", + "start": 798, + "end": 800, + "value": "96" + }, + { + "type": "brace", + "start": 800, + "end": 801, + "value": ")" + }, + { + "type": "whitespace", + "start": 801, + "end": 802, + "value": " " + }, + { + "type": "operator", + "start": 802, + "end": 803, + "value": "+" + }, + { + "type": "whitespace", + "start": 803, + "end": 804, + "value": " " + }, + { + "type": "word", + "start": 804, + "end": 805, + "value": "f" + }, + { + "type": "brace", + "start": 805, + "end": 806, + "value": "(" + }, + { + "type": "number", + "start": 806, + "end": 808, + "value": "97" + }, + { + "type": "brace", + "start": 808, + "end": 809, + "value": ")" + }, + { + "type": "whitespace", + "start": 809, + "end": 810, + "value": " " + }, + { + "type": "operator", + "start": 810, + "end": 811, + "value": "+" + }, + { + "type": "whitespace", + "start": 811, + "end": 812, + "value": " " + }, + { + "type": "word", + "start": 812, + "end": 813, + "value": "f" + }, + { + "type": "brace", + "start": 813, + "end": 814, + "value": "(" + }, + { + "type": "number", + "start": 814, + "end": 816, + "value": "98" + }, + { + "type": "brace", + "start": 816, + "end": 817, + "value": ")" + }, + { + "type": "whitespace", + "start": 817, + "end": 818, + "value": " " + }, + { + "type": "operator", + "start": 818, + "end": 819, + "value": "+" + }, + { + "type": "whitespace", + "start": 819, + "end": 820, + "value": " " + }, + { + "type": "word", + "start": 820, + "end": 821, + "value": "f" + }, + { + "type": "brace", + "start": 821, + "end": 822, + "value": "(" + }, + { + "type": "number", + "start": 822, + "end": 824, + "value": "99" + }, + { + "type": "brace", + "start": 824, + "end": 825, + "value": ")" + }, + { + "type": "whitespace", + "start": 825, + "end": 826, + "value": " " + }, + { + "type": "operator", + "start": 826, + "end": 827, + "value": "+" + }, + { + "type": "whitespace", + "start": 827, + "end": 828, + "value": " " + }, + { + "type": "word", + "start": 828, + "end": 829, + "value": "f" + }, + { + "type": "brace", + "start": 829, + "end": 830, + "value": "(" + }, + { + "type": "number", + "start": 830, + "end": 833, + "value": "100" + }, + { + "type": "brace", + "start": 833, + "end": 834, + "value": ")" + }, + { + "type": "whitespace", + "start": 834, + "end": 836, + "value": "\n\n" + }, + { + "type": "word", + "start": 836, + "end": 847, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 847, + "end": 848, + "value": "(" + }, + { + "type": "word", + "start": 848, + "end": 849, + "value": "x" + }, + { + "type": "comma", + "start": 849, + "end": 850, + "value": "," + }, + { + "type": "whitespace", + "start": 850, + "end": 851, + "value": " " + }, + { + "type": "number", + "start": 851, + "end": 856, + "value": "10100" + }, + { + "type": "comma", + "start": 856, + "end": 857, + "value": "," + }, + { + "type": "whitespace", + "start": 857, + "end": 858, + "value": " " + }, + { + "type": "number", + "start": 858, + "end": 861, + "value": "0.1" + }, + { + "type": "comma", + "start": 861, + "end": 862, + "value": "," + }, + { + "type": "whitespace", + "start": 862, + "end": 863, + "value": " " + }, + { + "type": "string", + "start": 863, + "end": 872, + "value": "\"Big sum\"" + }, + { + "type": "brace", + "start": 872, + "end": 873, + "value": ")" + }, + { + "type": "whitespace", + "start": 873, + "end": 874, + "value": "\n" + } + ] +} diff --git a/src/wasm-lib/kcl/tests/array_elem_push/ast.snap b/src/wasm-lib/kcl/tests/array_elem_push/ast.snap new file mode 100644 index 0000000000..be47ddb7fb --- /dev/null +++ b/src/wasm-lib/kcl/tests/array_elem_push/ast.snap @@ -0,0 +1,768 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of parsing array_elem_push.kcl +snapshot_kind: text +--- +{ + "Ok": { + "body": [ + { + "declarations": [ + { + "end": 15, + "id": { + "end": 3, + "name": "arr", + "start": 0, + "type": "Identifier" + }, + "init": { + "elements": [ + { + "end": 8, + "raw": "1", + "start": 7, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + { + "end": 11, + "raw": "2", + "start": 10, + "type": "Literal", + "type": "Literal", + "value": 2 + }, + { + "end": 14, + "raw": "3", + "start": 13, + "type": "Literal", + "type": "Literal", + "value": 3 + } + ], + "end": 15, + "start": 6, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + "start": 0, + "type": "VariableDeclarator" + } + ], + "end": 15, + "kind": "const", + "start": 0, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declarations": [ + { + "end": 39, + "id": { + "end": 24, + "name": "new_arr1", + "start": 16, + "type": "Identifier" + }, + "init": { + "arguments": [ + { + "end": 35, + "name": "arr", + "start": 32, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 38, + "raw": "4", + "start": 37, + "type": "Literal", + "type": "Literal", + "value": 4 + } + ], + "callee": { + "end": 31, + "name": "push", + "start": 27, + "type": "Identifier" + }, + "end": 39, + "optional": false, + "start": 27, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 16, + "type": "VariableDeclarator" + } + ], + "end": 39, + "kind": "const", + "start": 16, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declarations": [ + { + "end": 68, + "id": { + "end": 48, + "name": "new_arr2", + "start": 40, + "type": "Identifier" + }, + "init": { + "arguments": [ + { + "end": 64, + "name": "new_arr1", + "start": 56, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 67, + "raw": "5", + "start": 66, + "type": "Literal", + "type": "Literal", + "value": 5 + } + ], + "callee": { + "end": 55, + "name": "push", + "start": 51, + "type": "Identifier" + }, + "end": 68, + "optional": false, + "start": 51, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 40, + "type": "VariableDeclarator" + } + ], + "end": 68, + "kind": "const", + "start": 40, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "end": 142, + "expression": { + "arguments": [ + { + "computed": false, + "end": 92, + "object": { + "end": 89, + "name": "new_arr1", + "start": 81, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 91, + "raw": "0", + "start": 90, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + "start": 81, + "type": "MemberExpression", + "type": "MemberExpression" + }, + { + "end": 95, + "raw": "1", + "start": 94, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + { + "end": 104, + "raw": "0.00001", + "start": 97, + "type": "Literal", + "type": "Literal", + "value": 0.00001 + }, + { + "end": 141, + "raw": "\"element 0 should not have changed\"", + "start": 106, + "type": "Literal", + "type": "Literal", + "value": "element 0 should not have changed" + } + ], + "callee": { + "end": 80, + "name": "assertEqual", + "start": 69, + "type": "Identifier" + }, + "end": 142, + "optional": false, + "start": 69, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 69, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 216, + "expression": { + "arguments": [ + { + "computed": false, + "end": 166, + "object": { + "end": 163, + "name": "new_arr1", + "start": 155, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 165, + "raw": "1", + "start": 164, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + "start": 155, + "type": "MemberExpression", + "type": "MemberExpression" + }, + { + "end": 169, + "raw": "2", + "start": 168, + "type": "Literal", + "type": "Literal", + "value": 2 + }, + { + "end": 178, + "raw": "0.00001", + "start": 171, + "type": "Literal", + "type": "Literal", + "value": 0.00001 + }, + { + "end": 215, + "raw": "\"element 1 should not have changed\"", + "start": 180, + "type": "Literal", + "type": "Literal", + "value": "element 1 should not have changed" + } + ], + "callee": { + "end": 154, + "name": "assertEqual", + "start": 143, + "type": "Identifier" + }, + "end": 216, + "optional": false, + "start": 143, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 143, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 290, + "expression": { + "arguments": [ + { + "computed": false, + "end": 240, + "object": { + "end": 237, + "name": "new_arr1", + "start": 229, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 239, + "raw": "2", + "start": 238, + "type": "Literal", + "type": "Literal", + "value": 2 + }, + "start": 229, + "type": "MemberExpression", + "type": "MemberExpression" + }, + { + "end": 243, + "raw": "3", + "start": 242, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + { + "end": 252, + "raw": "0.00001", + "start": 245, + "type": "Literal", + "type": "Literal", + "value": 0.00001 + }, + { + "end": 289, + "raw": "\"element 2 should not have changed\"", + "start": 254, + "type": "Literal", + "type": "Literal", + "value": "element 2 should not have changed" + } + ], + "callee": { + "end": 228, + "name": "assertEqual", + "start": 217, + "type": "Identifier" + }, + "end": 290, + "optional": false, + "start": 217, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 217, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 366, + "expression": { + "arguments": [ + { + "computed": false, + "end": 314, + "object": { + "end": 311, + "name": "new_arr1", + "start": 303, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 313, + "raw": "3", + "start": 312, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + "start": 303, + "type": "MemberExpression", + "type": "MemberExpression" + }, + { + "end": 317, + "raw": "4", + "start": 316, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + { + "end": 326, + "raw": "0.00001", + "start": 319, + "type": "Literal", + "type": "Literal", + "value": 0.00001 + }, + { + "end": 365, + "raw": "\"4 was added to the end of the array\"", + "start": 328, + "type": "Literal", + "type": "Literal", + "value": "4 was added to the end of the array" + } + ], + "callee": { + "end": 302, + "name": "assertEqual", + "start": 291, + "type": "Identifier" + }, + "end": 366, + "optional": false, + "start": 291, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 291, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 440, + "expression": { + "arguments": [ + { + "computed": false, + "end": 390, + "object": { + "end": 387, + "name": "new_arr2", + "start": 379, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 389, + "raw": "0", + "start": 388, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + "start": 379, + "type": "MemberExpression", + "type": "MemberExpression" + }, + { + "end": 393, + "raw": "1", + "start": 392, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + { + "end": 402, + "raw": "0.00001", + "start": 395, + "type": "Literal", + "type": "Literal", + "value": 0.00001 + }, + { + "end": 439, + "raw": "\"element 0 should not have changed\"", + "start": 404, + "type": "Literal", + "type": "Literal", + "value": "element 0 should not have changed" + } + ], + "callee": { + "end": 378, + "name": "assertEqual", + "start": 367, + "type": "Identifier" + }, + "end": 440, + "optional": false, + "start": 367, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 367, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 514, + "expression": { + "arguments": [ + { + "computed": false, + "end": 464, + "object": { + "end": 461, + "name": "new_arr2", + "start": 453, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 463, + "raw": "1", + "start": 462, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + "start": 453, + "type": "MemberExpression", + "type": "MemberExpression" + }, + { + "end": 467, + "raw": "2", + "start": 466, + "type": "Literal", + "type": "Literal", + "value": 2 + }, + { + "end": 476, + "raw": "0.00001", + "start": 469, + "type": "Literal", + "type": "Literal", + "value": 0.00001 + }, + { + "end": 513, + "raw": "\"element 1 should not have changed\"", + "start": 478, + "type": "Literal", + "type": "Literal", + "value": "element 1 should not have changed" + } + ], + "callee": { + "end": 452, + "name": "assertEqual", + "start": 441, + "type": "Identifier" + }, + "end": 514, + "optional": false, + "start": 441, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 441, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 588, + "expression": { + "arguments": [ + { + "computed": false, + "end": 538, + "object": { + "end": 535, + "name": "new_arr2", + "start": 527, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 537, + "raw": "2", + "start": 536, + "type": "Literal", + "type": "Literal", + "value": 2 + }, + "start": 527, + "type": "MemberExpression", + "type": "MemberExpression" + }, + { + "end": 541, + "raw": "3", + "start": 540, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + { + "end": 550, + "raw": "0.00001", + "start": 543, + "type": "Literal", + "type": "Literal", + "value": 0.00001 + }, + { + "end": 587, + "raw": "\"element 2 should not have changed\"", + "start": 552, + "type": "Literal", + "type": "Literal", + "value": "element 2 should not have changed" + } + ], + "callee": { + "end": 526, + "name": "assertEqual", + "start": 515, + "type": "Identifier" + }, + "end": 588, + "optional": false, + "start": 515, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 515, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 664, + "expression": { + "arguments": [ + { + "computed": false, + "end": 612, + "object": { + "end": 609, + "name": "new_arr2", + "start": 601, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 611, + "raw": "3", + "start": 610, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + "start": 601, + "type": "MemberExpression", + "type": "MemberExpression" + }, + { + "end": 615, + "raw": "4", + "start": 614, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + { + "end": 624, + "raw": "0.00001", + "start": 617, + "type": "Literal", + "type": "Literal", + "value": 0.00001 + }, + { + "end": 663, + "raw": "\"4 was added to the end of the array\"", + "start": 626, + "type": "Literal", + "type": "Literal", + "value": "4 was added to the end of the array" + } + ], + "callee": { + "end": 600, + "name": "assertEqual", + "start": 589, + "type": "Identifier" + }, + "end": 664, + "optional": false, + "start": 589, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 589, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 740, + "expression": { + "arguments": [ + { + "computed": false, + "end": 688, + "object": { + "end": 685, + "name": "new_arr2", + "start": 677, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 687, + "raw": "4", + "start": 686, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + "start": 677, + "type": "MemberExpression", + "type": "MemberExpression" + }, + { + "end": 691, + "raw": "5", + "start": 690, + "type": "Literal", + "type": "Literal", + "value": 5 + }, + { + "end": 700, + "raw": "0.00001", + "start": 693, + "type": "Literal", + "type": "Literal", + "value": 0.00001 + }, + { + "end": 739, + "raw": "\"5 was added to the end of the array\"", + "start": 702, + "type": "Literal", + "type": "Literal", + "value": "5 was added to the end of the array" + } + ], + "callee": { + "end": 676, + "name": "assertEqual", + "start": 665, + "type": "Identifier" + }, + "end": 740, + "optional": false, + "start": 665, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 665, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 741, + "start": 0 + } +} diff --git a/src/wasm-lib/tests/executor/inputs/no_visuals/array_elem_push.kcl b/src/wasm-lib/kcl/tests/array_elem_push/input.kcl similarity index 100% rename from src/wasm-lib/tests/executor/inputs/no_visuals/array_elem_push.kcl rename to src/wasm-lib/kcl/tests/array_elem_push/input.kcl diff --git a/src/wasm-lib/kcl/tests/array_elem_push/program_memory.snap b/src/wasm-lib/kcl/tests/array_elem_push/program_memory.snap new file mode 100644 index 0000000000..9ecdf9a841 --- /dev/null +++ b/src/wasm-lib/kcl/tests/array_elem_push/program_memory.snap @@ -0,0 +1,94 @@ +--- +source: kcl/src/simulation_tests.rs +description: Program memory after executing array_elem_push.kcl +snapshot_kind: text +--- +{ + "environments": [ + { + "bindings": { + "HALF_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 180, + "__meta": [] + }, + "QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 90, + "__meta": [] + }, + "THREE_QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 270, + "__meta": [] + }, + "ZERO": { + "type": "UserVal", + "type": "UserVal", + "value": 0, + "__meta": [] + }, + "arr": { + "type": "UserVal", + "type": "UserVal", + "value": [ + 1, + 2, + 3 + ], + "__meta": [ + { + "sourceRange": [ + 6, + 15 + ] + } + ] + }, + "new_arr1": { + "type": "UserVal", + "type": "UserVal", + "value": [ + 1, + 2, + 3, + 4 + ], + "__meta": [ + { + "sourceRange": [ + 27, + 39 + ] + } + ] + }, + "new_arr2": { + "type": "UserVal", + "type": "UserVal", + "value": [ + 1, + 2, + 3, + 4, + 5 + ], + "__meta": [ + { + "sourceRange": [ + 51, + 68 + ] + } + ] + } + }, + "parent": null + } + ], + "currentEnv": 0, + "return": null +} diff --git a/src/wasm-lib/kcl/tests/array_elem_push/tokens.snap b/src/wasm-lib/kcl/tests/array_elem_push/tokens.snap new file mode 100644 index 0000000000..74bdc62614 --- /dev/null +++ b/src/wasm-lib/kcl/tests/array_elem_push/tokens.snap @@ -0,0 +1,1155 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of tokenizing array_elem_push.kcl +snapshot_kind: text +--- +{ + "Ok": [ + { + "type": "word", + "start": 0, + "end": 3, + "value": "arr" + }, + { + "type": "whitespace", + "start": 3, + "end": 4, + "value": " " + }, + { + "type": "operator", + "start": 4, + "end": 5, + "value": "=" + }, + { + "type": "whitespace", + "start": 5, + "end": 6, + "value": " " + }, + { + "type": "brace", + "start": 6, + "end": 7, + "value": "[" + }, + { + "type": "number", + "start": 7, + "end": 8, + "value": "1" + }, + { + "type": "comma", + "start": 8, + "end": 9, + "value": "," + }, + { + "type": "whitespace", + "start": 9, + "end": 10, + "value": " " + }, + { + "type": "number", + "start": 10, + "end": 11, + "value": "2" + }, + { + "type": "comma", + "start": 11, + "end": 12, + "value": "," + }, + { + "type": "whitespace", + "start": 12, + "end": 13, + "value": " " + }, + { + "type": "number", + "start": 13, + "end": 14, + "value": "3" + }, + { + "type": "brace", + "start": 14, + "end": 15, + "value": "]" + }, + { + "type": "whitespace", + "start": 15, + "end": 16, + "value": "\n" + }, + { + "type": "word", + "start": 16, + "end": 24, + "value": "new_arr1" + }, + { + "type": "whitespace", + "start": 24, + "end": 25, + "value": " " + }, + { + "type": "operator", + "start": 25, + "end": 26, + "value": "=" + }, + { + "type": "whitespace", + "start": 26, + "end": 27, + "value": " " + }, + { + "type": "word", + "start": 27, + "end": 31, + "value": "push" + }, + { + "type": "brace", + "start": 31, + "end": 32, + "value": "(" + }, + { + "type": "word", + "start": 32, + "end": 35, + "value": "arr" + }, + { + "type": "comma", + "start": 35, + "end": 36, + "value": "," + }, + { + "type": "whitespace", + "start": 36, + "end": 37, + "value": " " + }, + { + "type": "number", + "start": 37, + "end": 38, + "value": "4" + }, + { + "type": "brace", + "start": 38, + "end": 39, + "value": ")" + }, + { + "type": "whitespace", + "start": 39, + "end": 40, + "value": "\n" + }, + { + "type": "word", + "start": 40, + "end": 48, + "value": "new_arr2" + }, + { + "type": "whitespace", + "start": 48, + "end": 49, + "value": " " + }, + { + "type": "operator", + "start": 49, + "end": 50, + "value": "=" + }, + { + "type": "whitespace", + "start": 50, + "end": 51, + "value": " " + }, + { + "type": "word", + "start": 51, + "end": 55, + "value": "push" + }, + { + "type": "brace", + "start": 55, + "end": 56, + "value": "(" + }, + { + "type": "word", + "start": 56, + "end": 64, + "value": "new_arr1" + }, + { + "type": "comma", + "start": 64, + "end": 65, + "value": "," + }, + { + "type": "whitespace", + "start": 65, + "end": 66, + "value": " " + }, + { + "type": "number", + "start": 66, + "end": 67, + "value": "5" + }, + { + "type": "brace", + "start": 67, + "end": 68, + "value": ")" + }, + { + "type": "whitespace", + "start": 68, + "end": 69, + "value": "\n" + }, + { + "type": "word", + "start": 69, + "end": 80, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 80, + "end": 81, + "value": "(" + }, + { + "type": "word", + "start": 81, + "end": 89, + "value": "new_arr1" + }, + { + "type": "brace", + "start": 89, + "end": 90, + "value": "[" + }, + { + "type": "number", + "start": 90, + "end": 91, + "value": "0" + }, + { + "type": "brace", + "start": 91, + "end": 92, + "value": "]" + }, + { + "type": "comma", + "start": 92, + "end": 93, + "value": "," + }, + { + "type": "whitespace", + "start": 93, + "end": 94, + "value": " " + }, + { + "type": "number", + "start": 94, + "end": 95, + "value": "1" + }, + { + "type": "comma", + "start": 95, + "end": 96, + "value": "," + }, + { + "type": "whitespace", + "start": 96, + "end": 97, + "value": " " + }, + { + "type": "number", + "start": 97, + "end": 104, + "value": "0.00001" + }, + { + "type": "comma", + "start": 104, + "end": 105, + "value": "," + }, + { + "type": "whitespace", + "start": 105, + "end": 106, + "value": " " + }, + { + "type": "string", + "start": 106, + "end": 141, + "value": "\"element 0 should not have changed\"" + }, + { + "type": "brace", + "start": 141, + "end": 142, + "value": ")" + }, + { + "type": "whitespace", + "start": 142, + "end": 143, + "value": "\n" + }, + { + "type": "word", + "start": 143, + "end": 154, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 154, + "end": 155, + "value": "(" + }, + { + "type": "word", + "start": 155, + "end": 163, + "value": "new_arr1" + }, + { + "type": "brace", + "start": 163, + "end": 164, + "value": "[" + }, + { + "type": "number", + "start": 164, + "end": 165, + "value": "1" + }, + { + "type": "brace", + "start": 165, + "end": 166, + "value": "]" + }, + { + "type": "comma", + "start": 166, + "end": 167, + "value": "," + }, + { + "type": "whitespace", + "start": 167, + "end": 168, + "value": " " + }, + { + "type": "number", + "start": 168, + "end": 169, + "value": "2" + }, + { + "type": "comma", + "start": 169, + "end": 170, + "value": "," + }, + { + "type": "whitespace", + "start": 170, + "end": 171, + "value": " " + }, + { + "type": "number", + "start": 171, + "end": 178, + "value": "0.00001" + }, + { + "type": "comma", + "start": 178, + "end": 179, + "value": "," + }, + { + "type": "whitespace", + "start": 179, + "end": 180, + "value": " " + }, + { + "type": "string", + "start": 180, + "end": 215, + "value": "\"element 1 should not have changed\"" + }, + { + "type": "brace", + "start": 215, + "end": 216, + "value": ")" + }, + { + "type": "whitespace", + "start": 216, + "end": 217, + "value": "\n" + }, + { + "type": "word", + "start": 217, + "end": 228, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 228, + "end": 229, + "value": "(" + }, + { + "type": "word", + "start": 229, + "end": 237, + "value": "new_arr1" + }, + { + "type": "brace", + "start": 237, + "end": 238, + "value": "[" + }, + { + "type": "number", + "start": 238, + "end": 239, + "value": "2" + }, + { + "type": "brace", + "start": 239, + "end": 240, + "value": "]" + }, + { + "type": "comma", + "start": 240, + "end": 241, + "value": "," + }, + { + "type": "whitespace", + "start": 241, + "end": 242, + "value": " " + }, + { + "type": "number", + "start": 242, + "end": 243, + "value": "3" + }, + { + "type": "comma", + "start": 243, + "end": 244, + "value": "," + }, + { + "type": "whitespace", + "start": 244, + "end": 245, + "value": " " + }, + { + "type": "number", + "start": 245, + "end": 252, + "value": "0.00001" + }, + { + "type": "comma", + "start": 252, + "end": 253, + "value": "," + }, + { + "type": "whitespace", + "start": 253, + "end": 254, + "value": " " + }, + { + "type": "string", + "start": 254, + "end": 289, + "value": "\"element 2 should not have changed\"" + }, + { + "type": "brace", + "start": 289, + "end": 290, + "value": ")" + }, + { + "type": "whitespace", + "start": 290, + "end": 291, + "value": "\n" + }, + { + "type": "word", + "start": 291, + "end": 302, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 302, + "end": 303, + "value": "(" + }, + { + "type": "word", + "start": 303, + "end": 311, + "value": "new_arr1" + }, + { + "type": "brace", + "start": 311, + "end": 312, + "value": "[" + }, + { + "type": "number", + "start": 312, + "end": 313, + "value": "3" + }, + { + "type": "brace", + "start": 313, + "end": 314, + "value": "]" + }, + { + "type": "comma", + "start": 314, + "end": 315, + "value": "," + }, + { + "type": "whitespace", + "start": 315, + "end": 316, + "value": " " + }, + { + "type": "number", + "start": 316, + "end": 317, + "value": "4" + }, + { + "type": "comma", + "start": 317, + "end": 318, + "value": "," + }, + { + "type": "whitespace", + "start": 318, + "end": 319, + "value": " " + }, + { + "type": "number", + "start": 319, + "end": 326, + "value": "0.00001" + }, + { + "type": "comma", + "start": 326, + "end": 327, + "value": "," + }, + { + "type": "whitespace", + "start": 327, + "end": 328, + "value": " " + }, + { + "type": "string", + "start": 328, + "end": 365, + "value": "\"4 was added to the end of the array\"" + }, + { + "type": "brace", + "start": 365, + "end": 366, + "value": ")" + }, + { + "type": "whitespace", + "start": 366, + "end": 367, + "value": "\n" + }, + { + "type": "word", + "start": 367, + "end": 378, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 378, + "end": 379, + "value": "(" + }, + { + "type": "word", + "start": 379, + "end": 387, + "value": "new_arr2" + }, + { + "type": "brace", + "start": 387, + "end": 388, + "value": "[" + }, + { + "type": "number", + "start": 388, + "end": 389, + "value": "0" + }, + { + "type": "brace", + "start": 389, + "end": 390, + "value": "]" + }, + { + "type": "comma", + "start": 390, + "end": 391, + "value": "," + }, + { + "type": "whitespace", + "start": 391, + "end": 392, + "value": " " + }, + { + "type": "number", + "start": 392, + "end": 393, + "value": "1" + }, + { + "type": "comma", + "start": 393, + "end": 394, + "value": "," + }, + { + "type": "whitespace", + "start": 394, + "end": 395, + "value": " " + }, + { + "type": "number", + "start": 395, + "end": 402, + "value": "0.00001" + }, + { + "type": "comma", + "start": 402, + "end": 403, + "value": "," + }, + { + "type": "whitespace", + "start": 403, + "end": 404, + "value": " " + }, + { + "type": "string", + "start": 404, + "end": 439, + "value": "\"element 0 should not have changed\"" + }, + { + "type": "brace", + "start": 439, + "end": 440, + "value": ")" + }, + { + "type": "whitespace", + "start": 440, + "end": 441, + "value": "\n" + }, + { + "type": "word", + "start": 441, + "end": 452, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 452, + "end": 453, + "value": "(" + }, + { + "type": "word", + "start": 453, + "end": 461, + "value": "new_arr2" + }, + { + "type": "brace", + "start": 461, + "end": 462, + "value": "[" + }, + { + "type": "number", + "start": 462, + "end": 463, + "value": "1" + }, + { + "type": "brace", + "start": 463, + "end": 464, + "value": "]" + }, + { + "type": "comma", + "start": 464, + "end": 465, + "value": "," + }, + { + "type": "whitespace", + "start": 465, + "end": 466, + "value": " " + }, + { + "type": "number", + "start": 466, + "end": 467, + "value": "2" + }, + { + "type": "comma", + "start": 467, + "end": 468, + "value": "," + }, + { + "type": "whitespace", + "start": 468, + "end": 469, + "value": " " + }, + { + "type": "number", + "start": 469, + "end": 476, + "value": "0.00001" + }, + { + "type": "comma", + "start": 476, + "end": 477, + "value": "," + }, + { + "type": "whitespace", + "start": 477, + "end": 478, + "value": " " + }, + { + "type": "string", + "start": 478, + "end": 513, + "value": "\"element 1 should not have changed\"" + }, + { + "type": "brace", + "start": 513, + "end": 514, + "value": ")" + }, + { + "type": "whitespace", + "start": 514, + "end": 515, + "value": "\n" + }, + { + "type": "word", + "start": 515, + "end": 526, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 526, + "end": 527, + "value": "(" + }, + { + "type": "word", + "start": 527, + "end": 535, + "value": "new_arr2" + }, + { + "type": "brace", + "start": 535, + "end": 536, + "value": "[" + }, + { + "type": "number", + "start": 536, + "end": 537, + "value": "2" + }, + { + "type": "brace", + "start": 537, + "end": 538, + "value": "]" + }, + { + "type": "comma", + "start": 538, + "end": 539, + "value": "," + }, + { + "type": "whitespace", + "start": 539, + "end": 540, + "value": " " + }, + { + "type": "number", + "start": 540, + "end": 541, + "value": "3" + }, + { + "type": "comma", + "start": 541, + "end": 542, + "value": "," + }, + { + "type": "whitespace", + "start": 542, + "end": 543, + "value": " " + }, + { + "type": "number", + "start": 543, + "end": 550, + "value": "0.00001" + }, + { + "type": "comma", + "start": 550, + "end": 551, + "value": "," + }, + { + "type": "whitespace", + "start": 551, + "end": 552, + "value": " " + }, + { + "type": "string", + "start": 552, + "end": 587, + "value": "\"element 2 should not have changed\"" + }, + { + "type": "brace", + "start": 587, + "end": 588, + "value": ")" + }, + { + "type": "whitespace", + "start": 588, + "end": 589, + "value": "\n" + }, + { + "type": "word", + "start": 589, + "end": 600, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 600, + "end": 601, + "value": "(" + }, + { + "type": "word", + "start": 601, + "end": 609, + "value": "new_arr2" + }, + { + "type": "brace", + "start": 609, + "end": 610, + "value": "[" + }, + { + "type": "number", + "start": 610, + "end": 611, + "value": "3" + }, + { + "type": "brace", + "start": 611, + "end": 612, + "value": "]" + }, + { + "type": "comma", + "start": 612, + "end": 613, + "value": "," + }, + { + "type": "whitespace", + "start": 613, + "end": 614, + "value": " " + }, + { + "type": "number", + "start": 614, + "end": 615, + "value": "4" + }, + { + "type": "comma", + "start": 615, + "end": 616, + "value": "," + }, + { + "type": "whitespace", + "start": 616, + "end": 617, + "value": " " + }, + { + "type": "number", + "start": 617, + "end": 624, + "value": "0.00001" + }, + { + "type": "comma", + "start": 624, + "end": 625, + "value": "," + }, + { + "type": "whitespace", + "start": 625, + "end": 626, + "value": " " + }, + { + "type": "string", + "start": 626, + "end": 663, + "value": "\"4 was added to the end of the array\"" + }, + { + "type": "brace", + "start": 663, + "end": 664, + "value": ")" + }, + { + "type": "whitespace", + "start": 664, + "end": 665, + "value": "\n" + }, + { + "type": "word", + "start": 665, + "end": 676, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 676, + "end": 677, + "value": "(" + }, + { + "type": "word", + "start": 677, + "end": 685, + "value": "new_arr2" + }, + { + "type": "brace", + "start": 685, + "end": 686, + "value": "[" + }, + { + "type": "number", + "start": 686, + "end": 687, + "value": "4" + }, + { + "type": "brace", + "start": 687, + "end": 688, + "value": "]" + }, + { + "type": "comma", + "start": 688, + "end": 689, + "value": "," + }, + { + "type": "whitespace", + "start": 689, + "end": 690, + "value": " " + }, + { + "type": "number", + "start": 690, + "end": 691, + "value": "5" + }, + { + "type": "comma", + "start": 691, + "end": 692, + "value": "," + }, + { + "type": "whitespace", + "start": 692, + "end": 693, + "value": " " + }, + { + "type": "number", + "start": 693, + "end": 700, + "value": "0.00001" + }, + { + "type": "comma", + "start": 700, + "end": 701, + "value": "," + }, + { + "type": "whitespace", + "start": 701, + "end": 702, + "value": " " + }, + { + "type": "string", + "start": 702, + "end": 739, + "value": "\"5 was added to the end of the array\"" + }, + { + "type": "brace", + "start": 739, + "end": 740, + "value": ")" + }, + { + "type": "whitespace", + "start": 740, + "end": 741, + "value": "\n" + } + ] +} diff --git a/src/wasm-lib/kcl/tests/array_range_expr/ast.snap b/src/wasm-lib/kcl/tests/array_range_expr/ast.snap new file mode 100644 index 0000000000..8cf38bce14 --- /dev/null +++ b/src/wasm-lib/kcl/tests/array_range_expr/ast.snap @@ -0,0 +1,856 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of parsing array_range_expr.kcl +snapshot_kind: text +--- +{ + "Ok": { + "body": [ + { + "declarations": [ + { + "end": 11, + "id": { + "end": 2, + "name": "r1", + "start": 0, + "type": "Identifier" + }, + "init": { + "end": 11, + "endElement": { + "end": 10, + "raw": "4", + "start": 9, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + "endInclusive": true, + "start": 5, + "startElement": { + "end": 7, + "raw": "0", + "start": 6, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + "type": "ArrayRangeExpression", + "type": "ArrayRangeExpression" + }, + "start": 0, + "type": "VariableDeclarator" + } + ], + "end": 11, + "kind": "const", + "start": 0, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "end": 70, + "expression": { + "arguments": [ + { + "computed": false, + "end": 29, + "object": { + "end": 26, + "name": "r1", + "start": 24, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 28, + "raw": "4", + "start": 27, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + "start": 24, + "type": "MemberExpression", + "type": "MemberExpression" + }, + { + "end": 32, + "raw": "4", + "start": 31, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + { + "end": 41, + "raw": "0.00001", + "start": 34, + "type": "Literal", + "type": "Literal", + "value": 0.00001 + }, + { + "end": 69, + "raw": "\"last element is included\"", + "start": 43, + "type": "Literal", + "type": "Literal", + "value": "last element is included" + } + ], + "callee": { + "end": 23, + "name": "assertEqual", + "start": 12, + "type": "Identifier" + }, + "end": 70, + "optional": false, + "start": 12, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 12, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "declarations": [ + { + "end": 80, + "id": { + "end": 76, + "name": "four", + "start": 72, + "type": "Identifier" + }, + "init": { + "end": 80, + "raw": "4", + "start": 79, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + "start": 72, + "type": "VariableDeclarator" + } + ], + "end": 80, + "kind": "const", + "start": 72, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declarations": [ + { + "end": 89, + "id": { + "end": 85, + "name": "zero", + "start": 81, + "type": "Identifier" + }, + "init": { + "end": 89, + "raw": "0", + "start": 88, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + "start": 81, + "type": "VariableDeclarator" + } + ], + "end": 89, + "kind": "const", + "start": 81, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declarations": [ + { + "end": 107, + "id": { + "end": 92, + "name": "r2", + "start": 90, + "type": "Identifier" + }, + "init": { + "end": 107, + "endElement": { + "end": 106, + "name": "four", + "start": 102, + "type": "Identifier", + "type": "Identifier" + }, + "endInclusive": true, + "start": 95, + "startElement": { + "end": 100, + "name": "zero", + "start": 96, + "type": "Identifier", + "type": "Identifier" + }, + "type": "ArrayRangeExpression", + "type": "ArrayRangeExpression" + }, + "start": 90, + "type": "VariableDeclarator" + } + ], + "end": 107, + "kind": "const", + "start": 90, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "end": 166, + "expression": { + "arguments": [ + { + "computed": false, + "end": 125, + "object": { + "end": 122, + "name": "r2", + "start": 120, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 124, + "raw": "4", + "start": 123, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + "start": 120, + "type": "MemberExpression", + "type": "MemberExpression" + }, + { + "end": 128, + "raw": "4", + "start": 127, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + { + "end": 137, + "raw": "0.00001", + "start": 130, + "type": "Literal", + "type": "Literal", + "value": 0.00001 + }, + { + "end": 165, + "raw": "\"last element is included\"", + "start": 139, + "type": "Literal", + "type": "Literal", + "value": "last element is included" + } + ], + "callee": { + "end": 119, + "name": "assertEqual", + "start": 108, + "type": "Identifier" + }, + "end": 166, + "optional": false, + "start": 108, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 108, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "declarations": [ + { + "end": 188, + "id": { + "end": 172, + "name": "five", + "start": 168, + "type": "Identifier" + }, + "init": { + "arguments": [ + { + "end": 187, + "left": { + "end": 183, + "name": "four", + "start": 179, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "+", + "right": { + "end": 187, + "raw": "1", + "start": 186, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + "start": 179, + "type": "BinaryExpression", + "type": "BinaryExpression" + } + ], + "callee": { + "end": 178, + "name": "int", + "start": 175, + "type": "Identifier" + }, + "end": 188, + "optional": false, + "start": 175, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 168, + "type": "VariableDeclarator" + } + ], + "end": 188, + "kind": "const", + "start": 168, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declarations": [ + { + "end": 206, + "id": { + "end": 191, + "name": "r3", + "start": 189, + "type": "Identifier" + }, + "init": { + "end": 206, + "endElement": { + "end": 205, + "name": "five", + "start": 201, + "type": "Identifier", + "type": "Identifier" + }, + "endInclusive": true, + "start": 194, + "startElement": { + "end": 199, + "name": "zero", + "start": 195, + "type": "Identifier", + "type": "Identifier" + }, + "type": "ArrayRangeExpression", + "type": "ArrayRangeExpression" + }, + "start": 189, + "type": "VariableDeclarator" + } + ], + "end": 206, + "kind": "const", + "start": 189, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "end": 275, + "expression": { + "arguments": [ + { + "computed": false, + "end": 224, + "object": { + "end": 221, + "name": "r3", + "start": 219, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 223, + "raw": "4", + "start": 222, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + "start": 219, + "type": "MemberExpression", + "type": "MemberExpression" + }, + { + "end": 227, + "raw": "4", + "start": 226, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + { + "end": 236, + "raw": "0.00001", + "start": 229, + "type": "Literal", + "type": "Literal", + "value": 0.00001 + }, + { + "end": 274, + "raw": "\"second-to-last element is included\"", + "start": 238, + "type": "Literal", + "type": "Literal", + "value": "second-to-last element is included" + } + ], + "callee": { + "end": 218, + "name": "assertEqual", + "start": 207, + "type": "Identifier" + }, + "end": 275, + "optional": false, + "start": 207, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 207, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 334, + "expression": { + "arguments": [ + { + "computed": false, + "end": 293, + "object": { + "end": 290, + "name": "r3", + "start": 288, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 292, + "raw": "5", + "start": 291, + "type": "Literal", + "type": "Literal", + "value": 5 + }, + "start": 288, + "type": "MemberExpression", + "type": "MemberExpression" + }, + { + "end": 296, + "raw": "5", + "start": 295, + "type": "Literal", + "type": "Literal", + "value": 5 + }, + { + "end": 305, + "raw": "0.00001", + "start": 298, + "type": "Literal", + "type": "Literal", + "value": 0.00001 + }, + { + "end": 333, + "raw": "\"last element is included\"", + "start": 307, + "type": "Literal", + "type": "Literal", + "value": "last element is included" + } + ], + "callee": { + "end": 287, + "name": "assertEqual", + "start": 276, + "type": "Identifier" + }, + "end": 334, + "optional": false, + "start": 276, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 276, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "declarations": [ + { + "end": 373, + "id": { + "end": 338, + "name": "r4", + "start": 336, + "type": "Identifier" + }, + "init": { + "end": 373, + "endElement": { + "arguments": [ + { + "end": 371, + "left": { + "end": 367, + "name": "five", + "start": 363, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "-", + "right": { + "end": 371, + "raw": "1", + "start": 370, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + "start": 363, + "type": "BinaryExpression", + "type": "BinaryExpression" + } + ], + "callee": { + "end": 362, + "name": "int", + "start": 359, + "type": "Identifier" + }, + "end": 372, + "optional": false, + "start": 359, + "type": "CallExpression", + "type": "CallExpression" + }, + "endInclusive": true, + "start": 341, + "startElement": { + "arguments": [ + { + "end": 354, + "left": { + "end": 350, + "name": "zero", + "start": 346, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "+", + "right": { + "end": 354, + "raw": "1", + "start": 353, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + "start": 346, + "type": "BinaryExpression", + "type": "BinaryExpression" + } + ], + "callee": { + "end": 345, + "name": "int", + "start": 342, + "type": "Identifier" + }, + "end": 355, + "optional": false, + "start": 342, + "type": "CallExpression", + "type": "CallExpression" + }, + "type": "ArrayRangeExpression", + "type": "ArrayRangeExpression" + }, + "start": 336, + "type": "VariableDeclarator" + } + ], + "end": 373, + "kind": "const", + "start": 336, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "end": 426, + "expression": { + "arguments": [ + { + "computed": false, + "end": 391, + "object": { + "end": 388, + "name": "r4", + "start": 386, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 390, + "raw": "0", + "start": 389, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + "start": 386, + "type": "MemberExpression", + "type": "MemberExpression" + }, + { + "end": 394, + "raw": "1", + "start": 393, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + { + "end": 403, + "raw": "0.00001", + "start": 396, + "type": "Literal", + "type": "Literal", + "value": 0.00001 + }, + { + "end": 425, + "raw": "\"first element is 1\"", + "start": 405, + "type": "Literal", + "type": "Literal", + "value": "first element is 1" + } + ], + "callee": { + "end": 385, + "name": "assertEqual", + "start": 374, + "type": "Identifier" + }, + "end": 426, + "optional": false, + "start": 374, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 374, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 488, + "expression": { + "arguments": [ + { + "computed": false, + "end": 444, + "object": { + "end": 441, + "name": "r4", + "start": 439, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 443, + "raw": "2", + "start": 442, + "type": "Literal", + "type": "Literal", + "value": 2 + }, + "start": 439, + "type": "MemberExpression", + "type": "MemberExpression" + }, + { + "end": 447, + "raw": "3", + "start": 446, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + { + "end": 456, + "raw": "0.00001", + "start": 449, + "type": "Literal", + "type": "Literal", + "value": 0.00001 + }, + { + "end": 487, + "raw": "\"second-to-last element is 3\"", + "start": 458, + "type": "Literal", + "type": "Literal", + "value": "second-to-last element is 3" + } + ], + "callee": { + "end": 438, + "name": "assertEqual", + "start": 427, + "type": "Identifier" + }, + "end": 488, + "optional": false, + "start": 427, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 427, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 540, + "expression": { + "arguments": [ + { + "computed": false, + "end": 506, + "object": { + "end": 503, + "name": "r4", + "start": 501, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 505, + "raw": "3", + "start": 504, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + "start": 501, + "type": "MemberExpression", + "type": "MemberExpression" + }, + { + "end": 509, + "raw": "4", + "start": 508, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + { + "end": 518, + "raw": "0.00001", + "start": 511, + "type": "Literal", + "type": "Literal", + "value": 0.00001 + }, + { + "end": 539, + "raw": "\"last element is 4\"", + "start": 520, + "type": "Literal", + "type": "Literal", + "value": "last element is 4" + } + ], + "callee": { + "end": 500, + "name": "assertEqual", + "start": 489, + "type": "Identifier" + }, + "end": 540, + "optional": false, + "start": 489, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 489, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 541, + "nonCodeMeta": { + "nonCodeNodes": { + "1": [ + { + "end": 72, + "start": 70, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "5": [ + { + "end": 168, + "start": 166, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "9": [ + { + "end": 336, + "start": 334, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ] + }, + "startNodes": [] + }, + "start": 0 + } +} diff --git a/src/wasm-lib/tests/executor/inputs/no_visuals/array_range_expr.kcl b/src/wasm-lib/kcl/tests/array_range_expr/input.kcl similarity index 100% rename from src/wasm-lib/tests/executor/inputs/no_visuals/array_range_expr.kcl rename to src/wasm-lib/kcl/tests/array_range_expr/input.kcl diff --git a/src/wasm-lib/kcl/tests/array_range_expr/program_memory.snap b/src/wasm-lib/kcl/tests/array_range_expr/program_memory.snap new file mode 100644 index 0000000000..815317548c --- /dev/null +++ b/src/wasm-lib/kcl/tests/array_range_expr/program_memory.snap @@ -0,0 +1,155 @@ +--- +source: kcl/src/simulation_tests.rs +description: Program memory after executing array_range_expr.kcl +snapshot_kind: text +--- +{ + "environments": [ + { + "bindings": { + "HALF_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 180, + "__meta": [] + }, + "QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 90, + "__meta": [] + }, + "THREE_QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 270, + "__meta": [] + }, + "ZERO": { + "type": "UserVal", + "type": "UserVal", + "value": 0, + "__meta": [] + }, + "five": { + "type": "UserVal", + "type": "UserVal", + "value": 5, + "__meta": [ + { + "sourceRange": [ + 175, + 188 + ] + } + ] + }, + "four": { + "type": "UserVal", + "type": "UserVal", + "value": 4, + "__meta": [ + { + "sourceRange": [ + 79, + 80 + ] + } + ] + }, + "r1": { + "type": "UserVal", + "type": "UserVal", + "value": [ + 0, + 1, + 2, + 3, + 4 + ], + "__meta": [ + { + "sourceRange": [ + 5, + 11 + ] + } + ] + }, + "r2": { + "type": "UserVal", + "type": "UserVal", + "value": [ + 0, + 1, + 2, + 3, + 4 + ], + "__meta": [ + { + "sourceRange": [ + 95, + 107 + ] + } + ] + }, + "r3": { + "type": "UserVal", + "type": "UserVal", + "value": [ + 0, + 1, + 2, + 3, + 4, + 5 + ], + "__meta": [ + { + "sourceRange": [ + 194, + 206 + ] + } + ] + }, + "r4": { + "type": "UserVal", + "type": "UserVal", + "value": [ + 1, + 2, + 3, + 4 + ], + "__meta": [ + { + "sourceRange": [ + 341, + 373 + ] + } + ] + }, + "zero": { + "type": "UserVal", + "type": "UserVal", + "value": 0, + "__meta": [ + { + "sourceRange": [ + 88, + 89 + ] + } + ] + } + }, + "parent": null + } + ], + "currentEnv": 0, + "return": null +} diff --git a/src/wasm-lib/kcl/tests/array_range_expr/tokens.snap b/src/wasm-lib/kcl/tests/array_range_expr/tokens.snap new file mode 100644 index 0000000000..2f2c44c39d --- /dev/null +++ b/src/wasm-lib/kcl/tests/array_range_expr/tokens.snap @@ -0,0 +1,1209 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of tokenizing array_range_expr.kcl +snapshot_kind: text +--- +{ + "Ok": [ + { + "type": "word", + "start": 0, + "end": 2, + "value": "r1" + }, + { + "type": "whitespace", + "start": 2, + "end": 3, + "value": " " + }, + { + "type": "operator", + "start": 3, + "end": 4, + "value": "=" + }, + { + "type": "whitespace", + "start": 4, + "end": 5, + "value": " " + }, + { + "type": "brace", + "start": 5, + "end": 6, + "value": "[" + }, + { + "type": "number", + "start": 6, + "end": 7, + "value": "0" + }, + { + "type": "doublePeriod", + "start": 7, + "end": 9, + "value": ".." + }, + { + "type": "number", + "start": 9, + "end": 10, + "value": "4" + }, + { + "type": "brace", + "start": 10, + "end": 11, + "value": "]" + }, + { + "type": "whitespace", + "start": 11, + "end": 12, + "value": "\n" + }, + { + "type": "word", + "start": 12, + "end": 23, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 23, + "end": 24, + "value": "(" + }, + { + "type": "word", + "start": 24, + "end": 26, + "value": "r1" + }, + { + "type": "brace", + "start": 26, + "end": 27, + "value": "[" + }, + { + "type": "number", + "start": 27, + "end": 28, + "value": "4" + }, + { + "type": "brace", + "start": 28, + "end": 29, + "value": "]" + }, + { + "type": "comma", + "start": 29, + "end": 30, + "value": "," + }, + { + "type": "whitespace", + "start": 30, + "end": 31, + "value": " " + }, + { + "type": "number", + "start": 31, + "end": 32, + "value": "4" + }, + { + "type": "comma", + "start": 32, + "end": 33, + "value": "," + }, + { + "type": "whitespace", + "start": 33, + "end": 34, + "value": " " + }, + { + "type": "number", + "start": 34, + "end": 41, + "value": "0.00001" + }, + { + "type": "comma", + "start": 41, + "end": 42, + "value": "," + }, + { + "type": "whitespace", + "start": 42, + "end": 43, + "value": " " + }, + { + "type": "string", + "start": 43, + "end": 69, + "value": "\"last element is included\"" + }, + { + "type": "brace", + "start": 69, + "end": 70, + "value": ")" + }, + { + "type": "whitespace", + "start": 70, + "end": 72, + "value": "\n\n" + }, + { + "type": "word", + "start": 72, + "end": 76, + "value": "four" + }, + { + "type": "whitespace", + "start": 76, + "end": 77, + "value": " " + }, + { + "type": "operator", + "start": 77, + "end": 78, + "value": "=" + }, + { + "type": "whitespace", + "start": 78, + "end": 79, + "value": " " + }, + { + "type": "number", + "start": 79, + "end": 80, + "value": "4" + }, + { + "type": "whitespace", + "start": 80, + "end": 81, + "value": "\n" + }, + { + "type": "word", + "start": 81, + "end": 85, + "value": "zero" + }, + { + "type": "whitespace", + "start": 85, + "end": 86, + "value": " " + }, + { + "type": "operator", + "start": 86, + "end": 87, + "value": "=" + }, + { + "type": "whitespace", + "start": 87, + "end": 88, + "value": " " + }, + { + "type": "number", + "start": 88, + "end": 89, + "value": "0" + }, + { + "type": "whitespace", + "start": 89, + "end": 90, + "value": "\n" + }, + { + "type": "word", + "start": 90, + "end": 92, + "value": "r2" + }, + { + "type": "whitespace", + "start": 92, + "end": 93, + "value": " " + }, + { + "type": "operator", + "start": 93, + "end": 94, + "value": "=" + }, + { + "type": "whitespace", + "start": 94, + "end": 95, + "value": " " + }, + { + "type": "brace", + "start": 95, + "end": 96, + "value": "[" + }, + { + "type": "word", + "start": 96, + "end": 100, + "value": "zero" + }, + { + "type": "doublePeriod", + "start": 100, + "end": 102, + "value": ".." + }, + { + "type": "word", + "start": 102, + "end": 106, + "value": "four" + }, + { + "type": "brace", + "start": 106, + "end": 107, + "value": "]" + }, + { + "type": "whitespace", + "start": 107, + "end": 108, + "value": "\n" + }, + { + "type": "word", + "start": 108, + "end": 119, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 119, + "end": 120, + "value": "(" + }, + { + "type": "word", + "start": 120, + "end": 122, + "value": "r2" + }, + { + "type": "brace", + "start": 122, + "end": 123, + "value": "[" + }, + { + "type": "number", + "start": 123, + "end": 124, + "value": "4" + }, + { + "type": "brace", + "start": 124, + "end": 125, + "value": "]" + }, + { + "type": "comma", + "start": 125, + "end": 126, + "value": "," + }, + { + "type": "whitespace", + "start": 126, + "end": 127, + "value": " " + }, + { + "type": "number", + "start": 127, + "end": 128, + "value": "4" + }, + { + "type": "comma", + "start": 128, + "end": 129, + "value": "," + }, + { + "type": "whitespace", + "start": 129, + "end": 130, + "value": " " + }, + { + "type": "number", + "start": 130, + "end": 137, + "value": "0.00001" + }, + { + "type": "comma", + "start": 137, + "end": 138, + "value": "," + }, + { + "type": "whitespace", + "start": 138, + "end": 139, + "value": " " + }, + { + "type": "string", + "start": 139, + "end": 165, + "value": "\"last element is included\"" + }, + { + "type": "brace", + "start": 165, + "end": 166, + "value": ")" + }, + { + "type": "whitespace", + "start": 166, + "end": 168, + "value": "\n\n" + }, + { + "type": "word", + "start": 168, + "end": 172, + "value": "five" + }, + { + "type": "whitespace", + "start": 172, + "end": 173, + "value": " " + }, + { + "type": "operator", + "start": 173, + "end": 174, + "value": "=" + }, + { + "type": "whitespace", + "start": 174, + "end": 175, + "value": " " + }, + { + "type": "word", + "start": 175, + "end": 178, + "value": "int" + }, + { + "type": "brace", + "start": 178, + "end": 179, + "value": "(" + }, + { + "type": "word", + "start": 179, + "end": 183, + "value": "four" + }, + { + "type": "whitespace", + "start": 183, + "end": 184, + "value": " " + }, + { + "type": "operator", + "start": 184, + "end": 185, + "value": "+" + }, + { + "type": "whitespace", + "start": 185, + "end": 186, + "value": " " + }, + { + "type": "number", + "start": 186, + "end": 187, + "value": "1" + }, + { + "type": "brace", + "start": 187, + "end": 188, + "value": ")" + }, + { + "type": "whitespace", + "start": 188, + "end": 189, + "value": "\n" + }, + { + "type": "word", + "start": 189, + "end": 191, + "value": "r3" + }, + { + "type": "whitespace", + "start": 191, + "end": 192, + "value": " " + }, + { + "type": "operator", + "start": 192, + "end": 193, + "value": "=" + }, + { + "type": "whitespace", + "start": 193, + "end": 194, + "value": " " + }, + { + "type": "brace", + "start": 194, + "end": 195, + "value": "[" + }, + { + "type": "word", + "start": 195, + "end": 199, + "value": "zero" + }, + { + "type": "doublePeriod", + "start": 199, + "end": 201, + "value": ".." + }, + { + "type": "word", + "start": 201, + "end": 205, + "value": "five" + }, + { + "type": "brace", + "start": 205, + "end": 206, + "value": "]" + }, + { + "type": "whitespace", + "start": 206, + "end": 207, + "value": "\n" + }, + { + "type": "word", + "start": 207, + "end": 218, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 218, + "end": 219, + "value": "(" + }, + { + "type": "word", + "start": 219, + "end": 221, + "value": "r3" + }, + { + "type": "brace", + "start": 221, + "end": 222, + "value": "[" + }, + { + "type": "number", + "start": 222, + "end": 223, + "value": "4" + }, + { + "type": "brace", + "start": 223, + "end": 224, + "value": "]" + }, + { + "type": "comma", + "start": 224, + "end": 225, + "value": "," + }, + { + "type": "whitespace", + "start": 225, + "end": 226, + "value": " " + }, + { + "type": "number", + "start": 226, + "end": 227, + "value": "4" + }, + { + "type": "comma", + "start": 227, + "end": 228, + "value": "," + }, + { + "type": "whitespace", + "start": 228, + "end": 229, + "value": " " + }, + { + "type": "number", + "start": 229, + "end": 236, + "value": "0.00001" + }, + { + "type": "comma", + "start": 236, + "end": 237, + "value": "," + }, + { + "type": "whitespace", + "start": 237, + "end": 238, + "value": " " + }, + { + "type": "string", + "start": 238, + "end": 274, + "value": "\"second-to-last element is included\"" + }, + { + "type": "brace", + "start": 274, + "end": 275, + "value": ")" + }, + { + "type": "whitespace", + "start": 275, + "end": 276, + "value": "\n" + }, + { + "type": "word", + "start": 276, + "end": 287, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 287, + "end": 288, + "value": "(" + }, + { + "type": "word", + "start": 288, + "end": 290, + "value": "r3" + }, + { + "type": "brace", + "start": 290, + "end": 291, + "value": "[" + }, + { + "type": "number", + "start": 291, + "end": 292, + "value": "5" + }, + { + "type": "brace", + "start": 292, + "end": 293, + "value": "]" + }, + { + "type": "comma", + "start": 293, + "end": 294, + "value": "," + }, + { + "type": "whitespace", + "start": 294, + "end": 295, + "value": " " + }, + { + "type": "number", + "start": 295, + "end": 296, + "value": "5" + }, + { + "type": "comma", + "start": 296, + "end": 297, + "value": "," + }, + { + "type": "whitespace", + "start": 297, + "end": 298, + "value": " " + }, + { + "type": "number", + "start": 298, + "end": 305, + "value": "0.00001" + }, + { + "type": "comma", + "start": 305, + "end": 306, + "value": "," + }, + { + "type": "whitespace", + "start": 306, + "end": 307, + "value": " " + }, + { + "type": "string", + "start": 307, + "end": 333, + "value": "\"last element is included\"" + }, + { + "type": "brace", + "start": 333, + "end": 334, + "value": ")" + }, + { + "type": "whitespace", + "start": 334, + "end": 336, + "value": "\n\n" + }, + { + "type": "word", + "start": 336, + "end": 338, + "value": "r4" + }, + { + "type": "whitespace", + "start": 338, + "end": 339, + "value": " " + }, + { + "type": "operator", + "start": 339, + "end": 340, + "value": "=" + }, + { + "type": "whitespace", + "start": 340, + "end": 341, + "value": " " + }, + { + "type": "brace", + "start": 341, + "end": 342, + "value": "[" + }, + { + "type": "word", + "start": 342, + "end": 345, + "value": "int" + }, + { + "type": "brace", + "start": 345, + "end": 346, + "value": "(" + }, + { + "type": "word", + "start": 346, + "end": 350, + "value": "zero" + }, + { + "type": "whitespace", + "start": 350, + "end": 351, + "value": " " + }, + { + "type": "operator", + "start": 351, + "end": 352, + "value": "+" + }, + { + "type": "whitespace", + "start": 352, + "end": 353, + "value": " " + }, + { + "type": "number", + "start": 353, + "end": 354, + "value": "1" + }, + { + "type": "brace", + "start": 354, + "end": 355, + "value": ")" + }, + { + "type": "whitespace", + "start": 355, + "end": 356, + "value": " " + }, + { + "type": "doublePeriod", + "start": 356, + "end": 358, + "value": ".." + }, + { + "type": "whitespace", + "start": 358, + "end": 359, + "value": " " + }, + { + "type": "word", + "start": 359, + "end": 362, + "value": "int" + }, + { + "type": "brace", + "start": 362, + "end": 363, + "value": "(" + }, + { + "type": "word", + "start": 363, + "end": 367, + "value": "five" + }, + { + "type": "whitespace", + "start": 367, + "end": 368, + "value": " " + }, + { + "type": "operator", + "start": 368, + "end": 369, + "value": "-" + }, + { + "type": "whitespace", + "start": 369, + "end": 370, + "value": " " + }, + { + "type": "number", + "start": 370, + "end": 371, + "value": "1" + }, + { + "type": "brace", + "start": 371, + "end": 372, + "value": ")" + }, + { + "type": "brace", + "start": 372, + "end": 373, + "value": "]" + }, + { + "type": "whitespace", + "start": 373, + "end": 374, + "value": "\n" + }, + { + "type": "word", + "start": 374, + "end": 385, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 385, + "end": 386, + "value": "(" + }, + { + "type": "word", + "start": 386, + "end": 388, + "value": "r4" + }, + { + "type": "brace", + "start": 388, + "end": 389, + "value": "[" + }, + { + "type": "number", + "start": 389, + "end": 390, + "value": "0" + }, + { + "type": "brace", + "start": 390, + "end": 391, + "value": "]" + }, + { + "type": "comma", + "start": 391, + "end": 392, + "value": "," + }, + { + "type": "whitespace", + "start": 392, + "end": 393, + "value": " " + }, + { + "type": "number", + "start": 393, + "end": 394, + "value": "1" + }, + { + "type": "comma", + "start": 394, + "end": 395, + "value": "," + }, + { + "type": "whitespace", + "start": 395, + "end": 396, + "value": " " + }, + { + "type": "number", + "start": 396, + "end": 403, + "value": "0.00001" + }, + { + "type": "comma", + "start": 403, + "end": 404, + "value": "," + }, + { + "type": "whitespace", + "start": 404, + "end": 405, + "value": " " + }, + { + "type": "string", + "start": 405, + "end": 425, + "value": "\"first element is 1\"" + }, + { + "type": "brace", + "start": 425, + "end": 426, + "value": ")" + }, + { + "type": "whitespace", + "start": 426, + "end": 427, + "value": "\n" + }, + { + "type": "word", + "start": 427, + "end": 438, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 438, + "end": 439, + "value": "(" + }, + { + "type": "word", + "start": 439, + "end": 441, + "value": "r4" + }, + { + "type": "brace", + "start": 441, + "end": 442, + "value": "[" + }, + { + "type": "number", + "start": 442, + "end": 443, + "value": "2" + }, + { + "type": "brace", + "start": 443, + "end": 444, + "value": "]" + }, + { + "type": "comma", + "start": 444, + "end": 445, + "value": "," + }, + { + "type": "whitespace", + "start": 445, + "end": 446, + "value": " " + }, + { + "type": "number", + "start": 446, + "end": 447, + "value": "3" + }, + { + "type": "comma", + "start": 447, + "end": 448, + "value": "," + }, + { + "type": "whitespace", + "start": 448, + "end": 449, + "value": " " + }, + { + "type": "number", + "start": 449, + "end": 456, + "value": "0.00001" + }, + { + "type": "comma", + "start": 456, + "end": 457, + "value": "," + }, + { + "type": "whitespace", + "start": 457, + "end": 458, + "value": " " + }, + { + "type": "string", + "start": 458, + "end": 487, + "value": "\"second-to-last element is 3\"" + }, + { + "type": "brace", + "start": 487, + "end": 488, + "value": ")" + }, + { + "type": "whitespace", + "start": 488, + "end": 489, + "value": "\n" + }, + { + "type": "word", + "start": 489, + "end": 500, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 500, + "end": 501, + "value": "(" + }, + { + "type": "word", + "start": 501, + "end": 503, + "value": "r4" + }, + { + "type": "brace", + "start": 503, + "end": 504, + "value": "[" + }, + { + "type": "number", + "start": 504, + "end": 505, + "value": "3" + }, + { + "type": "brace", + "start": 505, + "end": 506, + "value": "]" + }, + { + "type": "comma", + "start": 506, + "end": 507, + "value": "," + }, + { + "type": "whitespace", + "start": 507, + "end": 508, + "value": " " + }, + { + "type": "number", + "start": 508, + "end": 509, + "value": "4" + }, + { + "type": "comma", + "start": 509, + "end": 510, + "value": "," + }, + { + "type": "whitespace", + "start": 510, + "end": 511, + "value": " " + }, + { + "type": "number", + "start": 511, + "end": 518, + "value": "0.00001" + }, + { + "type": "comma", + "start": 518, + "end": 519, + "value": "," + }, + { + "type": "whitespace", + "start": 519, + "end": 520, + "value": " " + }, + { + "type": "string", + "start": 520, + "end": 539, + "value": "\"last element is 4\"" + }, + { + "type": "brace", + "start": 539, + "end": 540, + "value": ")" + }, + { + "type": "whitespace", + "start": 540, + "end": 541, + "value": "\n" + } + ] +} diff --git a/src/wasm-lib/kcl/tests/array_range_negative_expr/ast.snap b/src/wasm-lib/kcl/tests/array_range_negative_expr/ast.snap new file mode 100644 index 0000000000..27b4037782 --- /dev/null +++ b/src/wasm-lib/kcl/tests/array_range_negative_expr/ast.snap @@ -0,0 +1,152 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of parsing array_range_negative_expr.kcl +snapshot_kind: text +--- +{ + "Ok": { + "body": [ + { + "declarations": [ + { + "end": 19, + "id": { + "end": 2, + "name": "xs", + "start": 0, + "type": "Identifier" + }, + "init": { + "end": 19, + "endElement": { + "end": 18, + "raw": "5", + "start": 17, + "type": "Literal", + "type": "Literal", + "value": 5 + }, + "endInclusive": true, + "start": 5, + "startElement": { + "arguments": [ + { + "argument": { + "end": 12, + "raw": "5", + "start": 11, + "type": "Literal", + "type": "Literal", + "value": 5 + }, + "end": 12, + "operator": "-", + "start": 10, + "type": "UnaryExpression", + "type": "UnaryExpression" + } + ], + "callee": { + "end": 9, + "name": "int", + "start": 6, + "type": "Identifier" + }, + "end": 13, + "optional": false, + "start": 6, + "type": "CallExpression", + "type": "CallExpression" + }, + "type": "ArrayRangeExpression", + "type": "ArrayRangeExpression" + }, + "start": 0, + "type": "VariableDeclarator" + } + ], + "end": 19, + "kind": "const", + "start": 0, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "end": 72, + "expression": { + "arguments": [ + { + "computed": false, + "end": 37, + "object": { + "end": 34, + "name": "xs", + "start": 32, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 36, + "raw": "0", + "start": 35, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + "start": 32, + "type": "MemberExpression", + "type": "MemberExpression" + }, + { + "argument": { + "end": 41, + "raw": "5", + "start": 40, + "type": "Literal", + "type": "Literal", + "value": 5 + }, + "end": 41, + "operator": "-", + "start": 39, + "type": "UnaryExpression", + "type": "UnaryExpression" + }, + { + "end": 48, + "raw": "0.001", + "start": 43, + "type": "Literal", + "type": "Literal", + "value": 0.001 + }, + { + "end": 71, + "raw": "\"first element is -5\"", + "start": 50, + "type": "Literal", + "type": "Literal", + "value": "first element is -5" + } + ], + "callee": { + "end": 31, + "name": "assertEqual", + "start": 20, + "type": "Identifier" + }, + "end": 72, + "optional": false, + "start": 20, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 20, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 73, + "start": 0 + } +} diff --git a/src/wasm-lib/tests/executor/inputs/no_visuals/array_range_negative_expr.kcl b/src/wasm-lib/kcl/tests/array_range_negative_expr/input.kcl similarity index 72% rename from src/wasm-lib/tests/executor/inputs/no_visuals/array_range_negative_expr.kcl rename to src/wasm-lib/kcl/tests/array_range_negative_expr/input.kcl index afaf12635d..5fc7e8d12f 100644 --- a/src/wasm-lib/tests/executor/inputs/no_visuals/array_range_negative_expr.kcl +++ b/src/wasm-lib/kcl/tests/array_range_negative_expr/input.kcl @@ -1,2 +1,2 @@ -xs = [int(-5)..5] +xs = [int(-5) .. 5] assertEqual(xs[0], -5, 0.001, "first element is -5") diff --git a/src/wasm-lib/kcl/tests/array_range_negative_expr/program_memory.snap b/src/wasm-lib/kcl/tests/array_range_negative_expr/program_memory.snap new file mode 100644 index 0000000000..bcc0be7448 --- /dev/null +++ b/src/wasm-lib/kcl/tests/array_range_negative_expr/program_memory.snap @@ -0,0 +1,65 @@ +--- +source: kcl/src/simulation_tests.rs +description: Program memory after executing array_range_negative_expr.kcl +snapshot_kind: text +--- +{ + "environments": [ + { + "bindings": { + "HALF_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 180, + "__meta": [] + }, + "QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 90, + "__meta": [] + }, + "THREE_QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 270, + "__meta": [] + }, + "ZERO": { + "type": "UserVal", + "type": "UserVal", + "value": 0, + "__meta": [] + }, + "xs": { + "type": "UserVal", + "type": "UserVal", + "value": [ + -5, + -4, + -3, + -2, + -1, + 0, + 1, + 2, + 3, + 4, + 5 + ], + "__meta": [ + { + "sourceRange": [ + 5, + 19 + ] + } + ] + } + }, + "parent": null + } + ], + "currentEnv": 0, + "return": null +} diff --git a/src/wasm-lib/kcl/tests/array_range_negative_expr/tokens.snap b/src/wasm-lib/kcl/tests/array_range_negative_expr/tokens.snap new file mode 100644 index 0000000000..436d0c45c2 --- /dev/null +++ b/src/wasm-lib/kcl/tests/array_range_negative_expr/tokens.snap @@ -0,0 +1,213 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of tokenizing array_range_negative_expr.kcl +snapshot_kind: text +--- +{ + "Ok": [ + { + "type": "word", + "start": 0, + "end": 2, + "value": "xs" + }, + { + "type": "whitespace", + "start": 2, + "end": 3, + "value": " " + }, + { + "type": "operator", + "start": 3, + "end": 4, + "value": "=" + }, + { + "type": "whitespace", + "start": 4, + "end": 5, + "value": " " + }, + { + "type": "brace", + "start": 5, + "end": 6, + "value": "[" + }, + { + "type": "word", + "start": 6, + "end": 9, + "value": "int" + }, + { + "type": "brace", + "start": 9, + "end": 10, + "value": "(" + }, + { + "type": "operator", + "start": 10, + "end": 11, + "value": "-" + }, + { + "type": "number", + "start": 11, + "end": 12, + "value": "5" + }, + { + "type": "brace", + "start": 12, + "end": 13, + "value": ")" + }, + { + "type": "whitespace", + "start": 13, + "end": 14, + "value": " " + }, + { + "type": "doublePeriod", + "start": 14, + "end": 16, + "value": ".." + }, + { + "type": "whitespace", + "start": 16, + "end": 17, + "value": " " + }, + { + "type": "number", + "start": 17, + "end": 18, + "value": "5" + }, + { + "type": "brace", + "start": 18, + "end": 19, + "value": "]" + }, + { + "type": "whitespace", + "start": 19, + "end": 20, + "value": "\n" + }, + { + "type": "word", + "start": 20, + "end": 31, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 31, + "end": 32, + "value": "(" + }, + { + "type": "word", + "start": 32, + "end": 34, + "value": "xs" + }, + { + "type": "brace", + "start": 34, + "end": 35, + "value": "[" + }, + { + "type": "number", + "start": 35, + "end": 36, + "value": "0" + }, + { + "type": "brace", + "start": 36, + "end": 37, + "value": "]" + }, + { + "type": "comma", + "start": 37, + "end": 38, + "value": "," + }, + { + "type": "whitespace", + "start": 38, + "end": 39, + "value": " " + }, + { + "type": "operator", + "start": 39, + "end": 40, + "value": "-" + }, + { + "type": "number", + "start": 40, + "end": 41, + "value": "5" + }, + { + "type": "comma", + "start": 41, + "end": 42, + "value": "," + }, + { + "type": "whitespace", + "start": 42, + "end": 43, + "value": " " + }, + { + "type": "number", + "start": 43, + "end": 48, + "value": "0.001" + }, + { + "type": "comma", + "start": 48, + "end": 49, + "value": "," + }, + { + "type": "whitespace", + "start": 49, + "end": 50, + "value": " " + }, + { + "type": "string", + "start": 50, + "end": 71, + "value": "\"first element is -5\"" + }, + { + "type": "brace", + "start": 71, + "end": 72, + "value": ")" + }, + { + "type": "whitespace", + "start": 72, + "end": 73, + "value": "\n" + } + ] +} diff --git a/src/wasm-lib/kcl/tests/comparisons/ast.snap b/src/wasm-lib/kcl/tests/comparisons/ast.snap new file mode 100644 index 0000000000..6d89ed5633 --- /dev/null +++ b/src/wasm-lib/kcl/tests/comparisons/ast.snap @@ -0,0 +1,659 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of parsing comparisons.kcl +snapshot_kind: text +--- +{ + "Ok": { + "body": [ + { + "end": 26, + "expression": { + "arguments": [ + { + "end": 13, + "left": { + "end": 8, + "raw": "3", + "start": 7, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + "operator": "==", + "right": { + "end": 13, + "raw": "3", + "start": 12, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + "start": 7, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + { + "end": 25, + "raw": "\"equality\"", + "start": 15, + "type": "Literal", + "type": "Literal", + "value": "equality" + } + ], + "callee": { + "end": 6, + "name": "assert", + "start": 0, + "type": "Identifier" + }, + "end": 26, + "optional": false, + "start": 0, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 0, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 67, + "expression": { + "arguments": [ + { + "end": 44, + "left": { + "end": 37, + "raw": "3.0", + "start": 34, + "type": "Literal", + "type": "Literal", + "value": 3.0 + }, + "operator": "==", + "right": { + "end": 44, + "raw": "3.0", + "start": 41, + "type": "Literal", + "type": "Literal", + "value": 3.0 + }, + "start": 34, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + { + "end": 66, + "raw": "\"equality of floats\"", + "start": 46, + "type": "Literal", + "type": "Literal", + "value": "equality of floats" + } + ], + "callee": { + "end": 33, + "name": "assert", + "start": 27, + "type": "Identifier" + }, + "end": 67, + "optional": false, + "start": 27, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 27, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 98, + "expression": { + "arguments": [ + { + "end": 81, + "left": { + "end": 76, + "raw": "3", + "start": 75, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + "operator": "!=", + "right": { + "end": 81, + "raw": "4", + "start": 80, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + "start": 75, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + { + "end": 97, + "raw": "\"non-equality\"", + "start": 83, + "type": "Literal", + "type": "Literal", + "value": "non-equality" + } + ], + "callee": { + "end": 74, + "name": "assert", + "start": 68, + "type": "Identifier" + }, + "end": 98, + "optional": false, + "start": 68, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 68, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 143, + "expression": { + "arguments": [ + { + "end": 116, + "left": { + "end": 109, + "raw": "3.0", + "start": 106, + "type": "Literal", + "type": "Literal", + "value": 3.0 + }, + "operator": "!=", + "right": { + "end": 116, + "raw": "4.0", + "start": 113, + "type": "Literal", + "type": "Literal", + "value": 4.0 + }, + "start": 106, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + { + "end": 142, + "raw": "\"non-equality of floats\"", + "start": 118, + "type": "Literal", + "type": "Literal", + "value": "non-equality of floats" + } + ], + "callee": { + "end": 105, + "name": "assert", + "start": 99, + "type": "Identifier" + }, + "end": 143, + "optional": false, + "start": 99, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 99, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 163, + "expression": { + "arguments": [ + { + "end": 156, + "left": { + "end": 152, + "raw": "3", + "start": 151, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + "operator": "<", + "right": { + "end": 156, + "raw": "4", + "start": 155, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + "start": 151, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + { + "end": 162, + "raw": "\"lt\"", + "start": 158, + "type": "Literal", + "type": "Literal", + "value": "lt" + } + ], + "callee": { + "end": 150, + "name": "assert", + "start": 144, + "type": "Identifier" + }, + "end": 163, + "optional": false, + "start": 144, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 144, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 201, + "expression": { + "arguments": [ + { + "end": 177, + "left": { + "end": 172, + "raw": "3", + "start": 171, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + "operator": "<=", + "right": { + "end": 177, + "raw": "4", + "start": 176, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + "start": 171, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + { + "end": 200, + "raw": "\"lte but actually lt\"", + "start": 179, + "type": "Literal", + "type": "Literal", + "value": "lte but actually lt" + } + ], + "callee": { + "end": 170, + "name": "assert", + "start": 164, + "type": "Identifier" + }, + "end": 201, + "optional": false, + "start": 164, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 164, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 239, + "expression": { + "arguments": [ + { + "end": 215, + "left": { + "end": 210, + "raw": "4", + "start": 209, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + "operator": "<=", + "right": { + "end": 215, + "raw": "4", + "start": 214, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + "start": 209, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + { + "end": 238, + "raw": "\"lte but actually eq\"", + "start": 217, + "type": "Literal", + "type": "Literal", + "value": "lte but actually eq" + } + ], + "callee": { + "end": 208, + "name": "assert", + "start": 202, + "type": "Identifier" + }, + "end": 239, + "optional": false, + "start": 202, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 202, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 259, + "expression": { + "arguments": [ + { + "end": 252, + "left": { + "end": 248, + "raw": "4", + "start": 247, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + "operator": ">", + "right": { + "end": 252, + "raw": "3", + "start": 251, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + "start": 247, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + { + "end": 258, + "raw": "\"gt\"", + "start": 254, + "type": "Literal", + "type": "Literal", + "value": "gt" + } + ], + "callee": { + "end": 246, + "name": "assert", + "start": 240, + "type": "Identifier" + }, + "end": 259, + "optional": false, + "start": 240, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 240, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 297, + "expression": { + "arguments": [ + { + "end": 273, + "left": { + "end": 268, + "raw": "4", + "start": 267, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + "operator": ">=", + "right": { + "end": 273, + "raw": "3", + "start": 272, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + "start": 267, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + { + "end": 296, + "raw": "\"gte but actually gt\"", + "start": 275, + "type": "Literal", + "type": "Literal", + "value": "gte but actually gt" + } + ], + "callee": { + "end": 266, + "name": "assert", + "start": 260, + "type": "Identifier" + }, + "end": 297, + "optional": false, + "start": 260, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 260, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 335, + "expression": { + "arguments": [ + { + "end": 311, + "left": { + "end": 306, + "raw": "3", + "start": 305, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + "operator": ">=", + "right": { + "end": 311, + "raw": "3", + "start": 310, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + "start": 305, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + { + "end": 334, + "raw": "\"gte but actually eq\"", + "start": 313, + "type": "Literal", + "type": "Literal", + "value": "gte but actually eq" + } + ], + "callee": { + "end": 304, + "name": "assert", + "start": 298, + "type": "Identifier" + }, + "end": 335, + "optional": false, + "start": 298, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 298, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 375, + "expression": { + "arguments": [ + { + "end": 354, + "left": { + "end": 347, + "raw": "0.0", + "start": 344, + "type": "Literal", + "type": "Literal", + "value": 0.0 + }, + "operator": "==", + "right": { + "end": 354, + "raw": "0.0", + "start": 351, + "type": "Literal", + "type": "Literal", + "value": 0.0 + }, + "start": 344, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + { + "end": 374, + "raw": "\"equality of zero\"", + "start": 356, + "type": "Literal", + "type": "Literal", + "value": "equality of zero" + } + ], + "callee": { + "end": 343, + "name": "assert", + "start": 337, + "type": "Identifier" + }, + "end": 375, + "optional": false, + "start": 337, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 337, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 428, + "expression": { + "arguments": [ + { + "end": 394, + "left": { + "end": 386, + "raw": "0.0", + "start": 383, + "type": "Literal", + "type": "Literal", + "value": 0.0 + }, + "operator": "==", + "right": { + "argument": { + "end": 394, + "raw": "0.0", + "start": 391, + "type": "Literal", + "type": "Literal", + "value": 0.0 + }, + "end": 394, + "operator": "-", + "start": 390, + "type": "UnaryExpression", + "type": "UnaryExpression" + }, + "start": 383, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + { + "end": 427, + "raw": "\"equality of zero and neg zero\"", + "start": 396, + "type": "Literal", + "type": "Literal", + "value": "equality of zero and neg zero" + } + ], + "callee": { + "end": 382, + "name": "assert", + "start": 376, + "type": "Identifier" + }, + "end": 428, + "optional": false, + "start": 376, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 376, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 429, + "nonCodeMeta": { + "nonCodeNodes": { + "9": [ + { + "end": 337, + "start": 335, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ] + }, + "startNodes": [] + }, + "start": 0 + } +} diff --git a/src/wasm-lib/tests/executor/inputs/no_visuals/comparisons.kcl b/src/wasm-lib/kcl/tests/comparisons/input.kcl similarity index 100% rename from src/wasm-lib/tests/executor/inputs/no_visuals/comparisons.kcl rename to src/wasm-lib/kcl/tests/comparisons/input.kcl diff --git a/src/wasm-lib/kcl/tests/comparisons/program_memory.snap b/src/wasm-lib/kcl/tests/comparisons/program_memory.snap new file mode 100644 index 0000000000..1d8fb2ed8f --- /dev/null +++ b/src/wasm-lib/kcl/tests/comparisons/program_memory.snap @@ -0,0 +1,40 @@ +--- +source: kcl/src/simulation_tests.rs +description: Program memory after executing comparisons.kcl +snapshot_kind: text +--- +{ + "environments": [ + { + "bindings": { + "HALF_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 180, + "__meta": [] + }, + "QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 90, + "__meta": [] + }, + "THREE_QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 270, + "__meta": [] + }, + "ZERO": { + "type": "UserVal", + "type": "UserVal", + "value": 0, + "__meta": [] + } + }, + "parent": null + } + ], + "currentEnv": 0, + "return": null +} diff --git a/src/wasm-lib/kcl/tests/comparisons/tokens.snap b/src/wasm-lib/kcl/tests/comparisons/tokens.snap new file mode 100644 index 0000000000..2700f7e9d7 --- /dev/null +++ b/src/wasm-lib/kcl/tests/comparisons/tokens.snap @@ -0,0 +1,879 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of tokenizing comparisons.kcl +snapshot_kind: text +--- +{ + "Ok": [ + { + "type": "word", + "start": 0, + "end": 6, + "value": "assert" + }, + { + "type": "brace", + "start": 6, + "end": 7, + "value": "(" + }, + { + "type": "number", + "start": 7, + "end": 8, + "value": "3" + }, + { + "type": "whitespace", + "start": 8, + "end": 9, + "value": " " + }, + { + "type": "operator", + "start": 9, + "end": 11, + "value": "==" + }, + { + "type": "whitespace", + "start": 11, + "end": 12, + "value": " " + }, + { + "type": "number", + "start": 12, + "end": 13, + "value": "3" + }, + { + "type": "comma", + "start": 13, + "end": 14, + "value": "," + }, + { + "type": "whitespace", + "start": 14, + "end": 15, + "value": " " + }, + { + "type": "string", + "start": 15, + "end": 25, + "value": "\"equality\"" + }, + { + "type": "brace", + "start": 25, + "end": 26, + "value": ")" + }, + { + "type": "whitespace", + "start": 26, + "end": 27, + "value": "\n" + }, + { + "type": "word", + "start": 27, + "end": 33, + "value": "assert" + }, + { + "type": "brace", + "start": 33, + "end": 34, + "value": "(" + }, + { + "type": "number", + "start": 34, + "end": 37, + "value": "3.0" + }, + { + "type": "whitespace", + "start": 37, + "end": 38, + "value": " " + }, + { + "type": "operator", + "start": 38, + "end": 40, + "value": "==" + }, + { + "type": "whitespace", + "start": 40, + "end": 41, + "value": " " + }, + { + "type": "number", + "start": 41, + "end": 44, + "value": "3.0" + }, + { + "type": "comma", + "start": 44, + "end": 45, + "value": "," + }, + { + "type": "whitespace", + "start": 45, + "end": 46, + "value": " " + }, + { + "type": "string", + "start": 46, + "end": 66, + "value": "\"equality of floats\"" + }, + { + "type": "brace", + "start": 66, + "end": 67, + "value": ")" + }, + { + "type": "whitespace", + "start": 67, + "end": 68, + "value": "\n" + }, + { + "type": "word", + "start": 68, + "end": 74, + "value": "assert" + }, + { + "type": "brace", + "start": 74, + "end": 75, + "value": "(" + }, + { + "type": "number", + "start": 75, + "end": 76, + "value": "3" + }, + { + "type": "whitespace", + "start": 76, + "end": 77, + "value": " " + }, + { + "type": "operator", + "start": 77, + "end": 79, + "value": "!=" + }, + { + "type": "whitespace", + "start": 79, + "end": 80, + "value": " " + }, + { + "type": "number", + "start": 80, + "end": 81, + "value": "4" + }, + { + "type": "comma", + "start": 81, + "end": 82, + "value": "," + }, + { + "type": "whitespace", + "start": 82, + "end": 83, + "value": " " + }, + { + "type": "string", + "start": 83, + "end": 97, + "value": "\"non-equality\"" + }, + { + "type": "brace", + "start": 97, + "end": 98, + "value": ")" + }, + { + "type": "whitespace", + "start": 98, + "end": 99, + "value": "\n" + }, + { + "type": "word", + "start": 99, + "end": 105, + "value": "assert" + }, + { + "type": "brace", + "start": 105, + "end": 106, + "value": "(" + }, + { + "type": "number", + "start": 106, + "end": 109, + "value": "3.0" + }, + { + "type": "whitespace", + "start": 109, + "end": 110, + "value": " " + }, + { + "type": "operator", + "start": 110, + "end": 112, + "value": "!=" + }, + { + "type": "whitespace", + "start": 112, + "end": 113, + "value": " " + }, + { + "type": "number", + "start": 113, + "end": 116, + "value": "4.0" + }, + { + "type": "comma", + "start": 116, + "end": 117, + "value": "," + }, + { + "type": "whitespace", + "start": 117, + "end": 118, + "value": " " + }, + { + "type": "string", + "start": 118, + "end": 142, + "value": "\"non-equality of floats\"" + }, + { + "type": "brace", + "start": 142, + "end": 143, + "value": ")" + }, + { + "type": "whitespace", + "start": 143, + "end": 144, + "value": "\n" + }, + { + "type": "word", + "start": 144, + "end": 150, + "value": "assert" + }, + { + "type": "brace", + "start": 150, + "end": 151, + "value": "(" + }, + { + "type": "number", + "start": 151, + "end": 152, + "value": "3" + }, + { + "type": "whitespace", + "start": 152, + "end": 153, + "value": " " + }, + { + "type": "operator", + "start": 153, + "end": 154, + "value": "<" + }, + { + "type": "whitespace", + "start": 154, + "end": 155, + "value": " " + }, + { + "type": "number", + "start": 155, + "end": 156, + "value": "4" + }, + { + "type": "comma", + "start": 156, + "end": 157, + "value": "," + }, + { + "type": "whitespace", + "start": 157, + "end": 158, + "value": " " + }, + { + "type": "string", + "start": 158, + "end": 162, + "value": "\"lt\"" + }, + { + "type": "brace", + "start": 162, + "end": 163, + "value": ")" + }, + { + "type": "whitespace", + "start": 163, + "end": 164, + "value": "\n" + }, + { + "type": "word", + "start": 164, + "end": 170, + "value": "assert" + }, + { + "type": "brace", + "start": 170, + "end": 171, + "value": "(" + }, + { + "type": "number", + "start": 171, + "end": 172, + "value": "3" + }, + { + "type": "whitespace", + "start": 172, + "end": 173, + "value": " " + }, + { + "type": "operator", + "start": 173, + "end": 175, + "value": "<=" + }, + { + "type": "whitespace", + "start": 175, + "end": 176, + "value": " " + }, + { + "type": "number", + "start": 176, + "end": 177, + "value": "4" + }, + { + "type": "comma", + "start": 177, + "end": 178, + "value": "," + }, + { + "type": "whitespace", + "start": 178, + "end": 179, + "value": " " + }, + { + "type": "string", + "start": 179, + "end": 200, + "value": "\"lte but actually lt\"" + }, + { + "type": "brace", + "start": 200, + "end": 201, + "value": ")" + }, + { + "type": "whitespace", + "start": 201, + "end": 202, + "value": "\n" + }, + { + "type": "word", + "start": 202, + "end": 208, + "value": "assert" + }, + { + "type": "brace", + "start": 208, + "end": 209, + "value": "(" + }, + { + "type": "number", + "start": 209, + "end": 210, + "value": "4" + }, + { + "type": "whitespace", + "start": 210, + "end": 211, + "value": " " + }, + { + "type": "operator", + "start": 211, + "end": 213, + "value": "<=" + }, + { + "type": "whitespace", + "start": 213, + "end": 214, + "value": " " + }, + { + "type": "number", + "start": 214, + "end": 215, + "value": "4" + }, + { + "type": "comma", + "start": 215, + "end": 216, + "value": "," + }, + { + "type": "whitespace", + "start": 216, + "end": 217, + "value": " " + }, + { + "type": "string", + "start": 217, + "end": 238, + "value": "\"lte but actually eq\"" + }, + { + "type": "brace", + "start": 238, + "end": 239, + "value": ")" + }, + { + "type": "whitespace", + "start": 239, + "end": 240, + "value": "\n" + }, + { + "type": "word", + "start": 240, + "end": 246, + "value": "assert" + }, + { + "type": "brace", + "start": 246, + "end": 247, + "value": "(" + }, + { + "type": "number", + "start": 247, + "end": 248, + "value": "4" + }, + { + "type": "whitespace", + "start": 248, + "end": 249, + "value": " " + }, + { + "type": "operator", + "start": 249, + "end": 250, + "value": ">" + }, + { + "type": "whitespace", + "start": 250, + "end": 251, + "value": " " + }, + { + "type": "number", + "start": 251, + "end": 252, + "value": "3" + }, + { + "type": "comma", + "start": 252, + "end": 253, + "value": "," + }, + { + "type": "whitespace", + "start": 253, + "end": 254, + "value": " " + }, + { + "type": "string", + "start": 254, + "end": 258, + "value": "\"gt\"" + }, + { + "type": "brace", + "start": 258, + "end": 259, + "value": ")" + }, + { + "type": "whitespace", + "start": 259, + "end": 260, + "value": "\n" + }, + { + "type": "word", + "start": 260, + "end": 266, + "value": "assert" + }, + { + "type": "brace", + "start": 266, + "end": 267, + "value": "(" + }, + { + "type": "number", + "start": 267, + "end": 268, + "value": "4" + }, + { + "type": "whitespace", + "start": 268, + "end": 269, + "value": " " + }, + { + "type": "operator", + "start": 269, + "end": 271, + "value": ">=" + }, + { + "type": "whitespace", + "start": 271, + "end": 272, + "value": " " + }, + { + "type": "number", + "start": 272, + "end": 273, + "value": "3" + }, + { + "type": "comma", + "start": 273, + "end": 274, + "value": "," + }, + { + "type": "whitespace", + "start": 274, + "end": 275, + "value": " " + }, + { + "type": "string", + "start": 275, + "end": 296, + "value": "\"gte but actually gt\"" + }, + { + "type": "brace", + "start": 296, + "end": 297, + "value": ")" + }, + { + "type": "whitespace", + "start": 297, + "end": 298, + "value": "\n" + }, + { + "type": "word", + "start": 298, + "end": 304, + "value": "assert" + }, + { + "type": "brace", + "start": 304, + "end": 305, + "value": "(" + }, + { + "type": "number", + "start": 305, + "end": 306, + "value": "3" + }, + { + "type": "whitespace", + "start": 306, + "end": 307, + "value": " " + }, + { + "type": "operator", + "start": 307, + "end": 309, + "value": ">=" + }, + { + "type": "whitespace", + "start": 309, + "end": 310, + "value": " " + }, + { + "type": "number", + "start": 310, + "end": 311, + "value": "3" + }, + { + "type": "comma", + "start": 311, + "end": 312, + "value": "," + }, + { + "type": "whitespace", + "start": 312, + "end": 313, + "value": " " + }, + { + "type": "string", + "start": 313, + "end": 334, + "value": "\"gte but actually eq\"" + }, + { + "type": "brace", + "start": 334, + "end": 335, + "value": ")" + }, + { + "type": "whitespace", + "start": 335, + "end": 337, + "value": "\n\n" + }, + { + "type": "word", + "start": 337, + "end": 343, + "value": "assert" + }, + { + "type": "brace", + "start": 343, + "end": 344, + "value": "(" + }, + { + "type": "number", + "start": 344, + "end": 347, + "value": "0.0" + }, + { + "type": "whitespace", + "start": 347, + "end": 348, + "value": " " + }, + { + "type": "operator", + "start": 348, + "end": 350, + "value": "==" + }, + { + "type": "whitespace", + "start": 350, + "end": 351, + "value": " " + }, + { + "type": "number", + "start": 351, + "end": 354, + "value": "0.0" + }, + { + "type": "comma", + "start": 354, + "end": 355, + "value": "," + }, + { + "type": "whitespace", + "start": 355, + "end": 356, + "value": " " + }, + { + "type": "string", + "start": 356, + "end": 374, + "value": "\"equality of zero\"" + }, + { + "type": "brace", + "start": 374, + "end": 375, + "value": ")" + }, + { + "type": "whitespace", + "start": 375, + "end": 376, + "value": "\n" + }, + { + "type": "word", + "start": 376, + "end": 382, + "value": "assert" + }, + { + "type": "brace", + "start": 382, + "end": 383, + "value": "(" + }, + { + "type": "number", + "start": 383, + "end": 386, + "value": "0.0" + }, + { + "type": "whitespace", + "start": 386, + "end": 387, + "value": " " + }, + { + "type": "operator", + "start": 387, + "end": 389, + "value": "==" + }, + { + "type": "whitespace", + "start": 389, + "end": 390, + "value": " " + }, + { + "type": "operator", + "start": 390, + "end": 391, + "value": "-" + }, + { + "type": "number", + "start": 391, + "end": 394, + "value": "0.0" + }, + { + "type": "comma", + "start": 394, + "end": 395, + "value": "," + }, + { + "type": "whitespace", + "start": 395, + "end": 396, + "value": " " + }, + { + "type": "string", + "start": 396, + "end": 427, + "value": "\"equality of zero and neg zero\"" + }, + { + "type": "brace", + "start": 427, + "end": 428, + "value": ")" + }, + { + "type": "whitespace", + "start": 428, + "end": 429, + "value": "\n" + } + ] +} diff --git a/src/wasm-lib/kcl/tests/if_else/ast.snap b/src/wasm-lib/kcl/tests/if_else/ast.snap new file mode 100644 index 0000000000..507f5a315b --- /dev/null +++ b/src/wasm-lib/kcl/tests/if_else/ast.snap @@ -0,0 +1,546 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of parsing if_else.kcl +snapshot_kind: text +--- +{ + "Ok": { + "body": [ + { + "declarations": [ + { + "end": 101, + "id": { + "end": 49, + "name": "a", + "start": 48, + "type": "Identifier" + }, + "init": { + "cond": { + "end": 59, + "raw": "true", + "start": 55, + "type": "Literal", + "type": "Literal", + "value": true + }, + "digest": null, + "else_ifs": [ + { + "cond": { + "end": 80, + "raw": "true", + "start": 76, + "type": "Literal", + "type": "Literal", + "value": true + }, + "digest": null, + "end": 88, + "start": 68, + "then_val": { + "body": [ + { + "end": 86, + "expression": { + "end": 86, + "raw": "4", + "start": 85, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + "start": 85, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 87, + "start": 81 + }, + "type": "ElseIf" + } + ], + "end": 101, + "final_else": { + "body": [ + { + "end": 99, + "expression": { + "end": 99, + "raw": "5", + "start": 98, + "type": "Literal", + "type": "Literal", + "value": 5 + }, + "start": 98, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 100, + "start": 98 + }, + "start": 52, + "then_val": { + "body": [ + { + "end": 65, + "expression": { + "end": 65, + "raw": "3", + "start": 64, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + "start": 64, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 66, + "start": 64 + }, + "type": "IfExpression", + "type": "IfExpression" + }, + "start": 48, + "type": "VariableDeclarator" + } + ], + "end": 101, + "kind": "const", + "start": 48, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "end": 159, + "expression": { + "arguments": [ + { + "end": 115, + "name": "a", + "start": 114, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 118, + "raw": "3", + "start": 117, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + { + "end": 125, + "raw": "0.001", + "start": 120, + "type": "Literal", + "type": "Literal", + "value": 0.001 + }, + { + "end": 158, + "raw": "\"the 'if' branch gets returned\"", + "start": 127, + "type": "Literal", + "type": "Literal", + "value": "the 'if' branch gets returned" + } + ], + "callee": { + "end": 113, + "name": "assertEqual", + "start": 102, + "type": "Identifier" + }, + "end": 159, + "optional": false, + "start": 102, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 102, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "declarations": [ + { + "end": 215, + "id": { + "end": 162, + "name": "b", + "start": 161, + "type": "Identifier" + }, + "init": { + "cond": { + "end": 173, + "raw": "false", + "start": 168, + "type": "Literal", + "type": "Literal", + "value": false + }, + "digest": null, + "else_ifs": [ + { + "cond": { + "end": 194, + "raw": "true", + "start": 190, + "type": "Literal", + "type": "Literal", + "value": true + }, + "digest": null, + "end": 202, + "start": 182, + "then_val": { + "body": [ + { + "end": 200, + "expression": { + "end": 200, + "raw": "4", + "start": 199, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + "start": 199, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 201, + "start": 195 + }, + "type": "ElseIf" + } + ], + "end": 215, + "final_else": { + "body": [ + { + "end": 213, + "expression": { + "end": 213, + "raw": "5", + "start": 212, + "type": "Literal", + "type": "Literal", + "value": 5 + }, + "start": 212, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 214, + "start": 212 + }, + "start": 165, + "then_val": { + "body": [ + { + "end": 179, + "expression": { + "end": 179, + "raw": "3", + "start": 178, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + "start": 178, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 180, + "start": 178 + }, + "type": "IfExpression", + "type": "IfExpression" + }, + "start": 161, + "type": "VariableDeclarator" + } + ], + "end": 215, + "kind": "const", + "start": 161, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "end": 278, + "expression": { + "arguments": [ + { + "end": 229, + "name": "b", + "start": 228, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 232, + "raw": "4", + "start": 231, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + { + "end": 239, + "raw": "0.001", + "start": 234, + "type": "Literal", + "type": "Literal", + "value": 0.001 + }, + { + "end": 277, + "raw": "\"the 'else if' branch gets returned\"", + "start": 241, + "type": "Literal", + "type": "Literal", + "value": "the 'else if' branch gets returned" + } + ], + "callee": { + "end": 227, + "name": "assertEqual", + "start": 216, + "type": "Identifier" + }, + "end": 278, + "optional": false, + "start": 216, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 216, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "declarations": [ + { + "end": 335, + "id": { + "end": 281, + "name": "c", + "start": 280, + "type": "Identifier" + }, + "init": { + "cond": { + "end": 292, + "raw": "false", + "start": 287, + "type": "Literal", + "type": "Literal", + "value": false + }, + "digest": null, + "else_ifs": [ + { + "cond": { + "end": 314, + "raw": "false", + "start": 309, + "type": "Literal", + "type": "Literal", + "value": false + }, + "digest": null, + "end": 322, + "start": 301, + "then_val": { + "body": [ + { + "end": 320, + "expression": { + "end": 320, + "raw": "4", + "start": 319, + "type": "Literal", + "type": "Literal", + "value": 4 + }, + "start": 319, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 321, + "start": 315 + }, + "type": "ElseIf" + } + ], + "end": 335, + "final_else": { + "body": [ + { + "end": 333, + "expression": { + "end": 333, + "raw": "5", + "start": 332, + "type": "Literal", + "type": "Literal", + "value": 5 + }, + "start": 332, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 334, + "start": 332 + }, + "start": 284, + "then_val": { + "body": [ + { + "end": 298, + "expression": { + "end": 298, + "raw": "3", + "start": 297, + "type": "Literal", + "type": "Literal", + "value": 3 + }, + "start": 297, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 299, + "start": 297 + }, + "type": "IfExpression", + "type": "IfExpression" + }, + "start": 280, + "type": "VariableDeclarator" + } + ], + "end": 335, + "kind": "const", + "start": 280, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "end": 395, + "expression": { + "arguments": [ + { + "end": 349, + "name": "c", + "start": 348, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 352, + "raw": "5", + "start": 351, + "type": "Literal", + "type": "Literal", + "value": 5 + }, + { + "end": 359, + "raw": "0.001", + "start": 354, + "type": "Literal", + "type": "Literal", + "value": 0.001 + }, + { + "end": 394, + "raw": "\"the 'else' branch gets returned\"", + "start": 361, + "type": "Literal", + "type": "Literal", + "value": "the 'else' branch gets returned" + } + ], + "callee": { + "end": 347, + "name": "assertEqual", + "start": 336, + "type": "Identifier" + }, + "end": 395, + "optional": false, + "start": 336, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 336, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 396, + "nonCodeMeta": { + "nonCodeNodes": { + "1": [ + { + "end": 161, + "start": 159, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "3": [ + { + "end": 280, + "start": 278, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ] + }, + "startNodes": [ + { + "end": 45, + "start": 0, + "type": "NonCodeNode", + "value": { + "type": "blockComment", + "value": "This tests evaluating if-else expressions.", + "style": "line" + } + }, + { + "end": 48, + "start": 45, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ] + }, + "start": 0 + } +} diff --git a/src/wasm-lib/tests/executor/inputs/no_visuals/if_else.kcl b/src/wasm-lib/kcl/tests/if_else/input.kcl similarity index 86% rename from src/wasm-lib/tests/executor/inputs/no_visuals/if_else.kcl rename to src/wasm-lib/kcl/tests/if_else/input.kcl index 6f48c59ab2..e57aede34e 100644 --- a/src/wasm-lib/tests/executor/inputs/no_visuals/if_else.kcl +++ b/src/wasm-lib/kcl/tests/if_else/input.kcl @@ -1,6 +1,7 @@ // This tests evaluating if-else expressions. -let a = if true { + +a = if true { 3 } else if true { 4 @@ -9,7 +10,7 @@ let a = if true { } assertEqual(a, 3, 0.001, "the 'if' branch gets returned") -let b = if false { +b = if false { 3 } else if true { 4 @@ -18,7 +19,7 @@ let b = if false { } assertEqual(b, 4, 0.001, "the 'else if' branch gets returned") -let c = if false { +c = if false { 3 } else if false { 4 diff --git a/src/wasm-lib/kcl/tests/if_else/program_memory.snap b/src/wasm-lib/kcl/tests/if_else/program_memory.snap new file mode 100644 index 0000000000..c396ab169e --- /dev/null +++ b/src/wasm-lib/kcl/tests/if_else/program_memory.snap @@ -0,0 +1,79 @@ +--- +source: kcl/src/simulation_tests.rs +description: Program memory after executing if_else.kcl +snapshot_kind: text +--- +{ + "environments": [ + { + "bindings": { + "HALF_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 180, + "__meta": [] + }, + "QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 90, + "__meta": [] + }, + "THREE_QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 270, + "__meta": [] + }, + "ZERO": { + "type": "UserVal", + "type": "UserVal", + "value": 0, + "__meta": [] + }, + "a": { + "type": "UserVal", + "type": "UserVal", + "value": 3, + "__meta": [ + { + "sourceRange": [ + 64, + 65 + ] + } + ] + }, + "b": { + "type": "UserVal", + "type": "UserVal", + "value": 4, + "__meta": [ + { + "sourceRange": [ + 199, + 200 + ] + } + ] + }, + "c": { + "type": "UserVal", + "type": "UserVal", + "value": 5, + "__meta": [ + { + "sourceRange": [ + 332, + 333 + ] + } + ] + } + }, + "parent": null + } + ], + "currentEnv": 0, + "return": null +} diff --git a/src/wasm-lib/kcl/tests/if_else/tokens.snap b/src/wasm-lib/kcl/tests/if_else/tokens.snap new file mode 100644 index 0000000000..1ab77a0388 --- /dev/null +++ b/src/wasm-lib/kcl/tests/if_else/tokens.snap @@ -0,0 +1,885 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of tokenizing if_else.kcl +snapshot_kind: text +--- +{ + "Ok": [ + { + "type": "lineComment", + "start": 0, + "end": 45, + "value": "// This tests evaluating if-else expressions." + }, + { + "type": "whitespace", + "start": 45, + "end": 48, + "value": "\n\n\n" + }, + { + "type": "word", + "start": 48, + "end": 49, + "value": "a" + }, + { + "type": "whitespace", + "start": 49, + "end": 50, + "value": " " + }, + { + "type": "operator", + "start": 50, + "end": 51, + "value": "=" + }, + { + "type": "whitespace", + "start": 51, + "end": 52, + "value": " " + }, + { + "type": "keyword", + "start": 52, + "end": 54, + "value": "if" + }, + { + "type": "whitespace", + "start": 54, + "end": 55, + "value": " " + }, + { + "type": "keyword", + "start": 55, + "end": 59, + "value": "true" + }, + { + "type": "whitespace", + "start": 59, + "end": 60, + "value": " " + }, + { + "type": "brace", + "start": 60, + "end": 61, + "value": "{" + }, + { + "type": "whitespace", + "start": 61, + "end": 64, + "value": "\n " + }, + { + "type": "number", + "start": 64, + "end": 65, + "value": "3" + }, + { + "type": "whitespace", + "start": 65, + "end": 66, + "value": "\n" + }, + { + "type": "brace", + "start": 66, + "end": 67, + "value": "}" + }, + { + "type": "whitespace", + "start": 67, + "end": 68, + "value": " " + }, + { + "type": "keyword", + "start": 68, + "end": 72, + "value": "else" + }, + { + "type": "whitespace", + "start": 72, + "end": 73, + "value": " " + }, + { + "type": "keyword", + "start": 73, + "end": 75, + "value": "if" + }, + { + "type": "whitespace", + "start": 75, + "end": 76, + "value": " " + }, + { + "type": "keyword", + "start": 76, + "end": 80, + "value": "true" + }, + { + "type": "whitespace", + "start": 80, + "end": 81, + "value": " " + }, + { + "type": "brace", + "start": 81, + "end": 82, + "value": "{" + }, + { + "type": "whitespace", + "start": 82, + "end": 85, + "value": "\n " + }, + { + "type": "number", + "start": 85, + "end": 86, + "value": "4" + }, + { + "type": "whitespace", + "start": 86, + "end": 87, + "value": "\n" + }, + { + "type": "brace", + "start": 87, + "end": 88, + "value": "}" + }, + { + "type": "whitespace", + "start": 88, + "end": 89, + "value": " " + }, + { + "type": "keyword", + "start": 89, + "end": 93, + "value": "else" + }, + { + "type": "whitespace", + "start": 93, + "end": 94, + "value": " " + }, + { + "type": "brace", + "start": 94, + "end": 95, + "value": "{" + }, + { + "type": "whitespace", + "start": 95, + "end": 98, + "value": "\n " + }, + { + "type": "number", + "start": 98, + "end": 99, + "value": "5" + }, + { + "type": "whitespace", + "start": 99, + "end": 100, + "value": "\n" + }, + { + "type": "brace", + "start": 100, + "end": 101, + "value": "}" + }, + { + "type": "whitespace", + "start": 101, + "end": 102, + "value": "\n" + }, + { + "type": "word", + "start": 102, + "end": 113, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 113, + "end": 114, + "value": "(" + }, + { + "type": "word", + "start": 114, + "end": 115, + "value": "a" + }, + { + "type": "comma", + "start": 115, + "end": 116, + "value": "," + }, + { + "type": "whitespace", + "start": 116, + "end": 117, + "value": " " + }, + { + "type": "number", + "start": 117, + "end": 118, + "value": "3" + }, + { + "type": "comma", + "start": 118, + "end": 119, + "value": "," + }, + { + "type": "whitespace", + "start": 119, + "end": 120, + "value": " " + }, + { + "type": "number", + "start": 120, + "end": 125, + "value": "0.001" + }, + { + "type": "comma", + "start": 125, + "end": 126, + "value": "," + }, + { + "type": "whitespace", + "start": 126, + "end": 127, + "value": " " + }, + { + "type": "string", + "start": 127, + "end": 158, + "value": "\"the 'if' branch gets returned\"" + }, + { + "type": "brace", + "start": 158, + "end": 159, + "value": ")" + }, + { + "type": "whitespace", + "start": 159, + "end": 161, + "value": "\n\n" + }, + { + "type": "word", + "start": 161, + "end": 162, + "value": "b" + }, + { + "type": "whitespace", + "start": 162, + "end": 163, + "value": " " + }, + { + "type": "operator", + "start": 163, + "end": 164, + "value": "=" + }, + { + "type": "whitespace", + "start": 164, + "end": 165, + "value": " " + }, + { + "type": "keyword", + "start": 165, + "end": 167, + "value": "if" + }, + { + "type": "whitespace", + "start": 167, + "end": 168, + "value": " " + }, + { + "type": "keyword", + "start": 168, + "end": 173, + "value": "false" + }, + { + "type": "whitespace", + "start": 173, + "end": 174, + "value": " " + }, + { + "type": "brace", + "start": 174, + "end": 175, + "value": "{" + }, + { + "type": "whitespace", + "start": 175, + "end": 178, + "value": "\n " + }, + { + "type": "number", + "start": 178, + "end": 179, + "value": "3" + }, + { + "type": "whitespace", + "start": 179, + "end": 180, + "value": "\n" + }, + { + "type": "brace", + "start": 180, + "end": 181, + "value": "}" + }, + { + "type": "whitespace", + "start": 181, + "end": 182, + "value": " " + }, + { + "type": "keyword", + "start": 182, + "end": 186, + "value": "else" + }, + { + "type": "whitespace", + "start": 186, + "end": 187, + "value": " " + }, + { + "type": "keyword", + "start": 187, + "end": 189, + "value": "if" + }, + { + "type": "whitespace", + "start": 189, + "end": 190, + "value": " " + }, + { + "type": "keyword", + "start": 190, + "end": 194, + "value": "true" + }, + { + "type": "whitespace", + "start": 194, + "end": 195, + "value": " " + }, + { + "type": "brace", + "start": 195, + "end": 196, + "value": "{" + }, + { + "type": "whitespace", + "start": 196, + "end": 199, + "value": "\n " + }, + { + "type": "number", + "start": 199, + "end": 200, + "value": "4" + }, + { + "type": "whitespace", + "start": 200, + "end": 201, + "value": "\n" + }, + { + "type": "brace", + "start": 201, + "end": 202, + "value": "}" + }, + { + "type": "whitespace", + "start": 202, + "end": 203, + "value": " " + }, + { + "type": "keyword", + "start": 203, + "end": 207, + "value": "else" + }, + { + "type": "whitespace", + "start": 207, + "end": 208, + "value": " " + }, + { + "type": "brace", + "start": 208, + "end": 209, + "value": "{" + }, + { + "type": "whitespace", + "start": 209, + "end": 212, + "value": "\n " + }, + { + "type": "number", + "start": 212, + "end": 213, + "value": "5" + }, + { + "type": "whitespace", + "start": 213, + "end": 214, + "value": "\n" + }, + { + "type": "brace", + "start": 214, + "end": 215, + "value": "}" + }, + { + "type": "whitespace", + "start": 215, + "end": 216, + "value": "\n" + }, + { + "type": "word", + "start": 216, + "end": 227, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 227, + "end": 228, + "value": "(" + }, + { + "type": "word", + "start": 228, + "end": 229, + "value": "b" + }, + { + "type": "comma", + "start": 229, + "end": 230, + "value": "," + }, + { + "type": "whitespace", + "start": 230, + "end": 231, + "value": " " + }, + { + "type": "number", + "start": 231, + "end": 232, + "value": "4" + }, + { + "type": "comma", + "start": 232, + "end": 233, + "value": "," + }, + { + "type": "whitespace", + "start": 233, + "end": 234, + "value": " " + }, + { + "type": "number", + "start": 234, + "end": 239, + "value": "0.001" + }, + { + "type": "comma", + "start": 239, + "end": 240, + "value": "," + }, + { + "type": "whitespace", + "start": 240, + "end": 241, + "value": " " + }, + { + "type": "string", + "start": 241, + "end": 277, + "value": "\"the 'else if' branch gets returned\"" + }, + { + "type": "brace", + "start": 277, + "end": 278, + "value": ")" + }, + { + "type": "whitespace", + "start": 278, + "end": 280, + "value": "\n\n" + }, + { + "type": "word", + "start": 280, + "end": 281, + "value": "c" + }, + { + "type": "whitespace", + "start": 281, + "end": 282, + "value": " " + }, + { + "type": "operator", + "start": 282, + "end": 283, + "value": "=" + }, + { + "type": "whitespace", + "start": 283, + "end": 284, + "value": " " + }, + { + "type": "keyword", + "start": 284, + "end": 286, + "value": "if" + }, + { + "type": "whitespace", + "start": 286, + "end": 287, + "value": " " + }, + { + "type": "keyword", + "start": 287, + "end": 292, + "value": "false" + }, + { + "type": "whitespace", + "start": 292, + "end": 293, + "value": " " + }, + { + "type": "brace", + "start": 293, + "end": 294, + "value": "{" + }, + { + "type": "whitespace", + "start": 294, + "end": 297, + "value": "\n " + }, + { + "type": "number", + "start": 297, + "end": 298, + "value": "3" + }, + { + "type": "whitespace", + "start": 298, + "end": 299, + "value": "\n" + }, + { + "type": "brace", + "start": 299, + "end": 300, + "value": "}" + }, + { + "type": "whitespace", + "start": 300, + "end": 301, + "value": " " + }, + { + "type": "keyword", + "start": 301, + "end": 305, + "value": "else" + }, + { + "type": "whitespace", + "start": 305, + "end": 306, + "value": " " + }, + { + "type": "keyword", + "start": 306, + "end": 308, + "value": "if" + }, + { + "type": "whitespace", + "start": 308, + "end": 309, + "value": " " + }, + { + "type": "keyword", + "start": 309, + "end": 314, + "value": "false" + }, + { + "type": "whitespace", + "start": 314, + "end": 315, + "value": " " + }, + { + "type": "brace", + "start": 315, + "end": 316, + "value": "{" + }, + { + "type": "whitespace", + "start": 316, + "end": 319, + "value": "\n " + }, + { + "type": "number", + "start": 319, + "end": 320, + "value": "4" + }, + { + "type": "whitespace", + "start": 320, + "end": 321, + "value": "\n" + }, + { + "type": "brace", + "start": 321, + "end": 322, + "value": "}" + }, + { + "type": "whitespace", + "start": 322, + "end": 323, + "value": " " + }, + { + "type": "keyword", + "start": 323, + "end": 327, + "value": "else" + }, + { + "type": "whitespace", + "start": 327, + "end": 328, + "value": " " + }, + { + "type": "brace", + "start": 328, + "end": 329, + "value": "{" + }, + { + "type": "whitespace", + "start": 329, + "end": 332, + "value": "\n " + }, + { + "type": "number", + "start": 332, + "end": 333, + "value": "5" + }, + { + "type": "whitespace", + "start": 333, + "end": 334, + "value": "\n" + }, + { + "type": "brace", + "start": 334, + "end": 335, + "value": "}" + }, + { + "type": "whitespace", + "start": 335, + "end": 336, + "value": "\n" + }, + { + "type": "word", + "start": 336, + "end": 347, + "value": "assertEqual" + }, + { + "type": "brace", + "start": 347, + "end": 348, + "value": "(" + }, + { + "type": "word", + "start": 348, + "end": 349, + "value": "c" + }, + { + "type": "comma", + "start": 349, + "end": 350, + "value": "," + }, + { + "type": "whitespace", + "start": 350, + "end": 351, + "value": " " + }, + { + "type": "number", + "start": 351, + "end": 352, + "value": "5" + }, + { + "type": "comma", + "start": 352, + "end": 353, + "value": "," + }, + { + "type": "whitespace", + "start": 353, + "end": 354, + "value": " " + }, + { + "type": "number", + "start": 354, + "end": 359, + "value": "0.001" + }, + { + "type": "comma", + "start": 359, + "end": 360, + "value": "," + }, + { + "type": "whitespace", + "start": 360, + "end": 361, + "value": " " + }, + { + "type": "string", + "start": 361, + "end": 394, + "value": "\"the 'else' branch gets returned\"" + }, + { + "type": "brace", + "start": 394, + "end": 395, + "value": ")" + }, + { + "type": "whitespace", + "start": 395, + "end": 396, + "value": "\n" + } + ] +} diff --git a/src/wasm-lib/kcl/tests/index_of_array/ast.snap b/src/wasm-lib/kcl/tests/index_of_array/ast.snap new file mode 100644 index 0000000000..cd2aa77985 --- /dev/null +++ b/src/wasm-lib/kcl/tests/index_of_array/ast.snap @@ -0,0 +1,466 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of parsing index_of_array.kcl +snapshot_kind: text +--- +{ + "Ok": { + "body": [ + { + "declarations": [ + { + "end": 55, + "id": { + "end": 40, + "name": "array", + "start": 35, + "type": "Identifier" + }, + "init": { + "elements": [ + { + "end": 46, + "raw": "90", + "start": 44, + "type": "Literal", + "type": "Literal", + "value": 90 + }, + { + "end": 50, + "raw": "91", + "start": 48, + "type": "Literal", + "type": "Literal", + "value": 91 + }, + { + "end": 54, + "raw": "92", + "start": 52, + "type": "Literal", + "type": "Literal", + "value": 92 + } + ], + "end": 55, + "start": 43, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + "start": 35, + "type": "VariableDeclarator" + } + ], + "end": 55, + "kind": "const", + "start": 35, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declarations": [ + { + "end": 101, + "id": { + "end": 90, + "name": "result0", + "start": 83, + "type": "Identifier" + }, + "init": { + "computed": false, + "end": 101, + "object": { + "end": 98, + "name": "array", + "start": 93, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 100, + "raw": "1", + "start": 99, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + "start": 93, + "type": "MemberExpression", + "type": "MemberExpression" + }, + "start": 83, + "type": "VariableDeclarator" + } + ], + "end": 101, + "kind": "const", + "start": 83, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "end": 161, + "expression": { + "arguments": [ + { + "end": 129, + "name": "result0", + "start": 122, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 133, + "raw": "91", + "start": 131, + "type": "Literal", + "type": "Literal", + "value": 91 + }, + { + "end": 160, + "raw": "\"Literal property lookup\"", + "start": 135, + "type": "Literal", + "type": "Literal", + "value": "Literal property lookup" + } + ], + "callee": { + "end": 121, + "name": "assertLessThanOrEq", + "start": 103, + "type": "Identifier" + }, + "end": 161, + "optional": false, + "start": 103, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 103, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 223, + "expression": { + "arguments": [ + { + "end": 191, + "name": "result0", + "start": 184, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 195, + "raw": "91", + "start": 193, + "type": "Literal", + "type": "Literal", + "value": 91 + }, + { + "end": 222, + "raw": "\"Literal property lookup\"", + "start": 197, + "type": "Literal", + "type": "Literal", + "value": "Literal property lookup" + } + ], + "callee": { + "end": 183, + "name": "assertGreaterThanOrEq", + "start": 162, + "type": "Identifier" + }, + "end": 223, + "optional": false, + "start": 162, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 162, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "declarations": [ + { + "end": 266, + "id": { + "end": 253, + "name": "i", + "start": 252, + "type": "Identifier" + }, + "init": { + "arguments": [ + { + "end": 265, + "left": { + "end": 261, + "raw": "1", + "start": 260, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + "operator": "+", + "right": { + "end": 265, + "raw": "0", + "start": 264, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + "start": 260, + "type": "BinaryExpression", + "type": "BinaryExpression" + } + ], + "callee": { + "end": 259, + "name": "int", + "start": 256, + "type": "Identifier" + }, + "end": 266, + "optional": false, + "start": 256, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 252, + "type": "VariableDeclarator" + } + ], + "end": 266, + "kind": "const", + "start": 252, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declarations": [ + { + "end": 285, + "id": { + "end": 274, + "name": "result1", + "start": 267, + "type": "Identifier" + }, + "init": { + "computed": true, + "end": 285, + "object": { + "end": 282, + "name": "array", + "start": 277, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 284, + "name": "i", + "start": 283, + "type": "Identifier", + "type": "Identifier" + }, + "start": 277, + "type": "MemberExpression", + "type": "MemberExpression" + }, + "start": 267, + "type": "VariableDeclarator" + } + ], + "end": 285, + "kind": "const", + "start": 267, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "end": 346, + "expression": { + "arguments": [ + { + "end": 313, + "name": "result1", + "start": 306, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 317, + "raw": "91", + "start": 315, + "type": "Literal", + "type": "Literal", + "value": 91 + }, + { + "end": 345, + "raw": "\"Computed property lookup\"", + "start": 319, + "type": "Literal", + "type": "Literal", + "value": "Computed property lookup" + } + ], + "callee": { + "end": 305, + "name": "assertLessThanOrEq", + "start": 287, + "type": "Identifier" + }, + "end": 346, + "optional": false, + "start": 287, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 287, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 409, + "expression": { + "arguments": [ + { + "end": 376, + "name": "result1", + "start": 369, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 380, + "raw": "91", + "start": 378, + "type": "Literal", + "type": "Literal", + "value": 91 + }, + { + "end": 408, + "raw": "\"Computed property lookup\"", + "start": 382, + "type": "Literal", + "type": "Literal", + "value": "Computed property lookup" + } + ], + "callee": { + "end": 368, + "name": "assertGreaterThanOrEq", + "start": 347, + "type": "Identifier" + }, + "end": 409, + "optional": false, + "start": 347, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 347, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 410, + "nonCodeMeta": { + "nonCodeNodes": { + "0": [ + { + "end": 80, + "start": 55, + "type": "NonCodeNode", + "value": { + "type": "newLineBlockComment", + "value": "Test: literal index.", + "style": "line" + } + }, + { + "end": 83, + "start": 80, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "1": [ + { + "end": 103, + "start": 101, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "3": [ + { + "end": 249, + "start": 223, + "type": "NonCodeNode", + "value": { + "type": "newLineBlockComment", + "value": "Test: computed index.", + "style": "line" + } + }, + { + "end": 252, + "start": 249, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "5": [ + { + "end": 287, + "start": 285, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ] + }, + "startNodes": [ + { + "end": 32, + "start": 0, + "type": "NonCodeNode", + "value": { + "type": "blockComment", + "value": "This tests indexing an array.", + "style": "line" + } + }, + { + "end": 35, + "start": 32, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ] + }, + "start": 0 + } +} diff --git a/src/wasm-lib/tests/executor/inputs/no_visuals/index_of_array.kcl b/src/wasm-lib/kcl/tests/index_of_array/input.kcl similarity index 77% rename from src/wasm-lib/tests/executor/inputs/no_visuals/index_of_array.kcl rename to src/wasm-lib/kcl/tests/index_of_array/input.kcl index 19d2d35be6..c61056c67a 100644 --- a/src/wasm-lib/tests/executor/inputs/no_visuals/index_of_array.kcl +++ b/src/wasm-lib/kcl/tests/index_of_array/input.kcl @@ -1,18 +1,21 @@ // This tests indexing an array. -const array = [90, 91, 92] + +array = [90, 91, 92] // Test: literal index. -const result0 = array[1] + +result0 = array[1] assertLessThanOrEq(result0, 91, "Literal property lookup") assertGreaterThanOrEq(result0, 91, "Literal property lookup") // Test: computed index. -const i = int(1 + 0) -const result1 = array[i] + +i = int(1 + 0) +result1 = array[i] assertLessThanOrEq(result1, 91, "Computed property lookup") assertGreaterThanOrEq(result1, 91, "Computed property lookup") diff --git a/src/wasm-lib/kcl/tests/index_of_array/program_memory.snap b/src/wasm-lib/kcl/tests/index_of_array/program_memory.snap new file mode 100644 index 0000000000..b679079fcf --- /dev/null +++ b/src/wasm-lib/kcl/tests/index_of_array/program_memory.snap @@ -0,0 +1,96 @@ +--- +source: kcl/src/simulation_tests.rs +description: Program memory after executing index_of_array.kcl +snapshot_kind: text +--- +{ + "environments": [ + { + "bindings": { + "HALF_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 180, + "__meta": [] + }, + "QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 90, + "__meta": [] + }, + "THREE_QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 270, + "__meta": [] + }, + "ZERO": { + "type": "UserVal", + "type": "UserVal", + "value": 0, + "__meta": [] + }, + "array": { + "type": "UserVal", + "type": "UserVal", + "value": [ + 90, + 91, + 92 + ], + "__meta": [ + { + "sourceRange": [ + 43, + 55 + ] + } + ] + }, + "i": { + "type": "UserVal", + "type": "UserVal", + "value": 1, + "__meta": [ + { + "sourceRange": [ + 256, + 266 + ] + } + ] + }, + "result0": { + "type": "UserVal", + "type": "UserVal", + "value": 91, + "__meta": [ + { + "sourceRange": [ + 93, + 101 + ] + } + ] + }, + "result1": { + "type": "UserVal", + "type": "UserVal", + "value": 91, + "__meta": [ + { + "sourceRange": [ + 277, + 285 + ] + } + ] + } + }, + "parent": null + } + ], + "currentEnv": 0, + "return": null +} diff --git a/src/wasm-lib/kcl/tests/index_of_array/tokens.snap b/src/wasm-lib/kcl/tests/index_of_array/tokens.snap new file mode 100644 index 0000000000..c9d865e149 --- /dev/null +++ b/src/wasm-lib/kcl/tests/index_of_array/tokens.snap @@ -0,0 +1,579 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of tokenizing index_of_array.kcl +snapshot_kind: text +--- +{ + "Ok": [ + { + "type": "lineComment", + "start": 0, + "end": 32, + "value": "// This tests indexing an array." + }, + { + "type": "whitespace", + "start": 32, + "end": 35, + "value": "\n\n\n" + }, + { + "type": "word", + "start": 35, + "end": 40, + "value": "array" + }, + { + "type": "whitespace", + "start": 40, + "end": 41, + "value": " " + }, + { + "type": "operator", + "start": 41, + "end": 42, + "value": "=" + }, + { + "type": "whitespace", + "start": 42, + "end": 43, + "value": " " + }, + { + "type": "brace", + "start": 43, + "end": 44, + "value": "[" + }, + { + "type": "number", + "start": 44, + "end": 46, + "value": "90" + }, + { + "type": "comma", + "start": 46, + "end": 47, + "value": "," + }, + { + "type": "whitespace", + "start": 47, + "end": 48, + "value": " " + }, + { + "type": "number", + "start": 48, + "end": 50, + "value": "91" + }, + { + "type": "comma", + "start": 50, + "end": 51, + "value": "," + }, + { + "type": "whitespace", + "start": 51, + "end": 52, + "value": " " + }, + { + "type": "number", + "start": 52, + "end": 54, + "value": "92" + }, + { + "type": "brace", + "start": 54, + "end": 55, + "value": "]" + }, + { + "type": "whitespace", + "start": 55, + "end": 57, + "value": "\n\n" + }, + { + "type": "lineComment", + "start": 57, + "end": 80, + "value": "// Test: literal index." + }, + { + "type": "whitespace", + "start": 80, + "end": 83, + "value": "\n\n\n" + }, + { + "type": "word", + "start": 83, + "end": 90, + "value": "result0" + }, + { + "type": "whitespace", + "start": 90, + "end": 91, + "value": " " + }, + { + "type": "operator", + "start": 91, + "end": 92, + "value": "=" + }, + { + "type": "whitespace", + "start": 92, + "end": 93, + "value": " " + }, + { + "type": "word", + "start": 93, + "end": 98, + "value": "array" + }, + { + "type": "brace", + "start": 98, + "end": 99, + "value": "[" + }, + { + "type": "number", + "start": 99, + "end": 100, + "value": "1" + }, + { + "type": "brace", + "start": 100, + "end": 101, + "value": "]" + }, + { + "type": "whitespace", + "start": 101, + "end": 103, + "value": "\n\n" + }, + { + "type": "word", + "start": 103, + "end": 121, + "value": "assertLessThanOrEq" + }, + { + "type": "brace", + "start": 121, + "end": 122, + "value": "(" + }, + { + "type": "word", + "start": 122, + "end": 129, + "value": "result0" + }, + { + "type": "comma", + "start": 129, + "end": 130, + "value": "," + }, + { + "type": "whitespace", + "start": 130, + "end": 131, + "value": " " + }, + { + "type": "number", + "start": 131, + "end": 133, + "value": "91" + }, + { + "type": "comma", + "start": 133, + "end": 134, + "value": "," + }, + { + "type": "whitespace", + "start": 134, + "end": 135, + "value": " " + }, + { + "type": "string", + "start": 135, + "end": 160, + "value": "\"Literal property lookup\"" + }, + { + "type": "brace", + "start": 160, + "end": 161, + "value": ")" + }, + { + "type": "whitespace", + "start": 161, + "end": 162, + "value": "\n" + }, + { + "type": "word", + "start": 162, + "end": 183, + "value": "assertGreaterThanOrEq" + }, + { + "type": "brace", + "start": 183, + "end": 184, + "value": "(" + }, + { + "type": "word", + "start": 184, + "end": 191, + "value": "result0" + }, + { + "type": "comma", + "start": 191, + "end": 192, + "value": "," + }, + { + "type": "whitespace", + "start": 192, + "end": 193, + "value": " " + }, + { + "type": "number", + "start": 193, + "end": 195, + "value": "91" + }, + { + "type": "comma", + "start": 195, + "end": 196, + "value": "," + }, + { + "type": "whitespace", + "start": 196, + "end": 197, + "value": " " + }, + { + "type": "string", + "start": 197, + "end": 222, + "value": "\"Literal property lookup\"" + }, + { + "type": "brace", + "start": 222, + "end": 223, + "value": ")" + }, + { + "type": "whitespace", + "start": 223, + "end": 225, + "value": "\n\n" + }, + { + "type": "lineComment", + "start": 225, + "end": 249, + "value": "// Test: computed index." + }, + { + "type": "whitespace", + "start": 249, + "end": 252, + "value": "\n\n\n" + }, + { + "type": "word", + "start": 252, + "end": 253, + "value": "i" + }, + { + "type": "whitespace", + "start": 253, + "end": 254, + "value": " " + }, + { + "type": "operator", + "start": 254, + "end": 255, + "value": "=" + }, + { + "type": "whitespace", + "start": 255, + "end": 256, + "value": " " + }, + { + "type": "word", + "start": 256, + "end": 259, + "value": "int" + }, + { + "type": "brace", + "start": 259, + "end": 260, + "value": "(" + }, + { + "type": "number", + "start": 260, + "end": 261, + "value": "1" + }, + { + "type": "whitespace", + "start": 261, + "end": 262, + "value": " " + }, + { + "type": "operator", + "start": 262, + "end": 263, + "value": "+" + }, + { + "type": "whitespace", + "start": 263, + "end": 264, + "value": " " + }, + { + "type": "number", + "start": 264, + "end": 265, + "value": "0" + }, + { + "type": "brace", + "start": 265, + "end": 266, + "value": ")" + }, + { + "type": "whitespace", + "start": 266, + "end": 267, + "value": "\n" + }, + { + "type": "word", + "start": 267, + "end": 274, + "value": "result1" + }, + { + "type": "whitespace", + "start": 274, + "end": 275, + "value": " " + }, + { + "type": "operator", + "start": 275, + "end": 276, + "value": "=" + }, + { + "type": "whitespace", + "start": 276, + "end": 277, + "value": " " + }, + { + "type": "word", + "start": 277, + "end": 282, + "value": "array" + }, + { + "type": "brace", + "start": 282, + "end": 283, + "value": "[" + }, + { + "type": "word", + "start": 283, + "end": 284, + "value": "i" + }, + { + "type": "brace", + "start": 284, + "end": 285, + "value": "]" + }, + { + "type": "whitespace", + "start": 285, + "end": 287, + "value": "\n\n" + }, + { + "type": "word", + "start": 287, + "end": 305, + "value": "assertLessThanOrEq" + }, + { + "type": "brace", + "start": 305, + "end": 306, + "value": "(" + }, + { + "type": "word", + "start": 306, + "end": 313, + "value": "result1" + }, + { + "type": "comma", + "start": 313, + "end": 314, + "value": "," + }, + { + "type": "whitespace", + "start": 314, + "end": 315, + "value": " " + }, + { + "type": "number", + "start": 315, + "end": 317, + "value": "91" + }, + { + "type": "comma", + "start": 317, + "end": 318, + "value": "," + }, + { + "type": "whitespace", + "start": 318, + "end": 319, + "value": " " + }, + { + "type": "string", + "start": 319, + "end": 345, + "value": "\"Computed property lookup\"" + }, + { + "type": "brace", + "start": 345, + "end": 346, + "value": ")" + }, + { + "type": "whitespace", + "start": 346, + "end": 347, + "value": "\n" + }, + { + "type": "word", + "start": 347, + "end": 368, + "value": "assertGreaterThanOrEq" + }, + { + "type": "brace", + "start": 368, + "end": 369, + "value": "(" + }, + { + "type": "word", + "start": 369, + "end": 376, + "value": "result1" + }, + { + "type": "comma", + "start": 376, + "end": 377, + "value": "," + }, + { + "type": "whitespace", + "start": 377, + "end": 378, + "value": " " + }, + { + "type": "number", + "start": 378, + "end": 380, + "value": "91" + }, + { + "type": "comma", + "start": 380, + "end": 381, + "value": "," + }, + { + "type": "whitespace", + "start": 381, + "end": 382, + "value": " " + }, + { + "type": "string", + "start": 382, + "end": 408, + "value": "\"Computed property lookup\"" + }, + { + "type": "brace", + "start": 408, + "end": 409, + "value": ")" + }, + { + "type": "whitespace", + "start": 409, + "end": 410, + "value": "\n" + } + ] +} diff --git a/src/wasm-lib/kcl/tests/property_of_object/ast.snap b/src/wasm-lib/kcl/tests/property_of_object/ast.snap new file mode 100644 index 0000000000..b7dbcc28ac --- /dev/null +++ b/src/wasm-lib/kcl/tests/property_of_object/ast.snap @@ -0,0 +1,863 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of parsing property_of_object.kcl +snapshot_kind: text +--- +{ + "Ok": { + "body": [ + { + "declarations": [ + { + "end": 74, + "id": { + "end": 53, + "name": "obj", + "start": 50, + "type": "Identifier" + }, + "init": { + "end": 74, + "properties": [ + { + "end": 64, + "key": { + "end": 61, + "name": "foo", + "start": 58, + "type": "Identifier" + }, + "start": 58, + "type": "ObjectProperty", + "value": { + "end": 64, + "raw": "1", + "start": 63, + "type": "Literal", + "type": "Literal", + "value": 1 + } + }, + { + "end": 72, + "key": { + "end": 69, + "name": "bar", + "start": 66, + "type": "Identifier" + }, + "start": 66, + "type": "ObjectProperty", + "value": { + "end": 72, + "raw": "0", + "start": 71, + "type": "Literal", + "type": "Literal", + "value": 0 + } + } + ], + "start": 56, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + "start": 50, + "type": "VariableDeclarator" + } + ], + "end": 74, + "kind": "const", + "start": 50, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declarations": [ + { + "end": 132, + "id": { + "end": 119, + "name": "one_a", + "start": 114, + "type": "Identifier" + }, + "init": { + "computed": false, + "end": 132, + "object": { + "end": 125, + "name": "obj", + "start": 122, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 131, + "raw": "\"foo\"", + "start": 126, + "type": "Literal", + "type": "Literal", + "value": "foo" + }, + "start": 122, + "type": "MemberExpression", + "type": "MemberExpression" + }, + "start": 114, + "type": "VariableDeclarator" + } + ], + "end": 132, + "kind": "const", + "start": 114, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "end": 189, + "expression": { + "arguments": [ + { + "end": 158, + "name": "one_a", + "start": 153, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 161, + "raw": "1", + "start": 160, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + { + "end": 188, + "raw": "\"Literal property lookup\"", + "start": 163, + "type": "Literal", + "type": "Literal", + "value": "Literal property lookup" + } + ], + "callee": { + "end": 152, + "name": "assertLessThanOrEq", + "start": 134, + "type": "Identifier" + }, + "end": 189, + "optional": false, + "start": 134, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 134, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 248, + "expression": { + "arguments": [ + { + "end": 217, + "name": "one_a", + "start": 212, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 220, + "raw": "1", + "start": 219, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + { + "end": 247, + "raw": "\"Literal property lookup\"", + "start": 222, + "type": "Literal", + "type": "Literal", + "value": "Literal property lookup" + } + ], + "callee": { + "end": 211, + "name": "assertGreaterThanOrEq", + "start": 190, + "type": "Identifier" + }, + "end": 248, + "optional": false, + "start": 190, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 190, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "declarations": [ + { + "end": 347, + "id": { + "end": 339, + "name": "p", + "start": 338, + "type": "Identifier" + }, + "init": { + "end": 347, + "raw": "\"foo\"", + "start": 342, + "type": "Literal", + "type": "Literal", + "value": "foo" + }, + "start": 338, + "type": "VariableDeclarator" + } + ], + "end": 347, + "kind": "const", + "start": 338, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declarations": [ + { + "end": 362, + "id": { + "end": 353, + "name": "one_b", + "start": 348, + "type": "Identifier" + }, + "init": { + "computed": true, + "end": 362, + "object": { + "end": 359, + "name": "obj", + "start": 356, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 361, + "name": "p", + "start": 360, + "type": "Identifier", + "type": "Identifier" + }, + "start": 356, + "type": "MemberExpression", + "type": "MemberExpression" + }, + "start": 348, + "type": "VariableDeclarator" + } + ], + "end": 362, + "kind": "const", + "start": 348, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "end": 420, + "expression": { + "arguments": [ + { + "end": 388, + "name": "one_b", + "start": 383, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 391, + "raw": "1", + "start": 390, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + { + "end": 419, + "raw": "\"Computed property lookup\"", + "start": 393, + "type": "Literal", + "type": "Literal", + "value": "Computed property lookup" + } + ], + "callee": { + "end": 382, + "name": "assertLessThanOrEq", + "start": 364, + "type": "Identifier" + }, + "end": 420, + "optional": false, + "start": 364, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 364, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 480, + "expression": { + "arguments": [ + { + "end": 448, + "name": "one_b", + "start": 443, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 451, + "raw": "1", + "start": 450, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + { + "end": 479, + "raw": "\"Computed property lookup\"", + "start": 453, + "type": "Literal", + "type": "Literal", + "value": "Computed property lookup" + } + ], + "callee": { + "end": 442, + "name": "assertGreaterThanOrEq", + "start": 421, + "type": "Identifier" + }, + "end": 480, + "optional": false, + "start": 421, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 421, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "declarations": [ + { + "end": 543, + "id": { + "end": 526, + "name": "obj2", + "start": 522, + "type": "Identifier" + }, + "init": { + "end": 543, + "properties": [ + { + "end": 541, + "key": { + "end": 536, + "name": "inner", + "start": 531, + "type": "Identifier" + }, + "start": 531, + "type": "ObjectProperty", + "value": { + "end": 541, + "name": "obj", + "start": 538, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "start": 529, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + "start": 522, + "type": "VariableDeclarator" + } + ], + "end": 543, + "kind": "const", + "start": 522, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declarations": [ + { + "end": 570, + "id": { + "end": 550, + "name": "one_c", + "start": 545, + "type": "Identifier" + }, + "init": { + "computed": false, + "end": 570, + "object": { + "computed": false, + "end": 563, + "object": { + "end": 557, + "name": "obj2", + "start": 553, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 563, + "name": "inner", + "start": 558, + "type": "Identifier", + "type": "Identifier" + }, + "start": 553, + "type": "MemberExpression", + "type": "MemberExpression" + }, + "property": { + "end": 569, + "raw": "\"foo\"", + "start": 564, + "type": "Literal", + "type": "Literal", + "value": "foo" + }, + "start": 553, + "type": "MemberExpression", + "type": "MemberExpression" + }, + "start": 545, + "type": "VariableDeclarator" + } + ], + "end": 570, + "kind": "const", + "start": 545, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "end": 627, + "expression": { + "arguments": [ + { + "end": 596, + "name": "one_c", + "start": 591, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 599, + "raw": "1", + "start": 598, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + { + "end": 626, + "raw": "\"Literal property lookup\"", + "start": 601, + "type": "Literal", + "type": "Literal", + "value": "Literal property lookup" + } + ], + "callee": { + "end": 590, + "name": "assertLessThanOrEq", + "start": 572, + "type": "Identifier" + }, + "end": 627, + "optional": false, + "start": 572, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 572, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 686, + "expression": { + "arguments": [ + { + "end": 655, + "name": "one_c", + "start": 650, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 658, + "raw": "1", + "start": 657, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + { + "end": 685, + "raw": "\"Literal property lookup\"", + "start": 660, + "type": "Literal", + "type": "Literal", + "value": "Literal property lookup" + } + ], + "callee": { + "end": 649, + "name": "assertGreaterThanOrEq", + "start": 628, + "type": "Identifier" + }, + "end": 686, + "optional": false, + "start": 628, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 628, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "declarations": [ + { + "end": 770, + "id": { + "end": 754, + "name": "one_d", + "start": 749, + "type": "Identifier" + }, + "init": { + "computed": true, + "end": 770, + "object": { + "computed": false, + "end": 767, + "object": { + "end": 761, + "name": "obj2", + "start": 757, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 767, + "name": "inner", + "start": 762, + "type": "Identifier", + "type": "Identifier" + }, + "start": 757, + "type": "MemberExpression", + "type": "MemberExpression" + }, + "property": { + "end": 769, + "name": "p", + "start": 768, + "type": "Identifier", + "type": "Identifier" + }, + "start": 757, + "type": "MemberExpression", + "type": "MemberExpression" + }, + "start": 749, + "type": "VariableDeclarator" + } + ], + "end": 770, + "kind": "const", + "start": 749, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "end": 828, + "expression": { + "arguments": [ + { + "end": 796, + "name": "one_d", + "start": 791, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 799, + "raw": "1", + "start": 798, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + { + "end": 827, + "raw": "\"Computed property lookup\"", + "start": 801, + "type": "Literal", + "type": "Literal", + "value": "Computed property lookup" + } + ], + "callee": { + "end": 790, + "name": "assertLessThanOrEq", + "start": 772, + "type": "Identifier" + }, + "end": 828, + "optional": false, + "start": 772, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 772, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "end": 888, + "expression": { + "arguments": [ + { + "end": 856, + "name": "one_d", + "start": 851, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 859, + "raw": "1", + "start": 858, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + { + "end": 887, + "raw": "\"Computed property lookup\"", + "start": 861, + "type": "Literal", + "type": "Literal", + "value": "Computed property lookup" + } + ], + "callee": { + "end": 850, + "name": "assertGreaterThanOrEq", + "start": 829, + "type": "Identifier" + }, + "end": 888, + "optional": false, + "start": 829, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 829, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 889, + "nonCodeMeta": { + "nonCodeNodes": { + "0": [ + { + "end": 111, + "start": 74, + "type": "NonCodeNode", + "value": { + "type": "newLineBlockComment", + "value": "Test: the property is a literal.", + "style": "line" + } + }, + { + "end": 114, + "start": 111, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "1": [ + { + "end": 134, + "start": 132, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "3": [ + { + "end": 286, + "start": 248, + "type": "NonCodeNode", + "value": { + "type": "newLineBlockComment", + "value": "Test: the property is a variable,", + "style": "line" + } + }, + { + "end": 335, + "start": 287, + "type": "NonCodeNode", + "value": { + "type": "blockComment", + "value": "which must be evaluated before looking it up.", + "style": "line" + } + }, + { + "end": 338, + "start": 335, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "5": [ + { + "end": 364, + "start": 362, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "7": [ + { + "end": 519, + "start": 480, + "type": "NonCodeNode", + "value": { + "type": "newLineBlockComment", + "value": "Test: multiple literal properties.", + "style": "line" + } + }, + { + "end": 522, + "start": 519, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "8": [ + { + "end": 545, + "start": 543, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "9": [ + { + "end": 572, + "start": 570, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "11": [ + { + "end": 746, + "start": 686, + "type": "NonCodeNode", + "value": { + "type": "newLineBlockComment", + "value": "Test: multiple properties, mix of literal and computed.", + "style": "line" + } + }, + { + "end": 749, + "start": 746, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "12": [ + { + "end": 772, + "start": 770, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ] + }, + "startNodes": [ + { + "end": 47, + "start": 0, + "type": "NonCodeNode", + "value": { + "type": "blockComment", + "value": "This tests evaluating properties of objects.", + "style": "line" + } + }, + { + "end": 50, + "start": 47, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ] + }, + "start": 0 + } +} diff --git a/src/wasm-lib/tests/executor/inputs/no_visuals/property_of_object.kcl b/src/wasm-lib/kcl/tests/property_of_object/input.kcl similarity index 54% rename from src/wasm-lib/tests/executor/inputs/no_visuals/property_of_object.kcl rename to src/wasm-lib/kcl/tests/property_of_object/input.kcl index 70867e84dc..9b5fe6f469 100644 --- a/src/wasm-lib/tests/executor/inputs/no_visuals/property_of_object.kcl +++ b/src/wasm-lib/kcl/tests/property_of_object/input.kcl @@ -1,40 +1,40 @@ // This tests evaluating properties of objects. -const obj = { - foo: 1, - bar: 0, -} + +obj = { foo: 1, bar: 0 } // Test: the property is a literal. -const one_a = obj["foo"] -assertLessThanOrEq(one_a, 1, "Literal property lookup") +one_a = obj["foo"] + +assertLessThanOrEq(one_a, 1, "Literal property lookup") assertGreaterThanOrEq(one_a, 1, "Literal property lookup") // Test: the property is a variable, // which must be evaluated before looking it up. -const p = "foo" -const one_b = obj[p] -assertLessThanOrEq(one_b, 1, "Computed property lookup") +p = "foo" +one_b = obj[p] + +assertLessThanOrEq(one_b, 1, "Computed property lookup") assertGreaterThanOrEq(one_b, 1, "Computed property lookup") // Test: multiple literal properties. -const obj2 = { - inner: obj, -} -const one_c = obj2.inner["foo"] +obj2 = { inner: obj } -assertLessThanOrEq(one_c, 1, "Literal property lookup") +one_c = obj2.inner["foo"] + +assertLessThanOrEq(one_c, 1, "Literal property lookup") assertGreaterThanOrEq(one_c, 1, "Literal property lookup") // Test: multiple properties, mix of literal and computed. -const one_d = obj2.inner[p] -assertLessThanOrEq(one_d, 1, "Computed property lookup") +one_d = obj2.inner[p] + +assertLessThanOrEq(one_d, 1, "Computed property lookup") assertGreaterThanOrEq(one_d, 1, "Computed property lookup") diff --git a/src/wasm-lib/kcl/tests/property_of_object/program_memory.snap b/src/wasm-lib/kcl/tests/property_of_object/program_memory.snap new file mode 100644 index 0000000000..10acfd7ae2 --- /dev/null +++ b/src/wasm-lib/kcl/tests/property_of_object/program_memory.snap @@ -0,0 +1,139 @@ +--- +source: kcl/src/simulation_tests.rs +description: Program memory after executing property_of_object.kcl +snapshot_kind: text +--- +{ + "environments": [ + { + "bindings": { + "HALF_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 180, + "__meta": [] + }, + "QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 90, + "__meta": [] + }, + "THREE_QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 270, + "__meta": [] + }, + "ZERO": { + "type": "UserVal", + "type": "UserVal", + "value": 0, + "__meta": [] + }, + "obj": { + "type": "UserVal", + "type": "UserVal", + "value": { + "bar": 0, + "foo": 1 + }, + "__meta": [ + { + "sourceRange": [ + 56, + 74 + ] + } + ] + }, + "obj2": { + "type": "UserVal", + "type": "UserVal", + "value": { + "inner": { + "bar": 0, + "foo": 1 + } + }, + "__meta": [ + { + "sourceRange": [ + 529, + 543 + ] + } + ] + }, + "one_a": { + "type": "UserVal", + "type": "UserVal", + "value": 1, + "__meta": [ + { + "sourceRange": [ + 122, + 132 + ] + } + ] + }, + "one_b": { + "type": "UserVal", + "type": "UserVal", + "value": 1, + "__meta": [ + { + "sourceRange": [ + 356, + 362 + ] + } + ] + }, + "one_c": { + "type": "UserVal", + "type": "UserVal", + "value": 1, + "__meta": [ + { + "sourceRange": [ + 553, + 570 + ] + } + ] + }, + "one_d": { + "type": "UserVal", + "type": "UserVal", + "value": 1, + "__meta": [ + { + "sourceRange": [ + 757, + 770 + ] + } + ] + }, + "p": { + "type": "UserVal", + "type": "UserVal", + "value": "foo", + "__meta": [ + { + "sourceRange": [ + 342, + 347 + ] + } + ] + } + }, + "parent": null + } + ], + "currentEnv": 0, + "return": null +} diff --git a/src/wasm-lib/kcl/tests/property_of_object/tokens.snap b/src/wasm-lib/kcl/tests/property_of_object/tokens.snap new file mode 100644 index 0000000000..54aebf4925 --- /dev/null +++ b/src/wasm-lib/kcl/tests/property_of_object/tokens.snap @@ -0,0 +1,1077 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of tokenizing property_of_object.kcl +snapshot_kind: text +--- +{ + "Ok": [ + { + "type": "lineComment", + "start": 0, + "end": 47, + "value": "// This tests evaluating properties of objects." + }, + { + "type": "whitespace", + "start": 47, + "end": 50, + "value": "\n\n\n" + }, + { + "type": "word", + "start": 50, + "end": 53, + "value": "obj" + }, + { + "type": "whitespace", + "start": 53, + "end": 54, + "value": " " + }, + { + "type": "operator", + "start": 54, + "end": 55, + "value": "=" + }, + { + "type": "whitespace", + "start": 55, + "end": 56, + "value": " " + }, + { + "type": "brace", + "start": 56, + "end": 57, + "value": "{" + }, + { + "type": "whitespace", + "start": 57, + "end": 58, + "value": " " + }, + { + "type": "word", + "start": 58, + "end": 61, + "value": "foo" + }, + { + "type": "colon", + "start": 61, + "end": 62, + "value": ":" + }, + { + "type": "whitespace", + "start": 62, + "end": 63, + "value": " " + }, + { + "type": "number", + "start": 63, + "end": 64, + "value": "1" + }, + { + "type": "comma", + "start": 64, + "end": 65, + "value": "," + }, + { + "type": "whitespace", + "start": 65, + "end": 66, + "value": " " + }, + { + "type": "word", + "start": 66, + "end": 69, + "value": "bar" + }, + { + "type": "colon", + "start": 69, + "end": 70, + "value": ":" + }, + { + "type": "whitespace", + "start": 70, + "end": 71, + "value": " " + }, + { + "type": "number", + "start": 71, + "end": 72, + "value": "0" + }, + { + "type": "whitespace", + "start": 72, + "end": 73, + "value": " " + }, + { + "type": "brace", + "start": 73, + "end": 74, + "value": "}" + }, + { + "type": "whitespace", + "start": 74, + "end": 76, + "value": "\n\n" + }, + { + "type": "lineComment", + "start": 76, + "end": 111, + "value": "// Test: the property is a literal." + }, + { + "type": "whitespace", + "start": 111, + "end": 114, + "value": "\n\n\n" + }, + { + "type": "word", + "start": 114, + "end": 119, + "value": "one_a" + }, + { + "type": "whitespace", + "start": 119, + "end": 120, + "value": " " + }, + { + "type": "operator", + "start": 120, + "end": 121, + "value": "=" + }, + { + "type": "whitespace", + "start": 121, + "end": 122, + "value": " " + }, + { + "type": "word", + "start": 122, + "end": 125, + "value": "obj" + }, + { + "type": "brace", + "start": 125, + "end": 126, + "value": "[" + }, + { + "type": "string", + "start": 126, + "end": 131, + "value": "\"foo\"" + }, + { + "type": "brace", + "start": 131, + "end": 132, + "value": "]" + }, + { + "type": "whitespace", + "start": 132, + "end": 134, + "value": "\n\n" + }, + { + "type": "word", + "start": 134, + "end": 152, + "value": "assertLessThanOrEq" + }, + { + "type": "brace", + "start": 152, + "end": 153, + "value": "(" + }, + { + "type": "word", + "start": 153, + "end": 158, + "value": "one_a" + }, + { + "type": "comma", + "start": 158, + "end": 159, + "value": "," + }, + { + "type": "whitespace", + "start": 159, + "end": 160, + "value": " " + }, + { + "type": "number", + "start": 160, + "end": 161, + "value": "1" + }, + { + "type": "comma", + "start": 161, + "end": 162, + "value": "," + }, + { + "type": "whitespace", + "start": 162, + "end": 163, + "value": " " + }, + { + "type": "string", + "start": 163, + "end": 188, + "value": "\"Literal property lookup\"" + }, + { + "type": "brace", + "start": 188, + "end": 189, + "value": ")" + }, + { + "type": "whitespace", + "start": 189, + "end": 190, + "value": "\n" + }, + { + "type": "word", + "start": 190, + "end": 211, + "value": "assertGreaterThanOrEq" + }, + { + "type": "brace", + "start": 211, + "end": 212, + "value": "(" + }, + { + "type": "word", + "start": 212, + "end": 217, + "value": "one_a" + }, + { + "type": "comma", + "start": 217, + "end": 218, + "value": "," + }, + { + "type": "whitespace", + "start": 218, + "end": 219, + "value": " " + }, + { + "type": "number", + "start": 219, + "end": 220, + "value": "1" + }, + { + "type": "comma", + "start": 220, + "end": 221, + "value": "," + }, + { + "type": "whitespace", + "start": 221, + "end": 222, + "value": " " + }, + { + "type": "string", + "start": 222, + "end": 247, + "value": "\"Literal property lookup\"" + }, + { + "type": "brace", + "start": 247, + "end": 248, + "value": ")" + }, + { + "type": "whitespace", + "start": 248, + "end": 250, + "value": "\n\n" + }, + { + "type": "lineComment", + "start": 250, + "end": 286, + "value": "// Test: the property is a variable," + }, + { + "type": "whitespace", + "start": 286, + "end": 287, + "value": "\n" + }, + { + "type": "lineComment", + "start": 287, + "end": 335, + "value": "// which must be evaluated before looking it up." + }, + { + "type": "whitespace", + "start": 335, + "end": 338, + "value": "\n\n\n" + }, + { + "type": "word", + "start": 338, + "end": 339, + "value": "p" + }, + { + "type": "whitespace", + "start": 339, + "end": 340, + "value": " " + }, + { + "type": "operator", + "start": 340, + "end": 341, + "value": "=" + }, + { + "type": "whitespace", + "start": 341, + "end": 342, + "value": " " + }, + { + "type": "string", + "start": 342, + "end": 347, + "value": "\"foo\"" + }, + { + "type": "whitespace", + "start": 347, + "end": 348, + "value": "\n" + }, + { + "type": "word", + "start": 348, + "end": 353, + "value": "one_b" + }, + { + "type": "whitespace", + "start": 353, + "end": 354, + "value": " " + }, + { + "type": "operator", + "start": 354, + "end": 355, + "value": "=" + }, + { + "type": "whitespace", + "start": 355, + "end": 356, + "value": " " + }, + { + "type": "word", + "start": 356, + "end": 359, + "value": "obj" + }, + { + "type": "brace", + "start": 359, + "end": 360, + "value": "[" + }, + { + "type": "word", + "start": 360, + "end": 361, + "value": "p" + }, + { + "type": "brace", + "start": 361, + "end": 362, + "value": "]" + }, + { + "type": "whitespace", + "start": 362, + "end": 364, + "value": "\n\n" + }, + { + "type": "word", + "start": 364, + "end": 382, + "value": "assertLessThanOrEq" + }, + { + "type": "brace", + "start": 382, + "end": 383, + "value": "(" + }, + { + "type": "word", + "start": 383, + "end": 388, + "value": "one_b" + }, + { + "type": "comma", + "start": 388, + "end": 389, + "value": "," + }, + { + "type": "whitespace", + "start": 389, + "end": 390, + "value": " " + }, + { + "type": "number", + "start": 390, + "end": 391, + "value": "1" + }, + { + "type": "comma", + "start": 391, + "end": 392, + "value": "," + }, + { + "type": "whitespace", + "start": 392, + "end": 393, + "value": " " + }, + { + "type": "string", + "start": 393, + "end": 419, + "value": "\"Computed property lookup\"" + }, + { + "type": "brace", + "start": 419, + "end": 420, + "value": ")" + }, + { + "type": "whitespace", + "start": 420, + "end": 421, + "value": "\n" + }, + { + "type": "word", + "start": 421, + "end": 442, + "value": "assertGreaterThanOrEq" + }, + { + "type": "brace", + "start": 442, + "end": 443, + "value": "(" + }, + { + "type": "word", + "start": 443, + "end": 448, + "value": "one_b" + }, + { + "type": "comma", + "start": 448, + "end": 449, + "value": "," + }, + { + "type": "whitespace", + "start": 449, + "end": 450, + "value": " " + }, + { + "type": "number", + "start": 450, + "end": 451, + "value": "1" + }, + { + "type": "comma", + "start": 451, + "end": 452, + "value": "," + }, + { + "type": "whitespace", + "start": 452, + "end": 453, + "value": " " + }, + { + "type": "string", + "start": 453, + "end": 479, + "value": "\"Computed property lookup\"" + }, + { + "type": "brace", + "start": 479, + "end": 480, + "value": ")" + }, + { + "type": "whitespace", + "start": 480, + "end": 482, + "value": "\n\n" + }, + { + "type": "lineComment", + "start": 482, + "end": 519, + "value": "// Test: multiple literal properties." + }, + { + "type": "whitespace", + "start": 519, + "end": 522, + "value": "\n\n\n" + }, + { + "type": "word", + "start": 522, + "end": 526, + "value": "obj2" + }, + { + "type": "whitespace", + "start": 526, + "end": 527, + "value": " " + }, + { + "type": "operator", + "start": 527, + "end": 528, + "value": "=" + }, + { + "type": "whitespace", + "start": 528, + "end": 529, + "value": " " + }, + { + "type": "brace", + "start": 529, + "end": 530, + "value": "{" + }, + { + "type": "whitespace", + "start": 530, + "end": 531, + "value": " " + }, + { + "type": "word", + "start": 531, + "end": 536, + "value": "inner" + }, + { + "type": "colon", + "start": 536, + "end": 537, + "value": ":" + }, + { + "type": "whitespace", + "start": 537, + "end": 538, + "value": " " + }, + { + "type": "word", + "start": 538, + "end": 541, + "value": "obj" + }, + { + "type": "whitespace", + "start": 541, + "end": 542, + "value": " " + }, + { + "type": "brace", + "start": 542, + "end": 543, + "value": "}" + }, + { + "type": "whitespace", + "start": 543, + "end": 545, + "value": "\n\n" + }, + { + "type": "word", + "start": 545, + "end": 550, + "value": "one_c" + }, + { + "type": "whitespace", + "start": 550, + "end": 551, + "value": " " + }, + { + "type": "operator", + "start": 551, + "end": 552, + "value": "=" + }, + { + "type": "whitespace", + "start": 552, + "end": 553, + "value": " " + }, + { + "type": "word", + "start": 553, + "end": 557, + "value": "obj2" + }, + { + "type": "period", + "start": 557, + "end": 558, + "value": "." + }, + { + "type": "word", + "start": 558, + "end": 563, + "value": "inner" + }, + { + "type": "brace", + "start": 563, + "end": 564, + "value": "[" + }, + { + "type": "string", + "start": 564, + "end": 569, + "value": "\"foo\"" + }, + { + "type": "brace", + "start": 569, + "end": 570, + "value": "]" + }, + { + "type": "whitespace", + "start": 570, + "end": 572, + "value": "\n\n" + }, + { + "type": "word", + "start": 572, + "end": 590, + "value": "assertLessThanOrEq" + }, + { + "type": "brace", + "start": 590, + "end": 591, + "value": "(" + }, + { + "type": "word", + "start": 591, + "end": 596, + "value": "one_c" + }, + { + "type": "comma", + "start": 596, + "end": 597, + "value": "," + }, + { + "type": "whitespace", + "start": 597, + "end": 598, + "value": " " + }, + { + "type": "number", + "start": 598, + "end": 599, + "value": "1" + }, + { + "type": "comma", + "start": 599, + "end": 600, + "value": "," + }, + { + "type": "whitespace", + "start": 600, + "end": 601, + "value": " " + }, + { + "type": "string", + "start": 601, + "end": 626, + "value": "\"Literal property lookup\"" + }, + { + "type": "brace", + "start": 626, + "end": 627, + "value": ")" + }, + { + "type": "whitespace", + "start": 627, + "end": 628, + "value": "\n" + }, + { + "type": "word", + "start": 628, + "end": 649, + "value": "assertGreaterThanOrEq" + }, + { + "type": "brace", + "start": 649, + "end": 650, + "value": "(" + }, + { + "type": "word", + "start": 650, + "end": 655, + "value": "one_c" + }, + { + "type": "comma", + "start": 655, + "end": 656, + "value": "," + }, + { + "type": "whitespace", + "start": 656, + "end": 657, + "value": " " + }, + { + "type": "number", + "start": 657, + "end": 658, + "value": "1" + }, + { + "type": "comma", + "start": 658, + "end": 659, + "value": "," + }, + { + "type": "whitespace", + "start": 659, + "end": 660, + "value": " " + }, + { + "type": "string", + "start": 660, + "end": 685, + "value": "\"Literal property lookup\"" + }, + { + "type": "brace", + "start": 685, + "end": 686, + "value": ")" + }, + { + "type": "whitespace", + "start": 686, + "end": 688, + "value": "\n\n" + }, + { + "type": "lineComment", + "start": 688, + "end": 746, + "value": "// Test: multiple properties, mix of literal and computed." + }, + { + "type": "whitespace", + "start": 746, + "end": 749, + "value": "\n\n\n" + }, + { + "type": "word", + "start": 749, + "end": 754, + "value": "one_d" + }, + { + "type": "whitespace", + "start": 754, + "end": 755, + "value": " " + }, + { + "type": "operator", + "start": 755, + "end": 756, + "value": "=" + }, + { + "type": "whitespace", + "start": 756, + "end": 757, + "value": " " + }, + { + "type": "word", + "start": 757, + "end": 761, + "value": "obj2" + }, + { + "type": "period", + "start": 761, + "end": 762, + "value": "." + }, + { + "type": "word", + "start": 762, + "end": 767, + "value": "inner" + }, + { + "type": "brace", + "start": 767, + "end": 768, + "value": "[" + }, + { + "type": "word", + "start": 768, + "end": 769, + "value": "p" + }, + { + "type": "brace", + "start": 769, + "end": 770, + "value": "]" + }, + { + "type": "whitespace", + "start": 770, + "end": 772, + "value": "\n\n" + }, + { + "type": "word", + "start": 772, + "end": 790, + "value": "assertLessThanOrEq" + }, + { + "type": "brace", + "start": 790, + "end": 791, + "value": "(" + }, + { + "type": "word", + "start": 791, + "end": 796, + "value": "one_d" + }, + { + "type": "comma", + "start": 796, + "end": 797, + "value": "," + }, + { + "type": "whitespace", + "start": 797, + "end": 798, + "value": " " + }, + { + "type": "number", + "start": 798, + "end": 799, + "value": "1" + }, + { + "type": "comma", + "start": 799, + "end": 800, + "value": "," + }, + { + "type": "whitespace", + "start": 800, + "end": 801, + "value": " " + }, + { + "type": "string", + "start": 801, + "end": 827, + "value": "\"Computed property lookup\"" + }, + { + "type": "brace", + "start": 827, + "end": 828, + "value": ")" + }, + { + "type": "whitespace", + "start": 828, + "end": 829, + "value": "\n" + }, + { + "type": "word", + "start": 829, + "end": 850, + "value": "assertGreaterThanOrEq" + }, + { + "type": "brace", + "start": 850, + "end": 851, + "value": "(" + }, + { + "type": "word", + "start": 851, + "end": 856, + "value": "one_d" + }, + { + "type": "comma", + "start": 856, + "end": 857, + "value": "," + }, + { + "type": "whitespace", + "start": 857, + "end": 858, + "value": " " + }, + { + "type": "number", + "start": 858, + "end": 859, + "value": "1" + }, + { + "type": "comma", + "start": 859, + "end": 860, + "value": "," + }, + { + "type": "whitespace", + "start": 860, + "end": 861, + "value": " " + }, + { + "type": "string", + "start": 861, + "end": 887, + "value": "\"Computed property lookup\"" + }, + { + "type": "brace", + "start": 887, + "end": 888, + "value": ")" + }, + { + "type": "whitespace", + "start": 888, + "end": 889, + "value": "\n" + } + ] +} diff --git a/src/wasm-lib/kcl/tests/sketch_in_object/ast.snap b/src/wasm-lib/kcl/tests/sketch_in_object/ast.snap new file mode 100644 index 0000000000..09faa9846b --- /dev/null +++ b/src/wasm-lib/kcl/tests/sketch_in_object/ast.snap @@ -0,0 +1,845 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of parsing sketch_in_object.kcl +snapshot_kind: text +--- +{ + "Ok": { + "body": [ + { + "declarations": [ + { + "end": 157, + "id": { + "end": 7, + "name": "test", + "start": 3, + "type": "Identifier" + }, + "init": { + "body": { + "body": [ + { + "argument": { + "body": [ + { + "arguments": [ + { + "end": 45, + "raw": "'XY'", + "start": 41, + "type": "Literal", + "type": "Literal", + "value": "XY" + } + ], + "callee": { + "end": 40, + "name": "startSketchOn", + "start": 27, + "type": "Identifier" + }, + "end": 46, + "optional": false, + "start": 27, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 69, + "raw": "0", + "start": 68, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + { + "end": 72, + "raw": "0", + "start": 71, + "type": "Literal", + "type": "Literal", + "value": 0 + } + ], + "end": 73, + "start": 67, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 76, + "start": 75, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 66, + "name": "startProfileAt", + "start": 52, + "type": "Identifier" + }, + "end": 77, + "optional": false, + "start": 52, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 90, + "raw": "0", + "start": 89, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + { + "end": 93, + "raw": "1", + "start": 92, + "type": "Literal", + "type": "Literal", + "value": 1 + } + ], + "end": 94, + "start": 88, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 97, + "start": 96, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 87, + "name": "line", + "start": 83, + "type": "Identifier" + }, + "end": 98, + "optional": false, + "start": 83, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 111, + "raw": "1", + "start": 110, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + { + "end": 114, + "raw": "0", + "start": 113, + "type": "Literal", + "type": "Literal", + "value": 0 + } + ], + "end": 115, + "start": 109, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 118, + "start": 117, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 108, + "name": "line", + "start": 104, + "type": "Identifier" + }, + "end": 119, + "optional": false, + "start": 104, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 132, + "raw": "0", + "start": 131, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + { + "argument": { + "end": 136, + "raw": "1", + "start": 135, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + "end": 136, + "operator": "-", + "start": 134, + "type": "UnaryExpression", + "type": "UnaryExpression" + } + ], + "end": 137, + "start": 130, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 140, + "start": 139, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 129, + "name": "line", + "start": 125, + "type": "Identifier" + }, + "end": 141, + "optional": false, + "start": 125, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 154, + "start": 153, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 152, + "name": "close", + "start": 147, + "type": "Identifier" + }, + "end": 155, + "optional": false, + "start": 147, + "type": "CallExpression", + "type": "CallExpression" + } + ], + "end": 155, + "start": 27, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "end": 155, + "start": 20, + "type": "ReturnStatement", + "type": "ReturnStatement" + } + ], + "end": 157, + "start": 16 + }, + "end": 157, + "params": [], + "start": 10, + "type": "FunctionExpression", + "type": "FunctionExpression" + }, + "start": 3, + "type": "VariableDeclarator" + } + ], + "end": 157, + "kind": "fn", + "start": 0, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declarations": [ + { + "end": 369, + "id": { + "end": 167, + "name": "test2", + "start": 162, + "type": "Identifier" + }, + "init": { + "body": { + "body": [ + { + "argument": { + "end": 367, + "properties": [ + { + "end": 365, + "key": { + "end": 197, + "name": "thing1", + "start": 191, + "type": "Identifier" + }, + "start": 191, + "type": "ObjectProperty", + "value": { + "end": 365, + "properties": [ + { + "end": 361, + "key": { + "end": 211, + "name": "thing2", + "start": 205, + "type": "Identifier" + }, + "start": 205, + "type": "ObjectProperty", + "value": { + "body": [ + { + "arguments": [ + { + "end": 231, + "raw": "'XY'", + "start": 227, + "type": "Literal", + "type": "Literal", + "value": "XY" + } + ], + "callee": { + "end": 226, + "name": "startSketchOn", + "start": 213, + "type": "Identifier" + }, + "end": 232, + "optional": false, + "start": 213, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 259, + "raw": "0", + "start": 258, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + { + "end": 262, + "raw": "0", + "start": 261, + "type": "Literal", + "type": "Literal", + "value": 0 + } + ], + "end": 263, + "start": 257, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 266, + "start": 265, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 256, + "name": "startProfileAt", + "start": 242, + "type": "Identifier" + }, + "end": 267, + "optional": false, + "start": 242, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 284, + "raw": "0", + "start": 283, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + { + "end": 287, + "raw": "1", + "start": 286, + "type": "Literal", + "type": "Literal", + "value": 1 + } + ], + "end": 288, + "start": 282, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 291, + "start": 290, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 281, + "name": "line", + "start": 277, + "type": "Identifier" + }, + "end": 292, + "optional": false, + "start": 277, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 309, + "raw": "1", + "start": 308, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + { + "end": 312, + "raw": "0", + "start": 311, + "type": "Literal", + "type": "Literal", + "value": 0 + } + ], + "end": 313, + "start": 307, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 316, + "start": 315, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 306, + "name": "line", + "start": 302, + "type": "Identifier" + }, + "end": 317, + "optional": false, + "start": 302, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 334, + "raw": "0", + "start": 333, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + { + "argument": { + "end": 338, + "raw": "1", + "start": 337, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + "end": 338, + "operator": "-", + "start": 336, + "type": "UnaryExpression", + "type": "UnaryExpression" + } + ], + "end": 339, + "start": 332, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 342, + "start": 341, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 331, + "name": "line", + "start": 327, + "type": "Identifier" + }, + "end": 343, + "optional": false, + "start": 327, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 360, + "start": 359, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 358, + "name": "close", + "start": 353, + "type": "Identifier" + }, + "end": 361, + "optional": false, + "start": 353, + "type": "CallExpression", + "type": "CallExpression" + } + ], + "end": 361, + "start": 213, + "type": "PipeExpression", + "type": "PipeExpression" + } + } + ], + "start": 199, + "type": "ObjectExpression", + "type": "ObjectExpression" + } + } + ], + "start": 187, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + "end": 367, + "start": 180, + "type": "ReturnStatement", + "type": "ReturnStatement" + } + ], + "end": 369, + "start": 176 + }, + "end": 369, + "params": [], + "start": 170, + "type": "FunctionExpression", + "type": "FunctionExpression" + }, + "start": 162, + "type": "VariableDeclarator" + } + ], + "end": 369, + "kind": "fn", + "start": 159, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declarations": [ + { + "end": 381, + "id": { + "end": 372, + "name": "x", + "start": 371, + "type": "Identifier" + }, + "init": { + "arguments": [], + "callee": { + "end": 379, + "name": "test", + "start": 375, + "type": "Identifier" + }, + "end": 381, + "optional": false, + "start": 375, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 371, + "type": "VariableDeclarator" + } + ], + "end": 381, + "kind": "const", + "start": 371, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "end": 404, + "expression": { + "body": [ + { + "end": 383, + "name": "x", + "start": 382, + "type": "Identifier", + "type": "Identifier" + }, + { + "arguments": [ + { + "argument": { + "end": 400, + "raw": "10", + "start": 398, + "type": "Literal", + "type": "Literal", + "value": 10 + }, + "end": 400, + "operator": "-", + "start": 397, + "type": "UnaryExpression", + "type": "UnaryExpression" + }, + { + "end": 403, + "start": 402, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 396, + "name": "extrude", + "start": 389, + "type": "Identifier" + }, + "end": 404, + "optional": false, + "start": 389, + "type": "CallExpression", + "type": "CallExpression" + } + ], + "end": 404, + "start": 382, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "start": 382, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + }, + { + "declarations": [ + { + "end": 418, + "id": { + "end": 408, + "name": "x2", + "start": 406, + "type": "Identifier" + }, + "init": { + "arguments": [], + "callee": { + "end": 416, + "name": "test2", + "start": 411, + "type": "Identifier" + }, + "end": 418, + "optional": false, + "start": 411, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 406, + "type": "VariableDeclarator" + } + ], + "end": 418, + "kind": "const", + "start": 406, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "end": 455, + "expression": { + "body": [ + { + "computed": false, + "end": 435, + "object": { + "computed": false, + "end": 428, + "object": { + "end": 421, + "name": "x2", + "start": 419, + "type": "Identifier", + "type": "Identifier" + }, + "property": { + "end": 428, + "name": "thing1", + "start": 422, + "type": "Identifier", + "type": "Identifier" + }, + "start": 419, + "type": "MemberExpression", + "type": "MemberExpression" + }, + "property": { + "end": 435, + "name": "thing2", + "start": 429, + "type": "Identifier", + "type": "Identifier" + }, + "start": 419, + "type": "MemberExpression", + "type": "MemberExpression" + }, + { + "arguments": [ + { + "end": 451, + "raw": "10", + "start": 449, + "type": "Literal", + "type": "Literal", + "value": 10 + }, + { + "end": 454, + "start": 453, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 448, + "name": "extrude", + "start": 441, + "type": "Identifier" + }, + "end": 455, + "optional": false, + "start": 441, + "type": "CallExpression", + "type": "CallExpression" + } + ], + "end": 455, + "start": 419, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "start": 419, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 456, + "nonCodeMeta": { + "nonCodeNodes": { + "0": [ + { + "end": 159, + "start": 157, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "1": [ + { + "end": 371, + "start": 369, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "3": [ + { + "end": 406, + "start": 404, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ] + }, + "startNodes": [] + }, + "start": 0 + } +} diff --git a/src/wasm-lib/tests/executor/inputs/no_visuals/sketch_in_object.kcl b/src/wasm-lib/kcl/tests/sketch_in_object/input.kcl similarity index 52% rename from src/wasm-lib/tests/executor/inputs/no_visuals/sketch_in_object.kcl rename to src/wasm-lib/kcl/tests/sketch_in_object/input.kcl index 1acbb951d1..a66c9d7cc9 100644 --- a/src/wasm-lib/tests/executor/inputs/no_visuals/sketch_in_object.kcl +++ b/src/wasm-lib/kcl/tests/sketch_in_object/input.kcl @@ -9,21 +9,21 @@ fn test = () => { fn test2 = () => { return { - thing1: { - thing2: startSketchOn('XY') - |> startProfileAt([0, 0], %) - |> line([0, 1], %) - |> line([1, 0], %) - |> line([0, -1], %) - |> close(%) - } + thing1: { + thing2: startSketchOn('XY') + |> startProfileAt([0, 0], %) + |> line([0, 1], %) + |> line([1, 0], %) + |> line([0, -1], %) + |> close(%) } } +} -const x = test() +x = test() x |> extrude(-10, %) -const x2 = test2() +x2 = test2() x2.thing1.thing2 |> extrude(10, %) diff --git a/src/wasm-lib/kcl/tests/sketch_in_object/program_memory.snap b/src/wasm-lib/kcl/tests/sketch_in_object/program_memory.snap new file mode 100644 index 0000000000..93d2a364a7 --- /dev/null +++ b/src/wasm-lib/kcl/tests/sketch_in_object/program_memory.snap @@ -0,0 +1,1283 @@ +--- +source: kcl/src/simulation_tests.rs +description: Program memory after executing sketch_in_object.kcl +snapshot_kind: text +--- +{ + "environments": [ + { + "bindings": { + "HALF_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 180, + "__meta": [] + }, + "QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 90, + "__meta": [] + }, + "THREE_QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 270, + "__meta": [] + }, + "ZERO": { + "type": "UserVal", + "type": "UserVal", + "value": 0, + "__meta": [] + }, + "test": { + "type": "Function", + "expression": { + "body": { + "body": [ + { + "argument": { + "body": [ + { + "arguments": [ + { + "end": 45, + "raw": "'XY'", + "start": 41, + "type": "Literal", + "type": "Literal", + "value": "XY" + } + ], + "callee": { + "end": 40, + "name": "startSketchOn", + "start": 27, + "type": "Identifier" + }, + "end": 46, + "optional": false, + "start": 27, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 69, + "raw": "0", + "start": 68, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + { + "end": 72, + "raw": "0", + "start": 71, + "type": "Literal", + "type": "Literal", + "value": 0 + } + ], + "end": 73, + "start": 67, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 76, + "start": 75, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 66, + "name": "startProfileAt", + "start": 52, + "type": "Identifier" + }, + "end": 77, + "optional": false, + "start": 52, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 90, + "raw": "0", + "start": 89, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + { + "end": 93, + "raw": "1", + "start": 92, + "type": "Literal", + "type": "Literal", + "value": 1 + } + ], + "end": 94, + "start": 88, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 97, + "start": 96, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 87, + "name": "line", + "start": 83, + "type": "Identifier" + }, + "end": 98, + "optional": false, + "start": 83, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 111, + "raw": "1", + "start": 110, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + { + "end": 114, + "raw": "0", + "start": 113, + "type": "Literal", + "type": "Literal", + "value": 0 + } + ], + "end": 115, + "start": 109, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 118, + "start": 117, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 108, + "name": "line", + "start": 104, + "type": "Identifier" + }, + "end": 119, + "optional": false, + "start": 104, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 132, + "raw": "0", + "start": 131, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + { + "argument": { + "end": 136, + "raw": "1", + "start": 135, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + "end": 136, + "operator": "-", + "start": 134, + "type": "UnaryExpression", + "type": "UnaryExpression" + } + ], + "end": 137, + "start": 130, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 140, + "start": 139, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 129, + "name": "line", + "start": 125, + "type": "Identifier" + }, + "end": 141, + "optional": false, + "start": 125, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 154, + "start": 153, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 152, + "name": "close", + "start": 147, + "type": "Identifier" + }, + "end": 155, + "optional": false, + "start": 147, + "type": "CallExpression", + "type": "CallExpression" + } + ], + "end": 155, + "start": 27, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "end": 155, + "start": 20, + "type": "ReturnStatement", + "type": "ReturnStatement" + } + ], + "end": 157, + "start": 16 + }, + "end": 157, + "params": [], + "start": 10, + "type": "FunctionExpression" + }, + "memory": { + "environments": [ + { + "bindings": { + "HALF_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 180, + "__meta": [] + }, + "QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 90, + "__meta": [] + }, + "THREE_QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 270, + "__meta": [] + }, + "ZERO": { + "type": "UserVal", + "type": "UserVal", + "value": 0, + "__meta": [] + } + }, + "parent": null + } + ], + "currentEnv": 0, + "return": null + }, + "__meta": [ + { + "sourceRange": [ + 10, + 157 + ] + } + ] + }, + "test2": { + "type": "Function", + "expression": { + "body": { + "body": [ + { + "argument": { + "end": 367, + "properties": [ + { + "end": 365, + "key": { + "end": 197, + "name": "thing1", + "start": 191, + "type": "Identifier" + }, + "start": 191, + "type": "ObjectProperty", + "value": { + "end": 365, + "properties": [ + { + "end": 361, + "key": { + "end": 211, + "name": "thing2", + "start": 205, + "type": "Identifier" + }, + "start": 205, + "type": "ObjectProperty", + "value": { + "body": [ + { + "arguments": [ + { + "end": 231, + "raw": "'XY'", + "start": 227, + "type": "Literal", + "type": "Literal", + "value": "XY" + } + ], + "callee": { + "end": 226, + "name": "startSketchOn", + "start": 213, + "type": "Identifier" + }, + "end": 232, + "optional": false, + "start": 213, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 259, + "raw": "0", + "start": 258, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + { + "end": 262, + "raw": "0", + "start": 261, + "type": "Literal", + "type": "Literal", + "value": 0 + } + ], + "end": 263, + "start": 257, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 266, + "start": 265, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 256, + "name": "startProfileAt", + "start": 242, + "type": "Identifier" + }, + "end": 267, + "optional": false, + "start": 242, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 284, + "raw": "0", + "start": 283, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + { + "end": 287, + "raw": "1", + "start": 286, + "type": "Literal", + "type": "Literal", + "value": 1 + } + ], + "end": 288, + "start": 282, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 291, + "start": 290, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 281, + "name": "line", + "start": 277, + "type": "Identifier" + }, + "end": 292, + "optional": false, + "start": 277, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 309, + "raw": "1", + "start": 308, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + { + "end": 312, + "raw": "0", + "start": 311, + "type": "Literal", + "type": "Literal", + "value": 0 + } + ], + "end": 313, + "start": 307, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 316, + "start": 315, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 306, + "name": "line", + "start": 302, + "type": "Identifier" + }, + "end": 317, + "optional": false, + "start": 302, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 334, + "raw": "0", + "start": 333, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + { + "argument": { + "end": 338, + "raw": "1", + "start": 337, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + "end": 338, + "operator": "-", + "start": 336, + "type": "UnaryExpression", + "type": "UnaryExpression" + } + ], + "end": 339, + "start": 332, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 342, + "start": 341, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 331, + "name": "line", + "start": 327, + "type": "Identifier" + }, + "end": 343, + "optional": false, + "start": 327, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 360, + "start": 359, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 358, + "name": "close", + "start": 353, + "type": "Identifier" + }, + "end": 361, + "optional": false, + "start": 353, + "type": "CallExpression", + "type": "CallExpression" + } + ], + "end": 361, + "start": 213, + "type": "PipeExpression", + "type": "PipeExpression" + } + } + ], + "start": 199, + "type": "ObjectExpression", + "type": "ObjectExpression" + } + } + ], + "start": 187, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + "end": 367, + "start": 180, + "type": "ReturnStatement", + "type": "ReturnStatement" + } + ], + "end": 369, + "start": 176 + }, + "end": 369, + "params": [], + "start": 170, + "type": "FunctionExpression" + }, + "memory": { + "environments": [ + { + "bindings": { + "HALF_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 180, + "__meta": [] + }, + "QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 90, + "__meta": [] + }, + "THREE_QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 270, + "__meta": [] + }, + "ZERO": { + "type": "UserVal", + "type": "UserVal", + "value": 0, + "__meta": [] + }, + "test": { + "type": "Function", + "expression": { + "body": { + "body": [ + { + "argument": { + "body": [ + { + "arguments": [ + { + "end": 45, + "raw": "'XY'", + "start": 41, + "type": "Literal", + "type": "Literal", + "value": "XY" + } + ], + "callee": { + "end": 40, + "name": "startSketchOn", + "start": 27, + "type": "Identifier" + }, + "end": 46, + "optional": false, + "start": 27, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 69, + "raw": "0", + "start": 68, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + { + "end": 72, + "raw": "0", + "start": 71, + "type": "Literal", + "type": "Literal", + "value": 0 + } + ], + "end": 73, + "start": 67, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 76, + "start": 75, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 66, + "name": "startProfileAt", + "start": 52, + "type": "Identifier" + }, + "end": 77, + "optional": false, + "start": 52, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 90, + "raw": "0", + "start": 89, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + { + "end": 93, + "raw": "1", + "start": 92, + "type": "Literal", + "type": "Literal", + "value": 1 + } + ], + "end": 94, + "start": 88, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 97, + "start": 96, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 87, + "name": "line", + "start": 83, + "type": "Identifier" + }, + "end": 98, + "optional": false, + "start": 83, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 111, + "raw": "1", + "start": 110, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + { + "end": 114, + "raw": "0", + "start": 113, + "type": "Literal", + "type": "Literal", + "value": 0 + } + ], + "end": 115, + "start": 109, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 118, + "start": 117, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 108, + "name": "line", + "start": 104, + "type": "Identifier" + }, + "end": 119, + "optional": false, + "start": 104, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 132, + "raw": "0", + "start": 131, + "type": "Literal", + "type": "Literal", + "value": 0 + }, + { + "argument": { + "end": 136, + "raw": "1", + "start": 135, + "type": "Literal", + "type": "Literal", + "value": 1 + }, + "end": 136, + "operator": "-", + "start": 134, + "type": "UnaryExpression", + "type": "UnaryExpression" + } + ], + "end": 137, + "start": 130, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 140, + "start": 139, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 129, + "name": "line", + "start": 125, + "type": "Identifier" + }, + "end": 141, + "optional": false, + "start": 125, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 154, + "start": 153, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 152, + "name": "close", + "start": 147, + "type": "Identifier" + }, + "end": 155, + "optional": false, + "start": 147, + "type": "CallExpression", + "type": "CallExpression" + } + ], + "end": 155, + "start": 27, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "end": 155, + "start": 20, + "type": "ReturnStatement", + "type": "ReturnStatement" + } + ], + "end": 157, + "start": 16 + }, + "end": 157, + "params": [], + "start": 10, + "type": "FunctionExpression" + }, + "memory": { + "environments": [ + { + "bindings": { + "HALF_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 180, + "__meta": [] + }, + "QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 90, + "__meta": [] + }, + "THREE_QUARTER_TURN": { + "type": "UserVal", + "type": "UserVal", + "value": 270, + "__meta": [] + }, + "ZERO": { + "type": "UserVal", + "type": "UserVal", + "value": 0, + "__meta": [] + } + }, + "parent": null + } + ], + "currentEnv": 0, + "return": null + }, + "__meta": [ + { + "sourceRange": [ + 10, + 157 + ] + } + ] + } + }, + "parent": null + } + ], + "currentEnv": 0, + "return": null + }, + "__meta": [ + { + "sourceRange": [ + 170, + 369 + ] + } + ] + }, + "x": { + "type": "UserVal", + "type": "UserVal", + "value": { + "__meta": [ + { + "sourceRange": [ + 52, + 77 + ] + } + ], + "id": "[uuid]", + "on": { + "__meta": [], + "id": "[uuid]", + "origin": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "type": "plane", + "value": "XY", + "xAxis": { + "x": 1.0, + "y": 0.0, + "z": 0.0 + }, + "yAxis": { + "x": 0.0, + "y": 1.0, + "z": 0.0 + }, + "zAxis": { + "x": 0.0, + "y": 0.0, + "z": 1.0 + } + }, + "paths": [ + { + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [ + 83, + 98 + ] + }, + "from": [ + 0.0, + 0.0 + ], + "tag": null, + "to": [ + 0.0, + 1.0 + ], + "type": "ToPoint" + }, + { + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [ + 104, + 119 + ] + }, + "from": [ + 0.0, + 1.0 + ], + "tag": null, + "to": [ + 1.0, + 1.0 + ], + "type": "ToPoint" + }, + { + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [ + 125, + 141 + ] + }, + "from": [ + 1.0, + 1.0 + ], + "tag": null, + "to": [ + 1.0, + 0.0 + ], + "type": "ToPoint" + }, + { + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [ + 147, + 155 + ] + }, + "from": [ + 1.0, + 0.0 + ], + "tag": null, + "to": [ + 0.0, + 0.0 + ], + "type": "ToPoint" + } + ], + "start": { + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [ + 52, + 77 + ] + }, + "from": [ + 0.0, + 0.0 + ], + "tag": null, + "to": [ + 0.0, + 0.0 + ] + }, + "type": "Sketch" + }, + "__meta": [ + { + "sourceRange": [ + 52, + 77 + ] + } + ] + }, + "x2": { + "type": "UserVal", + "type": "UserVal", + "value": { + "thing1": { + "thing2": { + "__meta": [ + { + "sourceRange": [ + 242, + 267 + ] + } + ], + "id": "[uuid]", + "on": { + "__meta": [], + "id": "[uuid]", + "origin": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "type": "plane", + "value": "XY", + "xAxis": { + "x": 1.0, + "y": 0.0, + "z": 0.0 + }, + "yAxis": { + "x": 0.0, + "y": 1.0, + "z": 0.0 + }, + "zAxis": { + "x": 0.0, + "y": 0.0, + "z": 1.0 + } + }, + "paths": [ + { + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [ + 277, + 292 + ] + }, + "from": [ + 0.0, + 0.0 + ], + "tag": null, + "to": [ + 0.0, + 1.0 + ], + "type": "ToPoint" + }, + { + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [ + 302, + 317 + ] + }, + "from": [ + 0.0, + 1.0 + ], + "tag": null, + "to": [ + 1.0, + 1.0 + ], + "type": "ToPoint" + }, + { + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [ + 327, + 343 + ] + }, + "from": [ + 1.0, + 1.0 + ], + "tag": null, + "to": [ + 1.0, + 0.0 + ], + "type": "ToPoint" + }, + { + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [ + 353, + 361 + ] + }, + "from": [ + 1.0, + 0.0 + ], + "tag": null, + "to": [ + 0.0, + 0.0 + ], + "type": "ToPoint" + } + ], + "start": { + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [ + 242, + 267 + ] + }, + "from": [ + 0.0, + 0.0 + ], + "tag": null, + "to": [ + 0.0, + 0.0 + ] + }, + "type": "Sketch" + } + } + }, + "__meta": [ + { + "sourceRange": [ + 187, + 367 + ] + } + ] + } + }, + "parent": null + } + ], + "currentEnv": 0, + "return": null +} diff --git a/src/wasm-lib/kcl/tests/sketch_in_object/tokens.snap b/src/wasm-lib/kcl/tests/sketch_in_object/tokens.snap new file mode 100644 index 0000000000..f8a64f489a --- /dev/null +++ b/src/wasm-lib/kcl/tests/sketch_in_object/tokens.snap @@ -0,0 +1,1443 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of tokenizing sketch_in_object.kcl +snapshot_kind: text +--- +{ + "Ok": [ + { + "type": "keyword", + "start": 0, + "end": 2, + "value": "fn" + }, + { + "type": "whitespace", + "start": 2, + "end": 3, + "value": " " + }, + { + "type": "word", + "start": 3, + "end": 7, + "value": "test" + }, + { + "type": "whitespace", + "start": 7, + "end": 8, + "value": " " + }, + { + "type": "operator", + "start": 8, + "end": 9, + "value": "=" + }, + { + "type": "whitespace", + "start": 9, + "end": 10, + "value": " " + }, + { + "type": "brace", + "start": 10, + "end": 11, + "value": "(" + }, + { + "type": "brace", + "start": 11, + "end": 12, + "value": ")" + }, + { + "type": "whitespace", + "start": 12, + "end": 13, + "value": " " + }, + { + "type": "operator", + "start": 13, + "end": 15, + "value": "=>" + }, + { + "type": "whitespace", + "start": 15, + "end": 16, + "value": " " + }, + { + "type": "brace", + "start": 16, + "end": 17, + "value": "{" + }, + { + "type": "whitespace", + "start": 17, + "end": 20, + "value": "\n " + }, + { + "type": "keyword", + "start": 20, + "end": 26, + "value": "return" + }, + { + "type": "whitespace", + "start": 26, + "end": 27, + "value": " " + }, + { + "type": "word", + "start": 27, + "end": 40, + "value": "startSketchOn" + }, + { + "type": "brace", + "start": 40, + "end": 41, + "value": "(" + }, + { + "type": "string", + "start": 41, + "end": 45, + "value": "'XY'" + }, + { + "type": "brace", + "start": 45, + "end": 46, + "value": ")" + }, + { + "type": "whitespace", + "start": 46, + "end": 49, + "value": "\n " + }, + { + "type": "operator", + "start": 49, + "end": 51, + "value": "|>" + }, + { + "type": "whitespace", + "start": 51, + "end": 52, + "value": " " + }, + { + "type": "word", + "start": 52, + "end": 66, + "value": "startProfileAt" + }, + { + "type": "brace", + "start": 66, + "end": 67, + "value": "(" + }, + { + "type": "brace", + "start": 67, + "end": 68, + "value": "[" + }, + { + "type": "number", + "start": 68, + "end": 69, + "value": "0" + }, + { + "type": "comma", + "start": 69, + "end": 70, + "value": "," + }, + { + "type": "whitespace", + "start": 70, + "end": 71, + "value": " " + }, + { + "type": "number", + "start": 71, + "end": 72, + "value": "0" + }, + { + "type": "brace", + "start": 72, + "end": 73, + "value": "]" + }, + { + "type": "comma", + "start": 73, + "end": 74, + "value": "," + }, + { + "type": "whitespace", + "start": 74, + "end": 75, + "value": " " + }, + { + "type": "operator", + "start": 75, + "end": 76, + "value": "%" + }, + { + "type": "brace", + "start": 76, + "end": 77, + "value": ")" + }, + { + "type": "whitespace", + "start": 77, + "end": 80, + "value": "\n " + }, + { + "type": "operator", + "start": 80, + "end": 82, + "value": "|>" + }, + { + "type": "whitespace", + "start": 82, + "end": 83, + "value": " " + }, + { + "type": "word", + "start": 83, + "end": 87, + "value": "line" + }, + { + "type": "brace", + "start": 87, + "end": 88, + "value": "(" + }, + { + "type": "brace", + "start": 88, + "end": 89, + "value": "[" + }, + { + "type": "number", + "start": 89, + "end": 90, + "value": "0" + }, + { + "type": "comma", + "start": 90, + "end": 91, + "value": "," + }, + { + "type": "whitespace", + "start": 91, + "end": 92, + "value": " " + }, + { + "type": "number", + "start": 92, + "end": 93, + "value": "1" + }, + { + "type": "brace", + "start": 93, + "end": 94, + "value": "]" + }, + { + "type": "comma", + "start": 94, + "end": 95, + "value": "," + }, + { + "type": "whitespace", + "start": 95, + "end": 96, + "value": " " + }, + { + "type": "operator", + "start": 96, + "end": 97, + "value": "%" + }, + { + "type": "brace", + "start": 97, + "end": 98, + "value": ")" + }, + { + "type": "whitespace", + "start": 98, + "end": 101, + "value": "\n " + }, + { + "type": "operator", + "start": 101, + "end": 103, + "value": "|>" + }, + { + "type": "whitespace", + "start": 103, + "end": 104, + "value": " " + }, + { + "type": "word", + "start": 104, + "end": 108, + "value": "line" + }, + { + "type": "brace", + "start": 108, + "end": 109, + "value": "(" + }, + { + "type": "brace", + "start": 109, + "end": 110, + "value": "[" + }, + { + "type": "number", + "start": 110, + "end": 111, + "value": "1" + }, + { + "type": "comma", + "start": 111, + "end": 112, + "value": "," + }, + { + "type": "whitespace", + "start": 112, + "end": 113, + "value": " " + }, + { + "type": "number", + "start": 113, + "end": 114, + "value": "0" + }, + { + "type": "brace", + "start": 114, + "end": 115, + "value": "]" + }, + { + "type": "comma", + "start": 115, + "end": 116, + "value": "," + }, + { + "type": "whitespace", + "start": 116, + "end": 117, + "value": " " + }, + { + "type": "operator", + "start": 117, + "end": 118, + "value": "%" + }, + { + "type": "brace", + "start": 118, + "end": 119, + "value": ")" + }, + { + "type": "whitespace", + "start": 119, + "end": 122, + "value": "\n " + }, + { + "type": "operator", + "start": 122, + "end": 124, + "value": "|>" + }, + { + "type": "whitespace", + "start": 124, + "end": 125, + "value": " " + }, + { + "type": "word", + "start": 125, + "end": 129, + "value": "line" + }, + { + "type": "brace", + "start": 129, + "end": 130, + "value": "(" + }, + { + "type": "brace", + "start": 130, + "end": 131, + "value": "[" + }, + { + "type": "number", + "start": 131, + "end": 132, + "value": "0" + }, + { + "type": "comma", + "start": 132, + "end": 133, + "value": "," + }, + { + "type": "whitespace", + "start": 133, + "end": 134, + "value": " " + }, + { + "type": "operator", + "start": 134, + "end": 135, + "value": "-" + }, + { + "type": "number", + "start": 135, + "end": 136, + "value": "1" + }, + { + "type": "brace", + "start": 136, + "end": 137, + "value": "]" + }, + { + "type": "comma", + "start": 137, + "end": 138, + "value": "," + }, + { + "type": "whitespace", + "start": 138, + "end": 139, + "value": " " + }, + { + "type": "operator", + "start": 139, + "end": 140, + "value": "%" + }, + { + "type": "brace", + "start": 140, + "end": 141, + "value": ")" + }, + { + "type": "whitespace", + "start": 141, + "end": 144, + "value": "\n " + }, + { + "type": "operator", + "start": 144, + "end": 146, + "value": "|>" + }, + { + "type": "whitespace", + "start": 146, + "end": 147, + "value": " " + }, + { + "type": "word", + "start": 147, + "end": 152, + "value": "close" + }, + { + "type": "brace", + "start": 152, + "end": 153, + "value": "(" + }, + { + "type": "operator", + "start": 153, + "end": 154, + "value": "%" + }, + { + "type": "brace", + "start": 154, + "end": 155, + "value": ")" + }, + { + "type": "whitespace", + "start": 155, + "end": 156, + "value": "\n" + }, + { + "type": "brace", + "start": 156, + "end": 157, + "value": "}" + }, + { + "type": "whitespace", + "start": 157, + "end": 159, + "value": "\n\n" + }, + { + "type": "keyword", + "start": 159, + "end": 161, + "value": "fn" + }, + { + "type": "whitespace", + "start": 161, + "end": 162, + "value": " " + }, + { + "type": "word", + "start": 162, + "end": 167, + "value": "test2" + }, + { + "type": "whitespace", + "start": 167, + "end": 168, + "value": " " + }, + { + "type": "operator", + "start": 168, + "end": 169, + "value": "=" + }, + { + "type": "whitespace", + "start": 169, + "end": 170, + "value": " " + }, + { + "type": "brace", + "start": 170, + "end": 171, + "value": "(" + }, + { + "type": "brace", + "start": 171, + "end": 172, + "value": ")" + }, + { + "type": "whitespace", + "start": 172, + "end": 173, + "value": " " + }, + { + "type": "operator", + "start": 173, + "end": 175, + "value": "=>" + }, + { + "type": "whitespace", + "start": 175, + "end": 176, + "value": " " + }, + { + "type": "brace", + "start": 176, + "end": 177, + "value": "{" + }, + { + "type": "whitespace", + "start": 177, + "end": 180, + "value": "\n " + }, + { + "type": "keyword", + "start": 180, + "end": 186, + "value": "return" + }, + { + "type": "whitespace", + "start": 186, + "end": 187, + "value": " " + }, + { + "type": "brace", + "start": 187, + "end": 188, + "value": "{" + }, + { + "type": "whitespace", + "start": 188, + "end": 191, + "value": "\n " + }, + { + "type": "word", + "start": 191, + "end": 197, + "value": "thing1" + }, + { + "type": "colon", + "start": 197, + "end": 198, + "value": ":" + }, + { + "type": "whitespace", + "start": 198, + "end": 199, + "value": " " + }, + { + "type": "brace", + "start": 199, + "end": 200, + "value": "{" + }, + { + "type": "whitespace", + "start": 200, + "end": 205, + "value": "\n " + }, + { + "type": "word", + "start": 205, + "end": 211, + "value": "thing2" + }, + { + "type": "colon", + "start": 211, + "end": 212, + "value": ":" + }, + { + "type": "whitespace", + "start": 212, + "end": 213, + "value": " " + }, + { + "type": "word", + "start": 213, + "end": 226, + "value": "startSketchOn" + }, + { + "type": "brace", + "start": 226, + "end": 227, + "value": "(" + }, + { + "type": "string", + "start": 227, + "end": 231, + "value": "'XY'" + }, + { + "type": "brace", + "start": 231, + "end": 232, + "value": ")" + }, + { + "type": "whitespace", + "start": 232, + "end": 239, + "value": "\n " + }, + { + "type": "operator", + "start": 239, + "end": 241, + "value": "|>" + }, + { + "type": "whitespace", + "start": 241, + "end": 242, + "value": " " + }, + { + "type": "word", + "start": 242, + "end": 256, + "value": "startProfileAt" + }, + { + "type": "brace", + "start": 256, + "end": 257, + "value": "(" + }, + { + "type": "brace", + "start": 257, + "end": 258, + "value": "[" + }, + { + "type": "number", + "start": 258, + "end": 259, + "value": "0" + }, + { + "type": "comma", + "start": 259, + "end": 260, + "value": "," + }, + { + "type": "whitespace", + "start": 260, + "end": 261, + "value": " " + }, + { + "type": "number", + "start": 261, + "end": 262, + "value": "0" + }, + { + "type": "brace", + "start": 262, + "end": 263, + "value": "]" + }, + { + "type": "comma", + "start": 263, + "end": 264, + "value": "," + }, + { + "type": "whitespace", + "start": 264, + "end": 265, + "value": " " + }, + { + "type": "operator", + "start": 265, + "end": 266, + "value": "%" + }, + { + "type": "brace", + "start": 266, + "end": 267, + "value": ")" + }, + { + "type": "whitespace", + "start": 267, + "end": 274, + "value": "\n " + }, + { + "type": "operator", + "start": 274, + "end": 276, + "value": "|>" + }, + { + "type": "whitespace", + "start": 276, + "end": 277, + "value": " " + }, + { + "type": "word", + "start": 277, + "end": 281, + "value": "line" + }, + { + "type": "brace", + "start": 281, + "end": 282, + "value": "(" + }, + { + "type": "brace", + "start": 282, + "end": 283, + "value": "[" + }, + { + "type": "number", + "start": 283, + "end": 284, + "value": "0" + }, + { + "type": "comma", + "start": 284, + "end": 285, + "value": "," + }, + { + "type": "whitespace", + "start": 285, + "end": 286, + "value": " " + }, + { + "type": "number", + "start": 286, + "end": 287, + "value": "1" + }, + { + "type": "brace", + "start": 287, + "end": 288, + "value": "]" + }, + { + "type": "comma", + "start": 288, + "end": 289, + "value": "," + }, + { + "type": "whitespace", + "start": 289, + "end": 290, + "value": " " + }, + { + "type": "operator", + "start": 290, + "end": 291, + "value": "%" + }, + { + "type": "brace", + "start": 291, + "end": 292, + "value": ")" + }, + { + "type": "whitespace", + "start": 292, + "end": 299, + "value": "\n " + }, + { + "type": "operator", + "start": 299, + "end": 301, + "value": "|>" + }, + { + "type": "whitespace", + "start": 301, + "end": 302, + "value": " " + }, + { + "type": "word", + "start": 302, + "end": 306, + "value": "line" + }, + { + "type": "brace", + "start": 306, + "end": 307, + "value": "(" + }, + { + "type": "brace", + "start": 307, + "end": 308, + "value": "[" + }, + { + "type": "number", + "start": 308, + "end": 309, + "value": "1" + }, + { + "type": "comma", + "start": 309, + "end": 310, + "value": "," + }, + { + "type": "whitespace", + "start": 310, + "end": 311, + "value": " " + }, + { + "type": "number", + "start": 311, + "end": 312, + "value": "0" + }, + { + "type": "brace", + "start": 312, + "end": 313, + "value": "]" + }, + { + "type": "comma", + "start": 313, + "end": 314, + "value": "," + }, + { + "type": "whitespace", + "start": 314, + "end": 315, + "value": " " + }, + { + "type": "operator", + "start": 315, + "end": 316, + "value": "%" + }, + { + "type": "brace", + "start": 316, + "end": 317, + "value": ")" + }, + { + "type": "whitespace", + "start": 317, + "end": 324, + "value": "\n " + }, + { + "type": "operator", + "start": 324, + "end": 326, + "value": "|>" + }, + { + "type": "whitespace", + "start": 326, + "end": 327, + "value": " " + }, + { + "type": "word", + "start": 327, + "end": 331, + "value": "line" + }, + { + "type": "brace", + "start": 331, + "end": 332, + "value": "(" + }, + { + "type": "brace", + "start": 332, + "end": 333, + "value": "[" + }, + { + "type": "number", + "start": 333, + "end": 334, + "value": "0" + }, + { + "type": "comma", + "start": 334, + "end": 335, + "value": "," + }, + { + "type": "whitespace", + "start": 335, + "end": 336, + "value": " " + }, + { + "type": "operator", + "start": 336, + "end": 337, + "value": "-" + }, + { + "type": "number", + "start": 337, + "end": 338, + "value": "1" + }, + { + "type": "brace", + "start": 338, + "end": 339, + "value": "]" + }, + { + "type": "comma", + "start": 339, + "end": 340, + "value": "," + }, + { + "type": "whitespace", + "start": 340, + "end": 341, + "value": " " + }, + { + "type": "operator", + "start": 341, + "end": 342, + "value": "%" + }, + { + "type": "brace", + "start": 342, + "end": 343, + "value": ")" + }, + { + "type": "whitespace", + "start": 343, + "end": 350, + "value": "\n " + }, + { + "type": "operator", + "start": 350, + "end": 352, + "value": "|>" + }, + { + "type": "whitespace", + "start": 352, + "end": 353, + "value": " " + }, + { + "type": "word", + "start": 353, + "end": 358, + "value": "close" + }, + { + "type": "brace", + "start": 358, + "end": 359, + "value": "(" + }, + { + "type": "operator", + "start": 359, + "end": 360, + "value": "%" + }, + { + "type": "brace", + "start": 360, + "end": 361, + "value": ")" + }, + { + "type": "whitespace", + "start": 361, + "end": 364, + "value": "\n " + }, + { + "type": "brace", + "start": 364, + "end": 365, + "value": "}" + }, + { + "type": "whitespace", + "start": 365, + "end": 366, + "value": "\n" + }, + { + "type": "brace", + "start": 366, + "end": 367, + "value": "}" + }, + { + "type": "whitespace", + "start": 367, + "end": 368, + "value": "\n" + }, + { + "type": "brace", + "start": 368, + "end": 369, + "value": "}" + }, + { + "type": "whitespace", + "start": 369, + "end": 371, + "value": "\n\n" + }, + { + "type": "word", + "start": 371, + "end": 372, + "value": "x" + }, + { + "type": "whitespace", + "start": 372, + "end": 373, + "value": " " + }, + { + "type": "operator", + "start": 373, + "end": 374, + "value": "=" + }, + { + "type": "whitespace", + "start": 374, + "end": 375, + "value": " " + }, + { + "type": "word", + "start": 375, + "end": 379, + "value": "test" + }, + { + "type": "brace", + "start": 379, + "end": 380, + "value": "(" + }, + { + "type": "brace", + "start": 380, + "end": 381, + "value": ")" + }, + { + "type": "whitespace", + "start": 381, + "end": 382, + "value": "\n" + }, + { + "type": "word", + "start": 382, + "end": 383, + "value": "x" + }, + { + "type": "whitespace", + "start": 383, + "end": 386, + "value": "\n " + }, + { + "type": "operator", + "start": 386, + "end": 388, + "value": "|>" + }, + { + "type": "whitespace", + "start": 388, + "end": 389, + "value": " " + }, + { + "type": "word", + "start": 389, + "end": 396, + "value": "extrude" + }, + { + "type": "brace", + "start": 396, + "end": 397, + "value": "(" + }, + { + "type": "operator", + "start": 397, + "end": 398, + "value": "-" + }, + { + "type": "number", + "start": 398, + "end": 400, + "value": "10" + }, + { + "type": "comma", + "start": 400, + "end": 401, + "value": "," + }, + { + "type": "whitespace", + "start": 401, + "end": 402, + "value": " " + }, + { + "type": "operator", + "start": 402, + "end": 403, + "value": "%" + }, + { + "type": "brace", + "start": 403, + "end": 404, + "value": ")" + }, + { + "type": "whitespace", + "start": 404, + "end": 406, + "value": "\n\n" + }, + { + "type": "word", + "start": 406, + "end": 408, + "value": "x2" + }, + { + "type": "whitespace", + "start": 408, + "end": 409, + "value": " " + }, + { + "type": "operator", + "start": 409, + "end": 410, + "value": "=" + }, + { + "type": "whitespace", + "start": 410, + "end": 411, + "value": " " + }, + { + "type": "word", + "start": 411, + "end": 416, + "value": "test2" + }, + { + "type": "brace", + "start": 416, + "end": 417, + "value": "(" + }, + { + "type": "brace", + "start": 417, + "end": 418, + "value": ")" + }, + { + "type": "whitespace", + "start": 418, + "end": 419, + "value": "\n" + }, + { + "type": "word", + "start": 419, + "end": 421, + "value": "x2" + }, + { + "type": "period", + "start": 421, + "end": 422, + "value": "." + }, + { + "type": "word", + "start": 422, + "end": 428, + "value": "thing1" + }, + { + "type": "period", + "start": 428, + "end": 429, + "value": "." + }, + { + "type": "word", + "start": 429, + "end": 435, + "value": "thing2" + }, + { + "type": "whitespace", + "start": 435, + "end": 438, + "value": "\n " + }, + { + "type": "operator", + "start": 438, + "end": 440, + "value": "|>" + }, + { + "type": "whitespace", + "start": 440, + "end": 441, + "value": " " + }, + { + "type": "word", + "start": 441, + "end": 448, + "value": "extrude" + }, + { + "type": "brace", + "start": 448, + "end": 449, + "value": "(" + }, + { + "type": "number", + "start": 449, + "end": 451, + "value": "10" + }, + { + "type": "comma", + "start": 451, + "end": 452, + "value": "," + }, + { + "type": "whitespace", + "start": 452, + "end": 453, + "value": " " + }, + { + "type": "operator", + "start": 453, + "end": 454, + "value": "%" + }, + { + "type": "brace", + "start": 454, + "end": 455, + "value": ")" + }, + { + "type": "whitespace", + "start": 455, + "end": 456, + "value": "\n" + } + ] +} diff --git a/src/wasm-lib/tests/executor/inputs/no_visuals/add_lots.kcl b/src/wasm-lib/tests/executor/inputs/no_visuals/add_lots.kcl deleted file mode 100644 index ae16939ccd..0000000000 --- a/src/wasm-lib/tests/executor/inputs/no_visuals/add_lots.kcl +++ /dev/null @@ -1,107 +0,0 @@ -fn f = (i) => { - return i * 2 -} - -let x = f(0) -+ f(1) -+ f(2) -+ f(3) -+ f(4) -+ f(5) -+ f(6) -+ f(7) -+ f(8) -+ f(9) -+ f(10) -+ f(11) -+ f(12) -+ f(13) -+ f(14) -+ f(15) -+ f(16) -+ f(17) -+ f(18) -+ f(19) -+ f(20) -+ f(21) -+ f(22) -+ f(23) -+ f(24) -+ f(25) -+ f(26) -+ f(27) -+ f(28) -+ f(29) -+ f(30) -+ f(31) -+ f(32) -+ f(33) -+ f(34) -+ f(35) -+ f(36) -+ f(37) -+ f(38) -+ f(39) -+ f(40) -+ f(41) -+ f(42) -+ f(43) -+ f(44) -+ f(45) -+ f(46) -+ f(47) -+ f(48) -+ f(49) -+ f(50) -+ f(51) -+ f(52) -+ f(53) -+ f(54) -+ f(55) -+ f(56) -+ f(57) -+ f(58) -+ f(59) -+ f(60) -+ f(61) -+ f(62) -+ f(63) -+ f(64) -+ f(65) -+ f(66) -+ f(67) -+ f(68) -+ f(69) -+ f(70) -+ f(71) -+ f(72) -+ f(73) -+ f(74) -+ f(75) -+ f(76) -+ f(77) -+ f(78) -+ f(79) -+ f(80) -+ f(81) -+ f(82) -+ f(83) -+ f(84) -+ f(85) -+ f(86) -+ f(87) -+ f(88) -+ f(89) -+ f(90) -+ f(91) -+ f(92) -+ f(93) -+ f(94) -+ f(95) -+ f(96) -+ f(97) -+ f(98) -+ f(99) -+ f(100) - -assertEqual(x, 10100, 0.1, "Big sum") diff --git a/src/wasm-lib/tests/executor/no_visuals.rs b/src/wasm-lib/tests/executor/no_visuals.rs index 034bc6032d..dd374a1350 100644 --- a/src/wasm-lib/tests/executor/no_visuals.rs +++ b/src/wasm-lib/tests/executor/no_visuals.rs @@ -5,16 +5,6 @@ use kcl_lib::{ parser, }; -macro_rules! gen_test { - ($file:ident) => { - #[tokio::test] - async fn $file() { - let code = include_str!(concat!("inputs/no_visuals/", stringify!($file), ".kcl")); - run(&code).await; - } - }; -} - macro_rules! gen_test_fail { ($file:ident, $expected:literal) => { #[tokio::test] @@ -37,27 +27,6 @@ macro_rules! gen_test_parse_fail { }; } -async fn run(code: &str) { - let (ctx, program, id_generator) = setup(code).await; - - let res = ctx - .run( - &program, - None, - id_generator, - Some("tests/executor/inputs/no_visuals/".to_owned()), - ) - .await; - match res { - Ok(state) => { - println!("{:#?}", state.memory); - } - Err(e) => { - panic!("{e}"); - } - } -} - async fn setup(program: &str) -> (ExecutorContext, Node, IdGenerator) { let tokens = kcl_lib::token::lexer(program).unwrap(); let parser = kcl_lib::parser::Parser::new(tokens); @@ -97,11 +66,6 @@ async fn run_parse_fail(code: &str) -> KclError { e } -gen_test!(property_of_object); -gen_test!(index_of_array); -gen_test!(comparisons); -gen_test!(array_range_expr); -gen_test!(array_range_negative_expr); gen_test_fail!( invalid_index_str, "semantic: Only integers >= 0 can be used as the index of an array, but you're using a string" @@ -138,14 +102,11 @@ gen_test_fail!( pipe_substitution_inside_function_called_from_pipeline, "semantic: cannot use % outside a pipe expression" ); -gen_test!(sketch_in_object); -gen_test!(if_else); // gen_test_fail!( // if_else_no_expr, // "syntax: blocks inside an if/else expression must end in an expression" // ); gen_test_fail!(comparisons_multiple, "syntax: Invalid number: true"); -gen_test!(import_simple); gen_test_fail!( import_cycle1, "import cycle: circular import of modules is not allowed: tests/executor/inputs/no_visuals/import_cycle2.kcl -> tests/executor/inputs/no_visuals/import_cycle3.kcl -> tests/executor/inputs/no_visuals/import_cycle1.kcl -> tests/executor/inputs/no_visuals/import_cycle2.kcl" @@ -171,8 +132,6 @@ gen_test_parse_fail!( // import_in_function, // "syntax: Can import only import at the top level" // ); -gen_test!(add_lots); -gen_test!(array_elem_push); gen_test_fail!( array_elem_push_fail, "undefined value: The array doesn't have any item at index 3"