()
| 272 | } |
| 273 | |
| 274 | const onAceChange = () => { |
| 275 | const code = inputAce.getValue() |
| 276 | const newBlocklyState = this.runCodeToBlocks({ testCase, code, codeLanguage: testCase.codeLanguage, errorDiv, prepData, prepDataError }) |
| 277 | if (!newBlocklyState) { return } |
| 278 | const cachedBlocklyTest = storage.load(`blockly-test-from-code_${testCase.key}_${hashString(code)}`) |
| 279 | if (!testBlockly.loaded && |
| 280 | !testCase.focused && |
| 281 | cachedBlocklyTest?.state && |
| 282 | (blocklyUtils.isEqualBlocklyState(newBlocklyState, cachedBlocklyTest?.state) || |
| 283 | blocklyUtils.isEqualBlocklyState(newBlocklyState, cachedBlocklyTest?.inputState))) { |
| 284 | console.log('Skipping Blockly instantiation for cached Blockly test', testCase.name, 'with status', cachedBlocklyTest.status, 'and reason', cachedBlocklyTest.reason) |
| 285 | testCase.status = cachedBlocklyTest.status |
| 286 | testCase.reason = cachedBlocklyTest.reason |
| 287 | if (cachedBlocklyTest.outputCode) { |
| 288 | testCase.outputCode = cachedBlocklyTest.outputCode |
| 289 | outputAce.setValue(cachedBlocklyTest.outputCode) |
| 290 | outputAce.clearSelection() |
| 291 | } |
| 292 | return |
| 293 | } else { |
| 294 | console.log('Must instantiate Blockly', testCase.name, 'with new state', newBlocklyState, 'because cached is', cachedBlocklyTest?.state, cachedBlocklyTest?.inputState, 'and loaded is', testBlockly.loaded, 'and focused is', testCase.focused) |
| 295 | } |
| 296 | if (!testBlockly.loaded) { |
| 297 | testBlockly.load() |
| 298 | } |
| 299 | // Input ace -> Blockly |
| 300 | testCase.inputBlocklyState = newBlocklyState |
| 301 | blocklyUtils.loadBlocklyState({ blocklyState: newBlocklyState, blockly: testBlockly.workspace }) |
| 302 | } |
| 303 | inputAce.getSession().getDocument().on('change', onAceChange) |
| 304 | onAceChange() |
| 305 | if (testCase.status) { |
nothing calls this directly
no test coverage detected