mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
large rework of node appending mechanics
This commit is contained in:
@@ -151,7 +151,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
|
||||
it('should returns correct IStackTraceData - variant #1: basic-1', () => {
|
||||
astTree = NodeMocks.getProgramNode(
|
||||
<ESTree.Statement[]>NodeUtils.convertCodeToStructure(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/basic-1.js')
|
||||
)
|
||||
);
|
||||
@@ -198,7 +198,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
|
||||
it('should returns correct BlockScopeTraceData - variant #2: basic-2', () => {
|
||||
astTree = NodeMocks.getProgramNode(
|
||||
<ESTree.Statement[]>NodeUtils.convertCodeToStructure(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/basic-2.js')
|
||||
)
|
||||
);
|
||||
@@ -234,7 +234,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
|
||||
it('should returns correct BlockScopeTraceData - variant #3: deep conditions nesting', () => {
|
||||
astTree = NodeMocks.getProgramNode(
|
||||
<ESTree.Statement[]>NodeUtils.convertCodeToStructure(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/deep-conditions-nesting.js')
|
||||
)
|
||||
);
|
||||
@@ -270,7 +270,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
|
||||
it('should returns correct BlockScopeTraceData - variant #4: call before declaration', () => {
|
||||
astTree = NodeMocks.getProgramNode(
|
||||
<ESTree.Statement[]>NodeUtils.convertCodeToStructure(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/call-before-declaration.js')
|
||||
)
|
||||
);
|
||||
@@ -290,7 +290,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
|
||||
it('should returns correct BlockScopeTraceData - variant #5: call expression of object member', () => {
|
||||
astTree = NodeMocks.getProgramNode(
|
||||
<ESTree.Statement[]>NodeUtils.convertCodeToStructure(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/call-expression-of-object-member.js')
|
||||
)
|
||||
);
|
||||
@@ -346,7 +346,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
|
||||
it('should returns correct BlockScopeTraceData - variant #6: no call expressions', () => {
|
||||
astTree = NodeMocks.getProgramNode(
|
||||
<ESTree.Statement[]>NodeUtils.convertCodeToStructure(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/no-call-expressions.js')
|
||||
)
|
||||
);
|
||||
@@ -360,7 +360,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
|
||||
it('should returns correct BlockScopeTraceData - variant #7: only call expression', () => {
|
||||
astTree = NodeMocks.getProgramNode(
|
||||
<ESTree.Statement[]>NodeUtils.convertCodeToStructure(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/only-call-expression.js')
|
||||
)
|
||||
);
|
||||
@@ -374,7 +374,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
|
||||
it('should returns correct BlockScopeTraceData - variant #8: self-invoking functions', () => {
|
||||
astTree = NodeMocks.getProgramNode(
|
||||
<ESTree.Statement[]>NodeUtils.convertCodeToStructure(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/self-invoking-functions.js')
|
||||
)
|
||||
);
|
||||
@@ -406,7 +406,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
|
||||
it('should returns correct BlockScopeTraceData - variant #9: no recursion', () => {
|
||||
astTree = NodeMocks.getProgramNode(
|
||||
<ESTree.Statement[]>NodeUtils.convertCodeToStructure(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/no-recursion.js')
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import * as escodegen from 'escodegen';
|
||||
import * as ESTree from 'estree';
|
||||
|
||||
import { TStatement } from '../../src/types/TStatement';
|
||||
|
||||
import { NodeType } from '../../src/enums/NodeType';
|
||||
|
||||
export class NodeMocks {
|
||||
@@ -8,7 +10,7 @@ export class NodeMocks {
|
||||
* @param bodyNodes
|
||||
* @returns {ESTree.Program}
|
||||
*/
|
||||
public static getProgramNode (bodyNodes: ESTree.Statement[] = []): ESTree.Program {
|
||||
public static getProgramNode (bodyNodes: TStatement[] = []): ESTree.Program {
|
||||
return {
|
||||
type: NodeType.Program,
|
||||
body: bodyNodes,
|
||||
|
||||
@@ -27,7 +27,7 @@ describe('NodeUtils', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('appendNode (blockScopeNode: TNodeWithBlockStatement[], nodeBodyStatements: TStatement[])', () => {
|
||||
describe('appendNode (blockScopeNode: TNodeWithBlockStatement[], nodeBodyStatements: TStatement[]): void', () => {
|
||||
let blockStatementNode: ESTree.BlockStatement,
|
||||
expectedBlockStatementNode: ESTree.BlockStatement,
|
||||
expectedExpressionStatementNode: ESTree.ExpressionStatement,
|
||||
@@ -198,7 +198,7 @@ describe('NodeUtils', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('insertNodeAtIndex (blockScopeNode: TNodeWithBlockStatement[], nodeBodyStatements: TStatement[], index: number): TNodeWithBlockStatement[]', () => {
|
||||
describe('insertNodeAtIndex (blockScopeNode: TNodeWithBlockStatement[], nodeBodyStatements: TStatement[], index: number): void', () => {
|
||||
let blockStatementNode: ESTree.BlockStatement,
|
||||
expectedBlockStatementNode: ESTree.BlockStatement,
|
||||
expressionStatementNode1: ESTree.ExpressionStatement,
|
||||
@@ -296,7 +296,7 @@ describe('NodeUtils', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('prependNode (blockScopeNode: TNodeWithBlockStatement[], nodeBodyStatements: TStatement[]): TNodeWithBlockStatement[]', () => {
|
||||
describe('prependNode (blockScopeNode: TNodeWithBlockStatement[], nodeBodyStatements: TStatement[]): void', () => {
|
||||
let blockStatementNode: ESTree.BlockStatement,
|
||||
expectedBlockStatementNode: ESTree.BlockStatement,
|
||||
expressionStatementNode1: ESTree.ExpressionStatement,
|
||||
|
||||
@@ -13,7 +13,7 @@ import { StackTraceAnalyzer } from '../../../src/stack-trace-analyzer/StackTrace
|
||||
const assert: any = chai.assert;
|
||||
|
||||
describe('CustomNodeAppender', () => {
|
||||
describe('appendNode (blockScopeStackTraceData: IStackTraceData[], blockScopeNode: TNodeWithBlockStatement, nodeBodyStatements: TStatement[], index: number = 0)', () => {
|
||||
describe('appendNode (blockScopeStackTraceData: IStackTraceData[], blockScopeNode: TNodeWithBlockStatement, nodeBodyStatements: TStatement[], index: number = 0): void', () => {
|
||||
let astTree: ESTree.Program,
|
||||
expectedAstTree: ESTree.Program,
|
||||
node: TStatement[],
|
||||
|
||||
Reference in New Issue
Block a user