simple test
const xRel001 = -20 const xRel002 = xRel001-50
This commit is contained in:
@ -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], %)
|
||||
|
||||
Reference in New Issue
Block a user