Repository: source-academy/js-slang
Pull request #517 (2020-04-10 05:10:07)

Make Source 1 and 2 Lazy accessible with Variant
Previously, in #461 lazy evaluation was added, but it had used a new property in Context known as EvaluationMethod to determine whether the lazy evaluator or eager evaluator should be used.

In #478 it was decided that a Variant property should be used instead, to standardise the implementations for various modes of evaluation like non-deterministic Source 3.

This change is to update the lazy evaluation paths to make use of Variant as well, and to remove the now-unnecesaary EvaluationMethod property.

coveralls: ## Pull Request Test Coverage Report for [Build 2766](https://coveralls.io/builds/29986812)

* **13** of **13**   **(100.0%)**  changed or added relevant lines in **3** files are covered.
* No unchanged relevant lines lost coverage.
* Overall coverage increased (+**0.007%**) to **89.103%**

---



|  Totals | [![Coverage Status](https://coveralls.io/builds/29986812/badge)](https://coveralls.io/builds/29986812) |
| :-- | --: |
| Change from base [Build 2757](https://coveralls.io/builds/29932437): |  0.007% |
| Covered Lines: | 4366 |
| Relevant Lines: | 4740 |

---
##### 💛  - [Coveralls](https://coveralls.io)


Patch:
diff --git a/src/createContext.ts b/src/createContext.ts
index c6ebf0cf..32142aca 100644
--- a/src/createContext.ts
+++ b/src/createContext.ts
@@ -64,7 +64,6 @@ export const createEmptyContext = <T>(
     debugger: createEmptyDebugger(),
     contextId: length - 1,
     executionMethod: 'auto',
-    evaluationMethod: 'strict',
     variant
   }
 }
diff --git a/src/index.ts b/src/index.ts
index e7fe441c..f7d85ec9 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -22,12 +22,12 @@ import { transpile } from './transpiler/transpiler'
 import {
   Context,
   Error as ResultError,
-  EvaluationMethod,
   ExecutionMethod,
   Finished,
   Result,
   Scheduler,
-  SourceError
+  SourceError,
+  Variant
 } from './types'
 import { nonDetEvaluate } from './interpreter/interpreter-non-det'
 import { locationDummyNode } from './utils/astCreator'
@@ -41,7 +41,7 @@ export interface IOptions {
   scheduler: 'preemptive' | 'async'
   steps: number
   executionMethod: ExecutionMethod
-  evaluationMethod: EvaluationMethod
+  variant: Variant
   originalMaxExecTime: number
   useSubst: boolean
 }
@@ -50,7 +50,7 @@ const DEFAULT_OPTIONS: IOptions = {
   scheduler: 'async',
   steps: 1000,
   executionMethod: 'auto',
-  evaluationMethod: 'strict',
+  variant: 'default',
   originalMaxExecTime: 1000,
   useSubst: false
 }
@@ -243,7 +243,7 @@ export async function runInContext(
     return undefined
   }
   const theOptions: IOptions = { ...DEFAULT_OPTIONS, ...options }
-  context.evaluationMethod = theOptions.evaluationMethod
+  context.variant = determineVariant(context, options)
   context.errors = []
 
   verboseErrors = getFirstLine(code) === 'enable verbose'
@@ -301,7 +301,7 @@ export async function runInContext(
     let sourceMapJson: RawSourceMap | undefined
     let lastStatementSourceMapJson: RawSourceMap | undefined
     try {
-      const temp = transpile(program, context.contextId, false, context.evaluationMethod)
+      const temp = transpile(program, context.contextId, false, context.variant)
       // some issues with formatting and semicolons and tslint so no destructure
       transpiled = temp.transpiled
       sourceMapJson = temp.codeMap
@@ -364,6 +364,26 @@ export async function runInContext(
   }
 }
 
+/**
+ * Small function to determine the variant to be used
+ * by a program, as both context and options can have
+ * a variant. The variant provided in options will
+ * have precedence over the variant provided in context.
+ *
+ * @param context The context of the program.
+ * @param options Options to be used when
+ *                running the program.
+ *
+ * @returns The variant that the program is to be run in
+ */
+function determineVariant(context: Context, options: Partial<IOptions>): Variant {
+  if (options.variant) {
+    return options.variant
+  } else {
+    return context.variant
+  }
+}
+
 export function resume(result: Result): Finished | ResultError | Promise<Result> {
   if (result.status === 'finished' || result.status === 'error') {
     return result
diff --git a/src/interpreter/interpreter.ts b/src/interpreter/interpreter.ts
index b47db295..2cd17bfc 100644
--- a/src/interpreter/interpreter.ts
+++ b/src/interpreter/interpreter.ts
@@ -232,7 +232,7 @@ const checkNumberOfArguments = (
 function* getArgs(context: Context, call: es.CallExpression) {
   const args = []
   for (const arg of call.arguments) {
-    if (context.evaluationMethod !== 'lazy') {
+    if (context.variant !== 'lazy') {
       args.push(yield* actualValue(arg, context))
     } else {
       args.push(delayIt(arg, currentEnvironment(context)))
@@ -549,7 +549,7 @@ export const evaluators: { [nodeType: string]: Evaluator<es.Node> } = {
     }
 
     // If we are now left with a CallExpression, then we use TCO
-    if (returnExpression.type === 'CallExpression' && context.evaluationMethod === 'strict') {
+    if (returnExpression.type === 'CallExpression' && context.variant !== 'lazy') {
       const callee = yield* actualValue(returnExpression.callee, context)
       const args = yield* getArgs(context, returnExpression)
       return new TailCallReturnValue(callee, args, returnExpression)
diff --git a/src/repl/repl.ts b/src/repl/repl.ts
index 1bc43e9e..df041418 100644
--- a/src/repl/repl.ts
+++ b/src/repl/repl.ts
@@ -2,13 +2,13 @@
 import { start } from 'repl' // 'repl' here refers to the module named 'repl' in index.d.ts
 import { inspect } from 'util'
 import { createContext, IOptions, parseError, runInContext } from '../index'
-import { EvaluationMethod, ExecutionMethod } from '../types'
+import { Variant, ExecutionMethod } from '../types'
 import Closure from '../interpreter/closure'
 
 function startRepl(
   chapter = 1,
   executionMethod: ExecutionMethod = 'interpreter',
-  evaluationMethod: EvaluationMethod = 'strict',
+  variant: Variant = 'default',
   useSubst: boolean = false,
   useRepl: boolean,
   prelude = ''
@@ -18,7 +18,7 @@ function startRepl(
   const options: Partial<IOptions> = {
     scheduler: 'preemptive',
     executionMethod,
-    evaluationMethod,
+    variant,
     useSubst
   }
   runInContext(prelude, context, options).then(preludeResult => {
@@ -72,12 +72,12 @@ function main() {
     .parseSystem()
 
   const executionMethod = opt.options.native === true ? 'native' : 'interpreter'
-  const evaluationMethod = opt.options.lazy === true ? 'lazy' : 'strict'
+  const variant = opt.options.lazy === true ? 'lazy' : 'default'
   const chapter = parseInt(opt.options.chapter, 10)
   const useSubst = opt.options.s
   const useRepl = !opt.options.e
   const prelude = opt.argv[0] ?? ''
-  startRepl(chapter, executionMethod, evaluationMethod, useSubst, useRepl, prelude)
+  startRepl(chapter, executionMethod, variant, useSubst, useRepl, prelude)
 }
 
 main()
diff --git a/src/transpiler/transpiler.ts b/src/transpiler/transpiler.ts
index d0a1c490..b469f5d6 100644
--- a/src/transpiler/transpiler.ts
+++ b/src/transpiler/transpiler.ts
@@ -3,7 +3,7 @@ import { generate } from 'astring'
 import * as es from 'estree'
 import { RawSourceMap, SourceMapGenerator } from 'source-map'
 import { GLOBAL, GLOBAL_KEY_TO_ACCESS_NATIVE_STORAGE } from '../constants'
-import { AllowedDeclarations, EvaluationMethod, Value } from '../types'
+import { AllowedDeclarations, Variant, Value } from '../types'
 import { ConstAssignment, UndefinedVariable } from '../errors/errors'
 import * as create from '../utils/astCreator'
 
@@ -211,10 +211,7 @@ function wrapArrowFunctionsToAllowNormalCallsAndNiceToString(
  *
  * conditional and logical expressions will be recursively looped through as well
  */
-function transformReturnStatementsToAllowProperTailCalls(
-  program: es.Program,
-  evaluationMethod: EvaluationMethod
-) {
+function transformReturnStatementsToAllowProperTailCalls(program: es.Program, variant: Variant) {
   function transformLogicalExpression(expression: es.Expression): es.Expression {
     switch (expression.type) {
       case 'LogicalExpression':
@@ -236,9 +233,9 @@ function transformReturnStatementsToAllowProperTailCalls(
         const { line, column } = expression.loc!.start
         const functionName =
           expression.callee.type === 'Identifier' ? expression.callee.name : '<anonymous>'
-        const args = evaluationMethod === 'strict' ? expression.arguments : ([] as es.Expression[])
+        const args = variant !== 'lazy' ? expression.arguments : ([] as es.Expression[])
 
-        if (evaluationMethod === 'lazy') {
+        if (variant === 'lazy') {
           for (const arg of expression.arguments) {
             args.push(delayIt(arg as es.Expression))
           }
@@ -288,16 +285,13 @@ function delayIt(expr: es.Expression) {
   return obj
 }
 
-function transformCallExpressionsToCheckIfFunction(
-  program: es.Program,
-  evaluationMethod: EvaluationMethod
-) {
+function transformCallExpressionsToCheckIfFunction(program: es.Program, variant: Variant) {
   simple(program, {
     CallExpression(node: es.CallExpression) {
       const { line, column } = node.loc!.start
-      const args = evaluationMethod === 'strict' ? node.arguments : ([] as es.Expression[])
+      const args = variant !== 'lazy' ? node.arguments : ([] as es.Expression[])
 
-      if (evaluationMethod === 'lazy') {
+      if (variant === 'lazy') {
         for (const arg of node.arguments) {
           args.push(delayIt(arg as es.Expression))
         }
@@ -675,7 +669,7 @@ export function transpile(
   program: es.Program,
   id: number,
   skipUndefinedVariableErrors = false,
-  evaluationMethod: EvaluationMethod = 'strict'
+  variant: Variant = 'default'
 ) {
   contextId = id
   refreshLatestIdentifiers(program)
@@ -687,8 +681,8 @@ export function transpile(
     return { transpiled: '' }
   }
   const functionsToStringMap = generateFunctionsToStringMap(program)
-  transformReturnStatementsToAllowProperTailCalls(program, evaluationMethod)
-  transformCallExpressionsToCheckIfFunction(program, evaluationMethod)
+  transformReturnStatementsToAllowProperTailCalls(program, variant)
+  transformCallExpressionsToCheckIfFunction(program, variant)
   transformUnaryAndBinaryOperationsToFunctionCalls(program)
   transformSomeExpressionsToCheckIfBoolean(program)
   transformPropertyAssignment(program)
diff --git a/src/types.ts b/src/types.ts
index 2a9a7273..ad55a06f 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -57,7 +57,6 @@ export interface Comment {
 }
 
 export type ExecutionMethod = 'native' | 'interpreter' | 'auto'
-export type EvaluationMethod = 'strict' | 'lazy'
 export type Variant = 'lazy' | 'non-det' | 'concurrent' | 'default' // this might replace EvaluationMethod
 
 export interface Context<T = any> {
@@ -110,13 +109,11 @@ export interface Context<T = any> {
    */
   executionMethod: ExecutionMethod
 
-  evaluationMethod: EvaluationMethod
-
   /**
    * Describes the strategy / paradigm to be used for evaluation
    * Examples: lazy, concurrent or non-deterministic
    */
-  variant: Variant // This will replace evaluationMethod
+  variant: Variant
 }
 
 export interface BlockFrame {
diff --git a/src/utils/operators.ts b/src/utils/operators.ts
index 792a8ac5..69dbf694 100644
--- a/src/utils/operators.ts
+++ b/src/utils/operators.ts
@@ -23,8 +23,6 @@ export function throwIfTimeout(start: number, current: number, line: number, col
 
 export function forceIt(val: any): any {
   if (val !== undefined && val !== null && val.isThunk === true) {
-    require('util').inspect.defaultOptions.depth = null
-
     if (val.isMemoized) {
       return val.memoizedValue
     }


Test patch:
diff --git a/src/__tests__/__snapshots__/environment.ts.snap b/src/__tests__/__snapshots__/environment.ts.snap
index 306f0f60..bb54009a 100644
--- a/src/__tests__/__snapshots__/environment.ts.snap
+++ b/src/__tests__/__snapshots__/environment.ts.snap
@@ -145,7 +145,6 @@ Array [
           "status": false,
         },
         "errors": Array [],
-        "evaluationMethod": "strict",
         "executionMethod": "auto",
         "externalContext": undefined,
         "externalSymbols": Array [],
@@ -627,7 +626,6 @@ Array [
         "status": false,
       },
       "errors": Array [],
-      "evaluationMethod": "strict",
       "executionMethod": "auto",
       "externalContext": undefined,
       "externalSymbols": Array [],
diff --git a/src/__tests__/__snapshots__/inspect.ts.snap b/src/__tests__/__snapshots__/inspect.ts.snap
index 89730c29..2050ce28 100644
--- a/src/__tests__/__snapshots__/inspect.ts.snap
+++ b/src/__tests__/__snapshots__/inspect.ts.snap
@@ -18,7 +18,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -1899,7 +1898,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -3401,7 +3399,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -3881,7 +3878,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -4242,7 +4238,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -5339,7 +5334,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -6201,7 +6195,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -8157,7 +8150,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -22989,7 +22981,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -24517,7 +24508,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -26045,7 +26035,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -27573,7 +27562,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -29101,7 +29089,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -29460,7 +29447,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -30172,7 +30158,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -31099,7 +31084,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -31460,7 +31444,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -32105,7 +32088,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -33262,7 +33244,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -34419,7 +34400,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -35576,7 +35556,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -36750,7 +36729,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -37111,7 +37089,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -38284,7 +38261,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -39457,7 +39433,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -39818,7 +39793,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -40960,7 +40934,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -42232,7 +42205,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -43374,7 +43346,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
@@ -44646,7 +44617,6 @@ Object {
       "status": false,
     },
     "errors": Array [],
-    "evaluationMethod": "strict",
     "executionMethod": "interpreter",
     "externalContext": undefined,
     "externalSymbols": Array [],
diff --git a/src/__tests__/lazy.ts b/src/__tests__/lazy.ts
index 80c08338..3b02bc71 100644
--- a/src/__tests__/lazy.ts
+++ b/src/__tests__/lazy.ts
@@ -2,7 +2,7 @@ import { expectResult } from '../utils/testing'
 
 test('Unused arguments are not evaluated', () => {
   return expectResult('function test(a, b) { return a === 1 ? a : b; } test(1, head(null));', {
-    evaluationMethod: 'lazy',
+    variant: 'lazy',
     chapter: 2,
     native: true
   }).toBe(1)
@@ -10,7 +10,7 @@ test('Unused arguments are not evaluated', () => {
 
 test('Unary operations force argument', () => {
   return expectResult('function neg(b) { return !b; } neg(((x) => x)(false)); ', {
-    evaluationMethod: 'lazy',
+    variant: 'lazy',
     native: true
   }).toBe(true)
 })
@@ -18,7 +18,7 @@ test('Unary operations force argument', () => {
 test('Binary operations force arguments', () => {
   return expectResult(
     'function add(x, y) { return x + y; } add(((x) => x)(5), ((x) => x + 1)(9)); ',
-    { evaluationMethod: 'lazy', native: true }
+    { variant: 'lazy', native: true }
   ).toBe(15)
 })
 
@@ -31,7 +31,7 @@ function f(a, b) {
 
 f(((b) => b)(true), ((b) => !b)(true));
 `,
-    { evaluationMethod: 'lazy', chapter: 2, native: true }
+    { variant: 'lazy', chapter: 2, native: true }
   ).toBe(true)
 })
 
@@ -50,7 +50,7 @@ function square(n) {
 }
 
 square(incX());`,
-    { evaluationMethod: 'lazy', chapter: 3, native: true }
+    { variant: 'lazy', chapter: 3, native: true }
   ).toBe(4)
 })
 
@@ -66,7 +66,7 @@ const addSome2 = addSome(2);
 
 addSome2(3);
 `,
-    { evaluationMethod: 'lazy', native: true }
+    { variant: 'lazy', native: true }
   ).toBe(6)
 })
 
@@ -79,6 +79,6 @@ function test2(a) { return test(a, head(null)); }
 
 test2(1);
 `,
-    { evaluationMethod: 'lazy', chapter: 2, native: true }
+    { variant: 'lazy', chapter: 2, native: true }
   ).toBe(1)
 })
diff --git a/src/utils/testing.ts b/src/utils/testing.ts
index f9078ea1..a395ca69 100644
--- a/src/utils/testing.ts
+++ b/src/utils/testing.ts
@@ -3,7 +3,7 @@ import { parseError, Result, runInContext } from '../index'
 import { mockContext } from '../mocks/context'
 import { parse } from '../parser/parser'
 import { transpile } from '../transpiler/transpiler'
-import { Context, CustomBuiltIns, EvaluationMethod, SourceError, Value, Variant } from '../types'
+import { Context, CustomBuiltIns, Variant, SourceError, Value } from '../types'
 import { stringify } from './stringify'
 
 export interface TestContext extends Context {
@@ -34,7 +34,6 @@ interface TestOptions {
   variant?: Variant
   testBuiltins?: TestBuiltins
   native?: boolean
-  evaluationMethod?: EvaluationMethod
 }
 
 export function createTestContext({
@@ -98,7 +97,7 @@ async function testInContext(code: string, options: TestOptions): Promise<TestRe
     await runInContext(code, interpretedTestContext, {
       scheduler,
       executionMethod: 'interpreter',
-      evaluationMethod: options.evaluationMethod === undefined ? 'strict' : options.evaluationMethod
+      variant: options.variant
     })
   )
   if (options.native) {
@@ -106,12 +105,7 @@ async function testInContext(code: string, options: TestOptions): Promise<TestRe
     let transpiled: string
     try {
       const parsed = parse(code, nativeTestContext)!
-      transpiled = transpile(
-        parsed,
-        nativeTestContext.contextId,
-        true,
-        options.evaluationMethod === undefined ? 'strict' : options.evaluationMethod
-      ).transpiled
+      transpiled = transpile(parsed, nativeTestContext.contextId, true, options.variant).transpiled
       // replace native[<number>] as they may be inconsistent
       const replacedNative = transpiled.replace(/native\[\d+]/g, 'native')
       // replace the line hiding globals as they may differ between environments
@@ -131,8 +125,7 @@ async function testInContext(code: string, options: TestOptions): Promise<TestRe
       await runInContext(code, nativeTestContext, {
         scheduler,
         executionMethod: 'native',
-        evaluationMethod:
-          options.evaluationMethod === undefined ? 'strict' : options.evaluationMethod
+        variant: options.variant
       })
     )
     const propertiesThatShouldBeEqual = [