mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
0.28.0 release
Support of BigInt
This commit is contained in:
+41
-16
@@ -13,30 +13,55 @@ import { InversifyContainerFacade } from '../../../../src/container/InversifyCon
|
||||
|
||||
describe('HexadecimalIdentifierNamesGenerator', () => {
|
||||
describe('generateNext', () => {
|
||||
let identifierNamesGenerator: IIdentifierNamesGenerator,
|
||||
hexadecimalIdentifierName: string,
|
||||
regExp: RegExp;
|
||||
describe('Base', () => {
|
||||
let identifierNamesGenerator: IIdentifierNamesGenerator,
|
||||
hexadecimalIdentifierName: string,
|
||||
regExp: RegExp;
|
||||
|
||||
before(() => {
|
||||
const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
|
||||
before(() => {
|
||||
const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
|
||||
|
||||
inversifyContainerFacade.load('', '', {});
|
||||
identifierNamesGenerator = inversifyContainerFacade.getNamed<IIdentifierNamesGenerator>(
|
||||
ServiceIdentifiers.IIdentifierNamesGenerator,
|
||||
IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator
|
||||
);
|
||||
inversifyContainerFacade.load('', '', {});
|
||||
identifierNamesGenerator = inversifyContainerFacade.getNamed<IIdentifierNamesGenerator>(
|
||||
ServiceIdentifiers.IIdentifierNamesGenerator,
|
||||
IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator
|
||||
);
|
||||
|
||||
hexadecimalIdentifierName = identifierNamesGenerator.generateNext();
|
||||
regExp = /^_0x(\w){4,6}$/;
|
||||
hexadecimalIdentifierName = identifierNamesGenerator.generateNext();
|
||||
regExp = /^_0x(\w){6}$/;
|
||||
});
|
||||
|
||||
it('should return hexadecimal name', () => {
|
||||
assert.match(hexadecimalIdentifierName, regExp);
|
||||
})
|
||||
});
|
||||
|
||||
it('should return hexadecimal name', () => {
|
||||
assert.match(hexadecimalIdentifierName, regExp);
|
||||
})
|
||||
describe('Custom length', () => {
|
||||
let identifierNamesGenerator: IIdentifierNamesGenerator,
|
||||
hexadecimalIdentifierName: string,
|
||||
regExp: RegExp;
|
||||
|
||||
before(() => {
|
||||
const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
|
||||
|
||||
inversifyContainerFacade.load('', '', {});
|
||||
identifierNamesGenerator = inversifyContainerFacade.getNamed<IIdentifierNamesGenerator>(
|
||||
ServiceIdentifiers.IIdentifierNamesGenerator,
|
||||
IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator
|
||||
);
|
||||
|
||||
hexadecimalIdentifierName = identifierNamesGenerator.generateNext(4);
|
||||
regExp = /^_0x(\w){4}$/;
|
||||
});
|
||||
|
||||
it('should return hexadecimal name', () => {
|
||||
assert.match(hexadecimalIdentifierName, regExp);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateForGlobalScope', () => {
|
||||
const regExp: RegExp = /^foo_0x(\w){4,6}$/;
|
||||
const regExp: RegExp = /^foo_0x(\w){6}$/;
|
||||
|
||||
let identifierNamesGenerator: IIdentifierNamesGenerator,
|
||||
hexadecimalIdentifierName: string;
|
||||
|
||||
@@ -6,7 +6,7 @@ describe('NumberUtils', () => {
|
||||
describe('toHex', () => {
|
||||
describe('Variant #1: number `0`', () => {
|
||||
const number: number = 0;
|
||||
const expectedHexString = '0';
|
||||
const expectedHexString = '0x0';
|
||||
|
||||
let hexString: string;
|
||||
|
||||
@@ -21,7 +21,7 @@ describe('NumberUtils', () => {
|
||||
|
||||
describe('Variant #2: number `10`', () => {
|
||||
const number: number = 10;
|
||||
const expectedHexString = 'a';
|
||||
const expectedHexString = '0xa';
|
||||
|
||||
let hexString: string;
|
||||
|
||||
@@ -36,7 +36,7 @@ describe('NumberUtils', () => {
|
||||
|
||||
describe('Variant #3: number `17`', () => {
|
||||
const number: number = 17;
|
||||
const expectedHexString = '11';
|
||||
const expectedHexString = '0x11';
|
||||
|
||||
let hexString: string;
|
||||
|
||||
@@ -51,7 +51,7 @@ describe('NumberUtils', () => {
|
||||
|
||||
describe('Variant #4: number `536870912`', () => {
|
||||
const number: number = 536870912;
|
||||
const expectedHexString = '20000000';
|
||||
const expectedHexString = '0x20000000';
|
||||
|
||||
let hexString: string;
|
||||
|
||||
@@ -63,6 +63,22 @@ describe('NumberUtils', () => {
|
||||
assert.equal(hexString, expectedHexString);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #5: bigint number `10n`', () => {
|
||||
// @ts-ignore
|
||||
const number: bigint = 10n;
|
||||
const expectedHexString = '0xan';
|
||||
|
||||
let hexString: string;
|
||||
|
||||
before(() => {
|
||||
hexString = NumberUtils.toHex(number);
|
||||
});
|
||||
|
||||
it('should create a string with hexadecimal value from a given bigint number', () => {
|
||||
assert.equal(hexString, expectedHexString);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('isCeil', () => {
|
||||
@@ -95,5 +111,21 @@ describe('NumberUtils', () => {
|
||||
assert.equal(result, expectedResult);
|
||||
});
|
||||
});
|
||||
|
||||
describe('bigint number', () => {
|
||||
// @ts-ignore
|
||||
const number: bigint = 10n;
|
||||
const expectedResult: boolean = true;
|
||||
|
||||
let result: boolean;
|
||||
|
||||
before(() => {
|
||||
result = NumberUtils.isCeil(number);
|
||||
});
|
||||
|
||||
it('should return true', () => {
|
||||
assert.equal(result, expectedResult);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user