|
1 | 1 | import runners, { type RunnerTypes } from '../sourceRunner' |
2 | 2 | import { Chapter, type ExecutionMethod, Variant } from '../../types' |
3 | 3 | import type { Runner } from '../types' |
4 | | -import { DEFAULT_SOURCE_OPTIONS, runCodeInSource } from '..' |
| 4 | +import { runCodeInSource } from '..' |
5 | 5 | import { mockContext } from '../../utils/testing/mocks' |
6 | 6 | import { getChapterName, objectKeys, objectValues } from '../../utils/misc' |
7 | 7 | import { asMockedFunc } from '../../utils/testing/misc' |
@@ -90,7 +90,7 @@ const sourceCases: FullTestCase[] = [ |
90 | 90 | { |
91 | 91 | contextMethod: 'native', |
92 | 92 | variant: Variant.NATIVE, |
93 | | - expectedRunner: 'native', |
| 93 | + expectedRunner: 'fulljs', |
94 | 94 | expectedPrelude: false |
95 | 95 | } |
96 | 96 | ] |
@@ -155,11 +155,12 @@ async function testCase({ |
155 | 155 | // Check if the prelude is null before execution |
156 | 156 | // because the prelude gets set to null if it wasn't before |
157 | 157 | const shouldPrelude = expectedPrelude && context.prelude !== null |
158 | | - const options = { ...DEFAULT_SOURCE_OPTIONS } |
159 | | - |
160 | | - if (optionMethod !== undefined) { |
161 | | - options.executionMethod = optionMethod |
162 | | - } |
| 158 | + const options = |
| 159 | + optionMethod === undefined |
| 160 | + ? undefined |
| 161 | + : { |
| 162 | + executionMethod: optionMethod |
| 163 | + } |
163 | 164 |
|
164 | 165 | await runCodeInSource(code, context, options) |
165 | 166 |
|
@@ -287,6 +288,15 @@ describe('Ensure that the correct runner is used for the given evaluation contex |
287 | 288 | expectedRunner: 'native' |
288 | 289 | })) |
289 | 290 |
|
| 291 | + // testCases('runner correctly respects optionMethod', objectKeys(runners).map(runner => ({ |
| 292 | + // code: '"enable verbose"; 0;', |
| 293 | + // optionMethod: runner, |
| 294 | + // chapter: Chapter.SOURCE_4, |
| 295 | + // variant: Variant.DEFAULT, |
| 296 | + // expectedPrelude: true, |
| 297 | + // expectedRunner: runner |
| 298 | + // }))) |
| 299 | + |
290 | 300 | test('if optionMethod is specified, debubger statements are ignored', () => |
291 | 301 | testCase({ |
292 | 302 | code: 'debugger; 0;', |
|
0 commit comments