simple test

const xRel001 = -20
const xRel002 = xRel001-50
This commit is contained in:
max-mrgrsk
2024-05-22 21:18:55 +02:00
parent 502cb08a10
commit 78046eceb6

View File

@ -1,6 +1,7 @@
import { parse, recast, initPromise } from './wasm'
import {
findAllPreviousVariables,
findUnusedVariables,
isNodeSafeToReplace,
isTypeInValue,
getNodePathFromSourceRange,
@ -60,6 +61,22 @@ const variableBelowShouldNotBeIncluded = 3
})
})
describe('findUnusedVariables', () => {
it('should find unused vairiables', () => {
// example code
const code = `
const xRel001 = -20
const xRel002 = xRel001-50
`
// parse into ast
const ast = parse(code)
// find unused variables
const unusedVariables = findUnusedVariables(ast)
// check wether unused variables match the expected result
expect(unusedVariables.map((node) => node.id.name)).toEqual(['xRel002'])
})
})
describe('testing argIsNotIdentifier', () => {
const code = `const part001 = startSketchOn('XY')
|> startProfileAt([-1.2, 4.83], %)