diff --git a/README.md b/README.md index 14c421ab44..05d1560f0b 100644 --- a/README.md +++ b/README.md @@ -32,17 +32,13 @@ Please note that doing this will disable the test suite, so you will need to run cd scripts\ bash test.sh -## For Testing of js-slang +## js-slang -### Alpha version - -Use branch js-slang-alpha-preview to see the new changes (native and verbose errors). - -Have `"enable verbose";` as the first line of your program to activate verbose messages. +Currently using a version of js-slang with native and verbose errors. Edit https://github.com/source-academy/cadet-frontend/blob/57ba44f6b55c214d0f20339cd45bece57f24f48c/src/sagas/index.ts#L260 -to toggle native. +to toggle native (default is native enabled). ### To run local copy of js-slang diff --git a/package.json b/package.json index 2b9c80ce70..42f50b1392 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "draft-js": "^0.10.5", "flexboxgrid": "^6.3.1", "flexboxgrid-helpers": "^1.1.3", - "js-slang": "0.2.0", + "js-slang": "0.2.1-alpha.4", "lodash": "^4.17.11", "lz-string": "^1.4.4", "moment": "^2.22.2", diff --git a/src/mocks/context.ts b/src/mocks/context.ts index f8047551bf..6ae96da29c 100644 --- a/src/mocks/context.ts +++ b/src/mocks/context.ts @@ -2,7 +2,7 @@ import { parse } from 'acorn'; import { FunctionExpression } from 'estree'; import Closure from 'js-slang/dist/closure'; import createContext from 'js-slang/dist/createContext'; -import { Context, Frame } from 'js-slang/dist/types'; +import { Context, Environment } from 'js-slang/dist/types'; import { TypeError } from 'js-slang/dist/utils/rttc'; export function mockContext(chapter = 1): Context { @@ -13,7 +13,7 @@ export function mockRuntimeContext(): Context { const context = createContext(); context.runtime = { isRunning: true, - frames: [], + environments: [], nodes: [ { type: 'Literal', @@ -31,7 +31,7 @@ export function mockRuntimeContext(): Context { } export function mockClosure(): Closure { - return new Closure({} as FunctionExpression, {} as Frame, {} as Context); + return new Closure({} as FunctionExpression, {} as Environment, {} as Context); } export function mockTypeError(): TypeError { diff --git a/src/sagas/index.ts b/src/sagas/index.ts index 779321f5b1..d595479c89 100644 --- a/src/sagas/index.ts +++ b/src/sagas/index.ts @@ -257,7 +257,7 @@ function* playgroundSaga(): SagaIterator { function* evalCode(code: string, context: Context, location: WorkspaceLocation) { const { result, interrupted } = yield race({ - result: call(runInContext, code, context, { scheduler: 'preemptive' }), + result: call(runInContext, code, context, { scheduler: 'preemptive', isNativeRunnable: true }), /** * A BEGIN_INTERRUPT_EXECUTION signals the beginning of an interruption, * i.e the trigger for the interpreter to interrupt execution. diff --git a/yarn.lock b/yarn.lock index 4d4a1315ec..77c25324cd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5227,9 +5227,10 @@ js-base64@^2.1.9: version "2.4.3" resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.4.3.tgz#2e545ec2b0f2957f41356510205214e98fad6582" -js-slang@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/js-slang/-/js-slang-0.2.0.tgz#15b998d2e67bc2834421235f96408b4015bb322c" +js-slang@0.2.1-alpha.3: + version "0.2.1-alpha.3" + resolved "https://registry.yarnpkg.com/js-slang/-/js-slang-0.2.1-alpha.3.tgz#8e93828c67e0eb729ce229f66cadc5e081730541" + integrity sha512-iLEhlsrW1kbZ1OZ0rlVrhrFSsAacLAjqSqLuMqO+bAbdbZq2xc1wtQk+/xrj1hnRFRJhPqZH5qQetQm8vkQqFg== dependencies: "@types/estree" "0.0.39" acorn "^6.0.5" @@ -5238,6 +5239,7 @@ js-slang@0.2.0: commander "^2.19.0" common-tags "^1.8.0" invariant "^2.2.4" + source-map "^0.7.3" js-tokens@^3.0.0, js-tokens@^3.0.2: version "3.0.2" @@ -8998,6 +9000,11 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" +source-map@^0.7.3: + version "0.7.3" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" + integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== + spdx-correct@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.0.0.tgz#05a5b4d7153a195bc92c3c425b69f3b2a9524c82"