Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js-eval: use engine262's own TLA #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/plugins/js-eval/__tests__/jsEvalPlugin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,16 @@ describe('jsEvalPlugin', () => {
await testEval(
`n> function foo(){}; let o={[await 'foo']: await eval('1')}; o`,
),
await testEval(
`e> function foo(){}; let o={[await 'foo']: await eval('1')}; o`,
),
]).toEqual([
'(okay) 2n',
'(okay) 2n',
'(okay) undefined',
'(okay) undefined',
'(okay) { foo: 1 }',
'(okay) { foo: 1 }',
]);
});

Expand Down
10 changes: 5 additions & 5 deletions src/plugins/js-eval/jsEvalPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const jsEvalPlugin = async ({ mentionUser, respond, message, selfConfig = {} })
if (mode === '?') return respond((mentionUser ? `${mentionUser}, ` : '') + helpMsg);
let code = message.slice(2);

const hasMaybeTLA = /\bawait\b/.test(code);
const hasMaybeTLA = mode !== 'e' && /\bawait\b/.test(code); // engine262 ships TLA

if (mode === 'b' && !hasMaybeTLA) {
code = (await babel.transformAsync(code, { plugins: transformPlugins })).code;
Expand All @@ -58,10 +58,10 @@ const jsEvalPlugin = async ({ mentionUser, respond, message, selfConfig = {} })
mode === 'e'
? 'engine262'
: mode === 's'
? 'script'
: mode === 'm'
? 'module'
: 'node-cjs',
? 'script'
: mode === 'm'
? 'module'
: 'node-cjs',
selfConfig.timer || 5000,
mode === 'b' ? CMD_SHIMS : mode === 'n' ? CMD : CMD_HARMONY,
);
Expand Down