This commit is contained in:
sanex3339
2020-06-23 08:24:17 +03:00
parent 3727fe2acf
commit 49259f1ef4
9 changed files with 78 additions and 54 deletions
+3 -11
View File
@@ -7,17 +7,9 @@ import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNo
let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
`
(function () {
const foo = {
prop1: 1,
prop2: 2,
calc: function () {
return this.prop1 + this.prop2;
}
};
console.log(foo.calc());
})();
class Foo {
[(1, Symbol.asyncIterator)]() {}
}
`,
{
...NO_ADDITIONAL_NODES_PRESET,
@@ -571,6 +571,30 @@ describe('JavaScriptObfuscator', () => {
});
});
/**
* https://github.com/estools/escodegen/pull/415
*/
describe('Precedence of `SequenceExpression` in computed property', () => {
const regExp: RegExp = /class Foo *{ *\[\(bar, *baz\)]\(\) *{ *} * *}/;
let obfuscatedCode: string;
beforeEach(() => {
const code: string = readFileAsString(__dirname + '/fixtures/precedence-of-sequence-expression-in-computed-property.js');
obfuscatedCode = JavaScriptObfuscator.obfuscate(
code,
{
...NO_ADDITIONAL_NODES_PRESET
}
).getObfuscatedCode();
});
it('should generate a valid js code', () => {
assert.match(obfuscatedCode, regExp);
});
});
describe('new.target MetaProperty', () => {
const regExp: RegExp = /new\.target *=== *Foo/;
@@ -0,0 +1,3 @@
class Foo {
[(bar, baz)]() {}
}