From 57ba44f6b55c214d0f20339cd45bece57f24f48c Mon Sep 17 00:00:00 2001 From: openorclose Date: Mon, 4 Mar 2019 23:25:45 +0800 Subject: [PATCH 1/5] Use alpha version of js-slang, with verbose messages and native enabled --- package.json | 2 +- src/mocks/context.ts | 6 +++--- src/sagas/index.ts | 2 +- yarn.lock | 21 ++++++++++++++------- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 008bb3663e..16ba6306ce 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.2", "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 fdeb9b3429..f5a39c0620 100644 --- a/yarn.lock +++ b/yarn.lock @@ -246,10 +246,10 @@ "@types/cheerio" "*" "@types/react" "*" -"@types/enzyme@^3.1.17": - version "3.9.0" - resolved "https://registry.yarnpkg.com/@types/enzyme/-/enzyme-3.9.0.tgz#a81c91e2dfd2d70e67f013f2c0e5efed6df05489" - integrity sha512-o0C7ooyBtj9NKyMzn2BWN53W4J21KPhO+/v+qqQX28Pcz0Z1B3DjL9bq2ZR4TN70PVw8O7gkhuFtC7VN3tausg== +"@types/enzyme@3.1.17": + version "3.1.17" + resolved "https://registry.yarnpkg.com/@types/enzyme/-/enzyme-3.1.17.tgz#41f553bfdbaa00880488feabb3ade47d5489db42" + integrity sha512-pZ+Blk1hODkprPZ9cxXd8njxdBnbLGWOKAmKk0QhpJvWzI4q4F20FHHUnkZXPXJt5WnK6SbbY5lfTKoz1M/CTw== dependencies: "@types/cheerio" "*" "@types/react" "*" @@ -5192,9 +5192,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.2: + version "0.2.1-alpha.2" + resolved "https://registry.yarnpkg.com/js-slang/-/js-slang-0.2.1-alpha.2.tgz#0c69db6049907dea67f899586b3d0214dfada6e1" + integrity sha512-BhC0bi/P8mecqHD3nWu9i3F2QHQVpe6lzcNm/yuHdUkdh8l8+flrVUOADYFWBpk173LGqmknym/ifZ0IPzFMyA== dependencies: "@types/estree" "0.0.39" acorn "^6.0.5" @@ -5203,6 +5204,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" @@ -8932,6 +8934,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" From 7f63bb5cfa6addbe8dc3f4ee024860252591414d Mon Sep 17 00:00:00 2001 From: openorclose Date: Tue, 5 Mar 2019 16:32:56 +0800 Subject: [PATCH 2/5] Update js-slang to alpha-3 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 16ba6306ce..20b080fb6f 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.1-alpha.2", + "js-slang": "0.2.1-alpha.3", "lodash": "^4.17.11", "lz-string": "^1.4.4", "moment": "^2.22.2", diff --git a/yarn.lock b/yarn.lock index f5a39c0620..d97e33ae70 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5192,10 +5192,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.1-alpha.2: - version "0.2.1-alpha.2" - resolved "https://registry.yarnpkg.com/js-slang/-/js-slang-0.2.1-alpha.2.tgz#0c69db6049907dea67f899586b3d0214dfada6e1" - integrity sha512-BhC0bi/P8mecqHD3nWu9i3F2QHQVpe6lzcNm/yuHdUkdh8l8+flrVUOADYFWBpk173LGqmknym/ifZ0IPzFMyA== +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" From f91baae5d158d11218068849c67622f08611d0ed Mon Sep 17 00:00:00 2001 From: openorclose Date: Sat, 6 Apr 2019 20:42:23 +0800 Subject: [PATCH 3/5] Update js-slang to alpha-4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2925ca05de..9247629f06 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.1-alpha.3", + "js-slang": "0.2.1-alpha.4", "lodash": "^4.17.11", "lz-string": "^1.4.4", "moment": "^2.22.2", From 08af0498355cb5547e4f96d5ac35491a6e12a686 Mon Sep 17 00:00:00 2001 From: "Open O. Close" <3646725+openorclose@users.noreply.github.com> Date: Sat, 6 Apr 2019 20:49:59 +0800 Subject: [PATCH 4/5] Update README.md --- README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) 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 From 844273904349ca94f75c02317efd2d7eaecae825 Mon Sep 17 00:00:00 2001 From: "Open O. Close" <3646725+openorclose@users.noreply.github.com> Date: Sat, 6 Apr 2019 20:52:02 +0800 Subject: [PATCH 5/5] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9247629f06..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.1-alpha.4", + "js-slang": "0.2.1-alpha.4", "lodash": "^4.17.11", "lz-string": "^1.4.4", "moment": "^2.22.2",