mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 21:14:28 -08:00
finishing record io
This commit is contained in:
24
test/test.js
24
test/test.js
@@ -3050,15 +3050,18 @@ const y = x()`
|
||||
|
||||
const next = COMMANDS.input(initial, `const x = Math.random()*2`, 0).state
|
||||
assert_equal(next.value_explorer.result.value, 2)
|
||||
assert_equal(next.eval_cxt.io_cache_index, 1)
|
||||
|
||||
// Patch Math.random to return 2. Now the first call to Math.random() is
|
||||
// cached with value 1, and the second shoud return 2
|
||||
// Patch Math.random to return 2.
|
||||
// TODO The first call to Math.random() is cached with value 1, and the
|
||||
// second shoud return 2
|
||||
Object.assign(globalThis.run_window.Math, {random: () => 2})
|
||||
const replay_failed = COMMANDS.input(
|
||||
initial,
|
||||
`const x = Math.random() + Math.random()`,
|
||||
0
|
||||
).state
|
||||
|
||||
// TODO must reuse first cached call?
|
||||
assert_equal(replay_failed.value_explorer.result.value, 4)
|
||||
|
||||
@@ -3211,4 +3214,21 @@ const y = x()`
|
||||
false
|
||||
)
|
||||
}),
|
||||
|
||||
test('record io no io cache on deferred calls', async () => {
|
||||
const code = `
|
||||
const x = Math.random
|
||||
export const fn = () => x()
|
||||
`
|
||||
|
||||
const {state: i, on_deferred_call} = test_deferred_calls_state(code)
|
||||
|
||||
// Make deferred call
|
||||
i.modules[''].fn()
|
||||
|
||||
const state = on_deferred_call(i)
|
||||
|
||||
// Deferred calls should not be record in cache
|
||||
assert_equal(state.eval_cxt.io_cache.length, 0)
|
||||
}),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user