Skip to content

Commit

Permalink
For SAFE: simplifyCalls -
Browse files Browse the repository at this point in the history
  Add test cases for calls without args.
  Add a TN test for calls without the ThisExpression
  • Loading branch information
BenBaryoPX committed Nov 3, 2024
1 parent 2baf0f1 commit 33a8515
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/modules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,12 +682,24 @@ describe('SAFE: separateChainedDeclarators', async () => {
});
describe('SAFE: simplifyCalls', async () => {
const targetModule = (await import('../src/modules/safe/simplifyCalls.js')).default;
it('TP-1', () => {
it('TP-1: With args', () => {
const code = `func1.apply(this, [arg1, arg2]); func2.call(this, arg1, arg2);`;
const expected = `func1(arg1, arg2);\nfunc2(arg1, arg2);`;
const result = applyModuleToCode(code, targetModule);
assert.strictEqual(result, expected);
});
it('TP-2: Without args', () => {
const code = `func1.apply(this); func2.call(this);`;
const expected = `func1();\nfunc2();`;
const result = applyModuleToCode(code, targetModule);
assert.strictEqual(result, expected);
});
it('TN-1: Ignore calls without ThisExpression', () => {
const code = `func1.apply({}); func2.call(null);`;
const expected = code;
const result = applyModuleToCode(code, targetModule);
assert.strictEqual(result, expected);
});
});
describe('SAFE: simplifyIfStatements', async () => {
const targetModule = (await import('../src/modules/safe/simplifyIfStatements.js')).default;
Expand Down

0 comments on commit 33a8515

Please sign in to comment.