From 76846c807e5d8b80d53d64a2b5dc58024ebb0dc2 Mon Sep 17 00:00:00 2001 From: sanex3339 Date: Sat, 7 Jan 2017 17:23:44 +0300 Subject: [PATCH] Now copying fixtures to test-tmp dir to keep relative requests with __dirname for test fixtures --- scripts/test-compile | 3 +- test/dev/dev.ts | 82 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/scripts/test-compile b/scripts/test-compile index 6d0ca7fa..a2dab091 100755 --- a/scripts/test-compile +++ b/scripts/test-compile @@ -1,4 +1,5 @@ #!/bin/bash $(npm bin)/tsc -p tsconfig-test.json && -$(npm bin)/babel test-tmp --out-dir test-tmp --source-maps inline --presets es2015 \ No newline at end of file +$(npm bin)/babel test-tmp --out-dir test-tmp --source-maps inline --presets es2015 && +rsync -a --prune-empty-dirs --include '*/' --include '*.js' --exclude '*' test/ test-tmp/test/ diff --git a/test/dev/dev.ts b/test/dev/dev.ts index caeb18dc..6aa24259 100644 --- a/test/dev/dev.ts +++ b/test/dev/dev.ts @@ -9,7 +9,87 @@ if (!(global)._babelPolyfill) { const JavaScriptObfuscator: any = require("../../index"); let obfuscatedCode: string = JavaScriptObfuscator.obfuscate( - 'var variable = `abc`;', + ` + (function(){ + var result = 1, + term1 = 0, + term2 = 1, + i = 1; + while(i < 10) + { + var test = 10; + result = term1 + term2; + console.log(result); + term1 = term2; + term2 = result; + i++; + } + + console.log(test); + + var test = function (test) { + console.log(test); + + if (true) { + var test = 5 + } + + return test; + } + + console.log(test(1)); + + function test2 (abc) { + function test1 () { + console.log('inside', abc.item); + } + + console.log('ั‚ะตัั‚', abc); + + var abc = {}; + + return abc.item = 15, test1(); + }; + + var regexptest = /version\\/(\\d+)/i; + console.log(regexptest); + + test2(22); + console.log(105.4); + console.log(true, false); + + var sA = 'shorthand1'; + var sB = 'shorthand2'; + + console.log({sA, sB}); + + try { + } catch (error) { + console.log(error); + } + + function foo () { + return function () { + var sum1 = 10 + 20; + var sum2 = 20 + 30; + var sum3 = 30 + 50; + var sub = sum3 - sum2; + + return sum1 + sub; + } + } + + console.log(foo()()); + + if (true) { + console.log(\`1\`); + console.log(\`2\`); + console.log(\`3\`); + console.log(\`4\`); + console.log(\`5\`); + } + })(); + `, { ...NO_CUSTOM_NODES_PRESET, compact: false