mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
FunctionControlFlowTransformer tests: testing few items in controlFlowNode storage
This commit is contained in:
+4
@@ -0,0 +1,4 @@
|
||||
(function () {
|
||||
var test1 = 1 + 2;
|
||||
var test2 = 2 - 3;
|
||||
})();
|
||||
+28
@@ -86,5 +86,33 @@ describe('FunctionControlFlowTransformer', () => {
|
||||
assert.closeTo((totalValue - samplesCount) / samplesCount, expectedValue, delta);
|
||||
});
|
||||
});
|
||||
|
||||
describe('variant #3 - single `control flow storage` node with multiple items', () => {
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
readFileAsString(
|
||||
'./test/fixtures/node-transformers/node-control-flow-transformers/function-control-flow-transformer-multiple-items-1.js'
|
||||
),
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
controlFlowFlattening: true,
|
||||
controlFlowFlatteningThreshold: 1
|
||||
}
|
||||
);
|
||||
const obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
|
||||
const regexp: RegExp = new RegExp(
|
||||
`var *${variableMatch} *= *\\{` +
|
||||
`'(\\\\x[a-f0-9]*){3}' *: *function *${variableMatch} *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
|
||||
`return *${variableMatch} *\\+ *${variableMatch};` +
|
||||
`\\}, *` +
|
||||
`'(\\\\x[a-f0-9]*){3}' *: *function *${variableMatch} *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
|
||||
`return *${variableMatch} *- *${variableMatch};` +
|
||||
`\\}` +
|
||||
`\\};`
|
||||
);
|
||||
|
||||
it('should add `control flow storage` node with multiple items to the obfuscated code', () => {
|
||||
assert.match(obfuscatedCode, regexp);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user