mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 13:04:30 -08:00
refactor test_initial_state
This commit is contained in:
@@ -70,12 +70,19 @@ console.time('run')
|
||||
const i = test_initial_state(
|
||||
{}, // files
|
||||
undefined,
|
||||
{project_dir: dir},
|
||||
{entrypoint: 'test/run.js'},
|
||||
{
|
||||
project_dir: dir,
|
||||
entrypoint: 'test/run.js',
|
||||
}
|
||||
)
|
||||
|
||||
if(!i.parse_result.ok) {
|
||||
console.error('Parse errors:', i.parse_result.problems)
|
||||
i.parse_result.problems.forEach(p => {
|
||||
if(p.index != null) {
|
||||
console.error(p.module + ': ' + p.message + ' at ' + i.files[p.module].slice(p.index, p.index + 80))
|
||||
}
|
||||
})
|
||||
throw new Error('parse error')
|
||||
}
|
||||
|
||||
|
||||
@@ -3320,9 +3320,7 @@ const y = x()`
|
||||
'x' : `export const x = () => 1; x()`,
|
||||
},
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
entrypoint: '',
|
||||
current_module: 'x',
|
||||
}
|
||||
)
|
||||
|
||||
@@ -98,20 +98,27 @@ export const assert_code_error_async = async (codestring, error) => {
|
||||
assert_equal(result.error, error)
|
||||
}
|
||||
|
||||
export const test_initial_state = (code, cursor_pos, other, entrypoint_settings) => {
|
||||
export const test_initial_state = (code, cursor_pos, options = {}) => {
|
||||
if(cursor_pos < 0) {
|
||||
throw new Error('illegal cursor_pos')
|
||||
}
|
||||
const {
|
||||
//entrypoint = '',
|
||||
current_module,
|
||||
project_dir,
|
||||
on_deferred_call,
|
||||
} = options
|
||||
const entrypoint = options.entrypoint ?? ''
|
||||
return COMMANDS.open_app_window(
|
||||
COMMANDS.get_initial_state(
|
||||
{
|
||||
files: typeof(code) == 'object' ? code : { '' : code},
|
||||
...other
|
||||
project_dir,
|
||||
on_deferred_call,
|
||||
},
|
||||
{
|
||||
entrypoint: '',
|
||||
current_module: '',
|
||||
...entrypoint_settings,
|
||||
entrypoint,
|
||||
current_module: current_module ?? '',
|
||||
},
|
||||
cursor_pos
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user