move TTC capture to unit test (#7268)
* move TTC capture to unit test * progress with artifact * fmt * abstract cases * add another case * add another test * update snapshots with proper file names * force to JSON * fmt * make jest happy * add another example and other tweaks * fix * tweak * add logs * more logs * strip out kcl version * remove logs * add comment explainer * more comments * more comment * remove package-lock line
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import type { Binary as BSONBinary } from 'bson'
|
||||
import { v4 } from 'uuid'
|
||||
import type { AnyMachineSnapshot } from 'xstate'
|
||||
import type { CallExpressionKw, SourceRange } from '@src/lang/wasm'
|
||||
import type { CallExpressionKw, ExecState, SourceRange } from '@src/lang/wasm'
|
||||
import { isDesktop } from '@src/lib/isDesktop'
|
||||
import type { AsyncFn } from '@src/lib/types'
|
||||
|
||||
@ -522,6 +522,20 @@ export function getModuleId(sourceRange: SourceRange) {
|
||||
return sourceRange[2]
|
||||
}
|
||||
|
||||
export function getModuleIdByFileName(
|
||||
fileName: string,
|
||||
fileNames: ExecState['filenames']
|
||||
) {
|
||||
const module = Object.entries(fileNames).find(
|
||||
([, moduleInfo]) =>
|
||||
moduleInfo?.type === 'Local' && moduleInfo.value === fileName
|
||||
)
|
||||
if (module) {
|
||||
return Number(module[0]) // Return the module ID
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
export function getInVariableCase(name: string, prefixIfDigit = 'm') {
|
||||
// As of 2025-04-08, standard case for KCL variables is camelCase
|
||||
const startsWithANumber = !Number.isNaN(Number(name.charAt(0)))
|
||||
|
Reference in New Issue
Block a user