Skip to content

Commit 33a8515

Browse files
committed
For SAFE: simplifyCalls -
Add test cases for calls without args. Add a TN test for calls without the ThisExpression
1 parent 2baf0f1 commit 33a8515

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tests/modules.test.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,12 +682,24 @@ describe('SAFE: separateChainedDeclarators', async () => {
682682
});
683683
describe('SAFE: simplifyCalls', async () => {
684684
const targetModule = (await import('../src/modules/safe/simplifyCalls.js')).default;
685-
it('TP-1', () => {
685+
it('TP-1: With args', () => {
686686
const code = `func1.apply(this, [arg1, arg2]); func2.call(this, arg1, arg2);`;
687687
const expected = `func1(arg1, arg2);\nfunc2(arg1, arg2);`;
688688
const result = applyModuleToCode(code, targetModule);
689689
assert.strictEqual(result, expected);
690690
});
691+
it('TP-2: Without args', () => {
692+
const code = `func1.apply(this); func2.call(this);`;
693+
const expected = `func1();\nfunc2();`;
694+
const result = applyModuleToCode(code, targetModule);
695+
assert.strictEqual(result, expected);
696+
});
697+
it('TN-1: Ignore calls without ThisExpression', () => {
698+
const code = `func1.apply({}); func2.call(null);`;
699+
const expected = code;
700+
const result = applyModuleToCode(code, targetModule);
701+
assert.strictEqual(result, expected);
702+
});
691703
});
692704
describe('SAFE: simplifyIfStatements', async () => {
693705
const targetModule = (await import('../src/modules/safe/simplifyIfStatements.js')).default;

0 commit comments

Comments
 (0)