summaryrefslogtreecommitdiff
path: root/node_modules/webworker-threads/test
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/webworker-threads/test')
-rw-r--r--node_modules/webworker-threads/test/ab.js96
-rw-r--r--node_modules/webworker-threads/test/test00_run_once_and_destroy.js27
-rw-r--r--node_modules/webworker-threads/test/test01_loop_as_fast_as_possible.js84
-rw-r--r--node_modules/webworker-threads/test/test02_loop_as_fast_as_possible.js32
-rw-r--r--node_modules/webworker-threads/test/test03_infiniteLoopFunction.js32
-rw-r--r--node_modules/webworker-threads/test/test04_gc_versus_not_gc.js44
-rw-r--r--node_modules/webworker-threads/test/test05_debugLeaksNoCallbacks.js32
-rw-r--r--node_modules/webworker-threads/test/test06_throw_from_the_thread.js12
-rw-r--r--node_modules/webworker-threads/test/test07_sigkill.js24
-rw-r--r--node_modules/webworker-threads/test/test08_sigkill_leaks.js30
-rw-r--r--node_modules/webworker-threads/test/test09_throw_from_the_callback.js15
-rw-r--r--node_modules/webworker-threads/test/test10_node_nextTick_speed.js35
-rw-r--r--node_modules/webworker-threads/test/test11_multi_callbacks.js38
-rw-r--r--node_modules/webworker-threads/test/test12_precompiled_vs_normal.js42
-rw-r--r--node_modules/webworker-threads/test/test13_thread_nextTick_speed.js31
-rw-r--r--node_modules/webworker-threads/test/test14_emit_once.js20
-rw-r--r--node_modules/webworker-threads/test/test15_emit_ping_pong.js31
-rw-r--r--node_modules/webworker-threads/test/test16_syntax_error_in_the_thread.js13
-rw-r--r--node_modules/webworker-threads/test/test17_pool_pi.js67
-rw-r--r--node_modules/webworker-threads/test/test18_pool_any_as_fast_as_possible.js47
-rw-r--r--node_modules/webworker-threads/test/test19_pool_emit_any_all.js37
-rw-r--r--node_modules/webworker-threads/test/test20_removeAllListeners.js23
-rw-r--r--node_modules/webworker-threads/test/test21_emit_ping_pong_big_string.js32
-rw-r--r--node_modules/webworker-threads/test/test22_create_destroy_loop.js25
-rw-r--r--node_modules/webworker-threads/test/test23_create_destroy_loop.js25
-rw-r--r--node_modules/webworker-threads/test/test24_puts.js17
-rw-r--r--node_modules/webworker-threads/test/test25_delete_puts.js23
-rw-r--r--node_modules/webworker-threads/test/test26_puts_with_many_args.js18
-rw-r--r--node_modules/webworker-threads/test/test27_puts_event_loop.js14
-rw-r--r--node_modules/webworker-threads/test/test28_puts_nextTick_loop.js14
-rw-r--r--node_modules/webworker-threads/test/test29_puts_callback_loop.js14
31 files changed, 994 insertions, 0 deletions
diff --git a/node_modules/webworker-threads/test/ab.js b/node_modules/webworker-threads/test/ab.js
new file mode 100644
index 0000000..8fc6665
--- /dev/null
+++ b/node_modules/webworker-threads/test/ab.js
@@ -0,0 +1,96 @@
+
+
+var http= require('http');
+http.globalAgent.maxSockets= 16384;
+
+var options= {
+ port: +process.argv[2] || 1200
+};
+
+var results= {
+ requestsPerSecond: 0,
+ "duration(ms)": 0,
+ sent: 0,
+ connected: 0,
+ completed: 0,
+ errors: 0,
+ " QUICK": 1,
+ " 14930352": 1
+};
+
+
+var dsp= "";
+function display () {
+ process.stdout.write(dsp);
+ dsp= "";
+}
+
+//var displayInterval= setInterval(display, 333);
+
+function run (i) {
+ var now= Date.now();
+ if (now < (t+ duration)) {
+ if (results.sent <= (results.connected + results.errors)) {
+ i= 200;
+ while (i--) {
+ anotherOne();
+ }
+ }
+ setTimeout(run, 100);
+ }
+ else {
+ results["duration(ms)"]= now- t;
+ results.requestsPerSecond= (results.completed*1e3/(now-t)).toFixed(1);
+ //clearInterval(displayInterval);
+ display();
+ console.log("\n", results);
+ process.exit();
+ }
+
+}
+
+function anotherOne () {
+ results.sent++;
+ http.get(options, onConnect).on('error', onERR);
+}
+
+function onConnect (res) {
+ anotherOne();
+ res.on('data', onData);
+ results.connected++;
+ dsp+= ".";
+}
+
+function onData (txt) {
+ results[txt]++;
+ results.completed++;
+}
+
+function onERR (err) {
+ results.errors++;
+ dsp+= "❚";
+ console.log(err);
+}
+
+
+
+var t;
+var duration= 1000;
+(function wait () {
+ var exec= require('child_process').exec;
+ exec('netstat -f inet | grep -c TIME_WAIT', function (err, o, e) {
+ o= Math.floor(o+ e);
+ console.log("Sockets in TIME_WAIT: "+ o);
+ if (o) {
+ setTimeout(wait, 1500);
+ }
+ else {
+ console.log("GO!");
+ t= Date.now();
+ run();
+ }
+ });
+})();
+
+
+
diff --git a/node_modules/webworker-threads/test/test00_run_once_and_destroy.js b/node_modules/webworker-threads/test/test00_run_once_and_destroy.js
new file mode 100644
index 0000000..78eb895
--- /dev/null
+++ b/node_modules/webworker-threads/test/test00_run_once_and_destroy.js
@@ -0,0 +1,27 @@
+
+
+var Threads= require('webworker-threads');
+
+
+function cb (err, data) {
+ ++i;
+ console.log('['+ this.id+ '] -> '+ data);
+ this.destroy();
+}
+
+function ƒ () { return Math.random() }
+
+var i= +process.argv[2] || 1;
+console.log('Using '+ i+ ' threads');
+
+var t= Date.now();
+while (i--) {
+ Threads.create().eval(ƒ).eval('ƒ()', cb);
+}
+
+i= 0;
+process.on('exit', function () {
+ t= Date.now()- t;
+ console.log('THREADS PER SECOND -> '+ (i*1e3/t).toFixed(1));
+ console.log('BYE !');
+});
diff --git a/node_modules/webworker-threads/test/test01_loop_as_fast_as_possible.js b/node_modules/webworker-threads/test/test01_loop_as_fast_as_possible.js
new file mode 100644
index 0000000..f55d0d7
--- /dev/null
+++ b/node_modules/webworker-threads/test/test01_loop_as_fast_as_possible.js
@@ -0,0 +1,84 @@
+
+
+var Threads= require('webworker-threads');
+
+function cb (err, msg) {
+ i++;
+ threads[this.id]++;
+ this.eval(source, cb);
+ //process.stdout.write('['+ this.id+ ']');
+}
+
+
+function ƒ () { }
+var source= "ƒ()";
+
+var i= +process.argv[2] || 1;
+console.log('Using '+ i+ ' threads');
+
+var threads= [];
+while (i--) {
+ threads[i]= 0;
+ Threads.create().eval(ƒ)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb)
+ .eval(source, cb);
+ process.stdout.write('.');
+}
+
+i= 0;
+var t= Date.now();
+function display () {
+ var e= Date.now()- t;
+ var tps= (i*1e3/e).toFixed(1);
+ process.stdout.write('\nt (ms) -> '+ e+ ', i -> '+ i+ ', tps -> '+ tps+ ', [ '+ threads.map(percent)+ ' ]');
+ function percent (v) {
+ return Math.round(v/i*100);
+ }
+}
+
+
+
+setInterval(display, 1e3);
+
+function pi () {
+ var π= 0;
+ var num= 4;
+ var den= 1;
+ var plus= true;
+
+ while (den < 1e6) {
+ if (plus) {
+ π+= num/den;
+ plus= false;
+ }
+ else {
+ π-= num/den;
+ plus= true;
+ }
+ den+= 2;
+ }
+ return π;
+} \ No newline at end of file
diff --git a/node_modules/webworker-threads/test/test02_loop_as_fast_as_possible.js b/node_modules/webworker-threads/test/test02_loop_as_fast_as_possible.js
new file mode 100644
index 0000000..8585ec8
--- /dev/null
+++ b/node_modules/webworker-threads/test/test02_loop_as_fast_as_possible.js
@@ -0,0 +1,32 @@
+
+
+var Threads= require('webworker-threads');
+
+function cb (err, msg) {
+ i++;
+ this.eval(source, cb);
+ //process.stdout.write('['+ this.id+ ']');
+}
+
+
+function ƒ () { }
+var source= "ƒ()";
+
+var i= +process.argv[2] || 1;
+console.log('Using '+ i+ ' threads');
+
+
+while (i--) {
+ Threads.create().eval(ƒ).eval(source, cb);
+ process.stdout.write('.');
+}
+
+i= 0;
+var t= Date.now();
+function display () {
+ var e= Date.now()- t;
+ var tps= (i*1e3/e).toFixed(1);
+ console.log('t (ms) -> '+ e+ ', i -> '+ i+ ', tps -> '+ tps);
+}
+
+setInterval(display, 1e3);
diff --git a/node_modules/webworker-threads/test/test03_infiniteLoopFunction.js b/node_modules/webworker-threads/test/test03_infiniteLoopFunction.js
new file mode 100644
index 0000000..aca79c1
--- /dev/null
+++ b/node_modules/webworker-threads/test/test03_infiniteLoopFunction.js
@@ -0,0 +1,32 @@
+
+
+var Threads= require('webworker-threads');
+
+function cb (err, msg) {
+ ++i;
+ process.stdout.write('['+ this.id+ ']['+ i+ '] -> '+ msg+ '\n');
+ //process.stdout.write('['+ this.id+ ']');
+}
+
+function ƒ () { while (1) {} }
+
+
+var i= +process.argv[2] || 1;
+console.log('Using '+ i+ ' threads');
+
+var threads= [];
+var t= Date.now();
+while (i--) {
+ Threads.create().eval(ƒ).eval('ƒ()', cb);
+}
+
+
+i= 0;
+(function display () {
+ var e= Date.now()- t;
+ var tps= (i*1e3/e).toFixed(1);
+ console.log('\nTiempo total (ms) -> '+ e);
+ console.log('Threads por segundo -> '+ tps);
+ console.log('Total de threads ejecutadas -> '+ i);
+ setTimeout(display, 1e3);
+})();
diff --git a/node_modules/webworker-threads/test/test04_gc_versus_not_gc.js b/node_modules/webworker-threads/test/test04_gc_versus_not_gc.js
new file mode 100644
index 0000000..af745eb
--- /dev/null
+++ b/node_modules/webworker-threads/test/test04_gc_versus_not_gc.js
@@ -0,0 +1,44 @@
+
+
+var Threads= require('webworker-threads');
+
+console.log('Launch with/without --expose_gc to compare memory usage')
+
+function cb (err, msg) {
+ i++;
+ if (msg) console.log('['+ this.id+ ']'+ msg);
+ this.eval(source, cb);
+ //process.stdout.write('['+ this.id+ ']['+ i+ '] -> '+ msg+ '\n');
+ //process.stdout.write('['+ this.id+ ']');
+}
+
+
+function ƒ () {
+ if (++i % 10e3) return '';
+ try {
+ gc();
+ return ' -> gc()'
+ }
+ catch (e) {
+ return ' -> *NOT* gc()]';
+ }
+}
+var source= "ƒ()";
+
+var i= +process.argv[2] || 1;
+console.log('Using '+ i+ ' threads');
+
+
+while (i--) {
+ Threads.create().eval(ƒ+ '\nvar i= 0;').eval(source, cb);
+}
+
+i= 0;
+var t= Date.now();
+function display () {
+ var e= Date.now()- t;
+ var tps= (i*1e3/e).toFixed(1);
+ console.log('t (ms) -> '+ e+ ', i -> '+ i+ ', tps -> '+ tps);
+}
+
+setInterval(display, 1e3);
diff --git a/node_modules/webworker-threads/test/test05_debugLeaksNoCallbacks.js b/node_modules/webworker-threads/test/test05_debugLeaksNoCallbacks.js
new file mode 100644
index 0000000..ec006ec
--- /dev/null
+++ b/node_modules/webworker-threads/test/test05_debugLeaksNoCallbacks.js
@@ -0,0 +1,32 @@
+
+
+var Threads= require('webworker-threads');
+
+function ƒ () { return Math.random() }
+
+var i= +process.argv[2] || 1;
+console.log('Using '+ i+ ' threads');
+
+var threads= [];
+var t= Date.now();
+while (i--) {
+ var thread= Threads.create().eval(ƒ);
+ threads.push(thread);
+}
+
+i= 0;
+(function loop () {
+ threads.forEach(function (v) {
+ i++;
+ v.eval('ƒ()');
+ });
+ process.nextTick(loop); //segfaults
+})();
+
+
+(function display () {
+ var e= Date.now()- t;
+ var tps= (i*1e3/e).toFixed(1);
+ console.log('t (ms) -> '+ e+ ', tps -> '+ tps+ ', i -> '+ i);
+ setTimeout(display, 1e3);
+})();
diff --git a/node_modules/webworker-threads/test/test06_throw_from_the_thread.js b/node_modules/webworker-threads/test/test06_throw_from_the_thread.js
new file mode 100644
index 0000000..6e2ff62
--- /dev/null
+++ b/node_modules/webworker-threads/test/test06_throw_from_the_thread.js
@@ -0,0 +1,12 @@
+
+
+var Thread= require('webworker-threads');
+
+function cb (e,m) {
+ process.stdout.write('[ '+ e+ ', '+ m+ ' ]\n');
+ this.eval(src, cb);
+}
+
+var src= 'if (++i % 2) throw("An error -> "+ i); else ("No error -> "+ i);';
+
+Thread.create().eval('i=0').eval(src, cb);
diff --git a/node_modules/webworker-threads/test/test07_sigkill.js b/node_modules/webworker-threads/test/test07_sigkill.js
new file mode 100644
index 0000000..4749c14
--- /dev/null
+++ b/node_modules/webworker-threads/test/test07_sigkill.js
@@ -0,0 +1,24 @@
+
+
+var Thread= require('webworker-threads');
+
+
+function cb (e,m) {
+ this.ctr= this.ctr ? this.ctr+1 : 1;
+ console.log('['+ this.id+ '] -> '+ this.ctr);
+ if (this.ctr >= 9) this.destroy();
+ else this.eval('0', cb);
+}
+
+
+var i= +process.argv[2] || 1;
+console.log('Using '+ i+ ' threads');
+
+while (i--) {
+ Thread.create().eval('0', cb);
+}
+
+
+process.on('exit', function () {
+ console.log("process.on('exit') -> BYE!");
+});
diff --git a/node_modules/webworker-threads/test/test08_sigkill_leaks.js b/node_modules/webworker-threads/test/test08_sigkill_leaks.js
new file mode 100644
index 0000000..8b04c47
--- /dev/null
+++ b/node_modules/webworker-threads/test/test08_sigkill_leaks.js
@@ -0,0 +1,30 @@
+
+
+var Thread= require('webworker-threads');
+
+function cb (e,m) {
+ this.destroy();
+ console.log('['+this.id+'].destroy()');
+ //this.eval('0', cb);
+ again();
+}
+
+
+function again () {
+ Thread.create().eval('0', cb);
+}
+
+
+var i= +process.argv[2] || 1;
+console.log('Using '+ i+ ' threads');
+
+
+
+while (i--) {
+ again();
+}
+
+
+process.on('exit', function () {
+ console.log("process.on('exit') -> BYE!");
+});
diff --git a/node_modules/webworker-threads/test/test09_throw_from_the_callback.js b/node_modules/webworker-threads/test/test09_throw_from_the_callback.js
new file mode 100644
index 0000000..b5beddc
--- /dev/null
+++ b/node_modules/webworker-threads/test/test09_throw_from_the_callback.js
@@ -0,0 +1,15 @@
+
+
+var Thread= require('webworker-threads');
+
+function cb (e,m) {
+ console.log([e,m]);
+ this.destroy();
+ throw('An error');
+}
+
+Thread.create().eval('0', cb);
+
+process.on('uncaughtException', function () {
+ console.log('OK, BYE!');
+})
diff --git a/node_modules/webworker-threads/test/test10_node_nextTick_speed.js b/node_modules/webworker-threads/test/test10_node_nextTick_speed.js
new file mode 100644
index 0000000..1a31fc7
--- /dev/null
+++ b/node_modules/webworker-threads/test/test10_node_nextTick_speed.js
@@ -0,0 +1,35 @@
+
+
+var Threads= require('webworker-threads');
+
+function cb (err, msg) {
+ i++;
+ ƒ();
+ //process.stdout.write('['+ this.id+ ']');
+}
+
+
+function ƒ () { process.nextTick(cb) }
+
+var i= +process.argv[2] || 1;
+console.log('Using '+ i+ ' threads');
+
+var threads= [];
+while (i--) {
+ ƒ();
+}
+
+i= 0;
+var t= Date.now();
+function display () {
+ var e= Date.now()- t;
+ var tps= (i*1e3/e).toFixed(1);
+ process.stdout.write('\nt (ms) -> '+ e+ ', i -> '+ i+ ', tps -> '+ tps+ ', [ '+ threads.map(percent)+ ' ]');
+ function percent (v) {
+ return Math.round(v/i*100);
+ }
+}
+
+
+
+setInterval(display, 1e3); \ No newline at end of file
diff --git a/node_modules/webworker-threads/test/test11_multi_callbacks.js b/node_modules/webworker-threads/test/test11_multi_callbacks.js
new file mode 100644
index 0000000..9db4262
--- /dev/null
+++ b/node_modules/webworker-threads/test/test11_multi_callbacks.js
@@ -0,0 +1,38 @@
+
+
+var Threads= require('webworker-threads');
+
+function A (err, msg) {
+ i++;
+ this.eval('', B);
+ process.stdout.write('A');
+}
+
+function B (err, msg) {
+ i++;
+ this.eval('', C);
+ process.stdout.write('B');
+}
+
+function C (err, msg) {
+ i++;
+ this.eval('', A);
+ process.stdout.write('C');
+}
+
+var i= +process.argv[2] || 1;
+console.log('Using '+ i+ ' threads');
+
+while (i--) {
+ Threads.create().eval('0', A);
+ process.stdout.write('.');
+}
+
+i= 0;
+var t= Date.now();
+setInterval(function display () {
+ var e= Date.now()- t;
+ var tps= (i*1e3/e).toFixed(1);
+ process.stdout.write('\nt (ms) -> '+ e+ ', i -> '+ i+ ', tps -> '+ tps);
+}, 1e3);
+
diff --git a/node_modules/webworker-threads/test/test12_precompiled_vs_normal.js b/node_modules/webworker-threads/test/test12_precompiled_vs_normal.js
new file mode 100644
index 0000000..c4f86af
--- /dev/null
+++ b/node_modules/webworker-threads/test/test12_precompiled_vs_normal.js
@@ -0,0 +1,42 @@
+
+
+var Threads= require('webworker-threads');
+
+function A (err, msg) {
+ ctrA++;
+ this.eval(sourceText, A);
+ //process.stdout.write("\nA -> "+ msg);
+}
+
+function B (err, msg) {
+ ctrB++;
+ this.eval(precompiled, B);
+ //process.stdout.write("\nB -> "+ msg);
+}
+
+function ƒ () { return Math.random()* 10 }
+
+var sourceText= '('+ ƒ+ ')()';
+var precompiled= Threads.preCompile(sourceText);
+var i= +process.argv[2] || 1;
+console.log('Using '+ (i*2)+ ' threads');
+
+while (i--) {
+ var a= Threads.create();
+ var b= Threads.create();
+ b.eval(precompiled, B);
+ a.eval(sourceText, A);
+ process.stdout.write('.');
+}
+
+ctrA= 0;
+ctrB= 0;
+var t= Date.now();
+setInterval(function display () {
+ var e= Date.now()- t;
+ var tps= ((ctrA+ctrB)*1e3/e).toFixed(1);
+ var tpsA= (ctrA*1e3/e).toFixed(1);
+ var tpsB= (ctrB*1e3/e).toFixed(1);
+ process.stdout.write('\nt (ms) -> '+ e+ ', i -> '+ i+ ', tps -> '+ tps+ ', tpsA -> '+ tpsA+ ', tpsB -> '+ tpsB);
+}, 1e3);
+
diff --git a/node_modules/webworker-threads/test/test13_thread_nextTick_speed.js b/node_modules/webworker-threads/test/test13_thread_nextTick_speed.js
new file mode 100644
index 0000000..58e0e25
--- /dev/null
+++ b/node_modules/webworker-threads/test/test13_thread_nextTick_speed.js
@@ -0,0 +1,31 @@
+
+
+var Threads= require('webworker-threads');
+
+function ƒ () {
+ var i= 0;
+ var t= Date.now();
+
+ (function ƒ () {
+ thread.nextTick(ƒ);
+
+ if ((++i % 1e6) === 0) {
+ var e= Date.now()- t;
+ var cps= (i*1e3/e).toFixed(1);
+ thread.emit("data", cps);
+ }
+ })();
+
+}
+
+function onData (data) {
+ console.log(data);
+}
+
+var i= +process.argv[2] || 1;
+console.log('Using '+ i+ ' threads');
+
+while (i--) {
+ Threads.create().on('data', onData).eval(ƒ).eval('ƒ()');
+ process.stdout.write('.');
+}
diff --git a/node_modules/webworker-threads/test/test14_emit_once.js b/node_modules/webworker-threads/test/test14_emit_once.js
new file mode 100644
index 0000000..6b38812
--- /dev/null
+++ b/node_modules/webworker-threads/test/test14_emit_once.js
@@ -0,0 +1,20 @@
+
+
+var t= require('webworker-threads');
+
+function killHandler (data) {
+ console.log("GOT KILL with data -> "+ data);
+ o.destroy();
+}
+
+function boot () {
+ thread.once('kill', function (data) {
+ thread.emit('kill', data);
+ });
+}
+
+o= t.create().once('kill', killHandler).eval(boot).eval('boot()').emit('kill', "*** DATA");
+
+process.on('exit', function () {
+ console.log("Bye!");
+});
diff --git a/node_modules/webworker-threads/test/test15_emit_ping_pong.js b/node_modules/webworker-threads/test/test15_emit_ping_pong.js
new file mode 100644
index 0000000..98946a6
--- /dev/null
+++ b/node_modules/webworker-threads/test/test15_emit_ping_pong.js
@@ -0,0 +1,31 @@
+var t= require('webworker-threads');
+
+function eventHandler (data) {
+ ctr++;
+ this.emit('b', 0);
+}
+
+function boot () {
+ thread.on('b', eventHandler);
+
+ function eventHandler (data) {
+ thread.emit('a', 0);
+ }
+}
+
+var ctr= 0;
+var i= +process.argv[2] || 1;
+console.log('Using '+ i+ ' threads');
+
+var pool= t.createPool(i);
+pool.all.eval(boot).all.eval('boot()').on('a', eventHandler).all.emit('b', 0).all.emit('b', 0).all.emit('b', 0);
+
+
+var s= Date.now();
+function display () {
+ var e= Date.now()- s;
+ var ppps= (ctr*1e3/e).toFixed(1);
+ console.log("ping-pongs: "+ ctr+ ", ping-pongs-per-second: "+ ppps);
+}
+
+setInterval(display, 1e3);
diff --git a/node_modules/webworker-threads/test/test16_syntax_error_in_the_thread.js b/node_modules/webworker-threads/test/test16_syntax_error_in_the_thread.js
new file mode 100644
index 0000000..8a985ae
--- /dev/null
+++ b/node_modules/webworker-threads/test/test16_syntax_error_in_the_thread.js
@@ -0,0 +1,13 @@
+
+
+var Thread= require('webworker-threads');
+
+function cb (e,m) {
+ process.stdout.write('[ '+ e+ ', '+ m+ ', '+ (i++)+ ' ]\n');
+ this.eval(syntaxError, cb);
+}
+
+var i= 0;
+var syntaxError= 'if return then goto 1';
+
+Thread.create().eval(syntaxError, cb);
diff --git a/node_modules/webworker-threads/test/test17_pool_pi.js b/node_modules/webworker-threads/test/test17_pool_pi.js
new file mode 100644
index 0000000..1d8128f
--- /dev/null
+++ b/node_modules/webworker-threads/test/test17_pool_pi.js
@@ -0,0 +1,67 @@
+
+
+var T= require('webworker-threads');
+
+var i= process.argv[2] || 1;
+console.log("Creating a pool of "+ i+ " threads");
+
+var pool= T.createPool(i);
+
+pool.all.eval(pi);
+
+function pi () {
+ var π= 0;
+ var num= 4;
+ var den= 1;
+ var plus= true;
+
+ while (den < 1e7) {
+ if (plus) {
+ π+= num/den;
+ plus= false;
+ }
+ else {
+ π-= num/den;
+ plus= true;
+ }
+ den+= 2;
+ }
+ return π;
+}
+
+var piValue= pi()+ '';
+var ctr= 0;
+function cb (err, data) {
+ if (err) throw data;
+ if (data !== piValue) throw "*** BAD DATA -> "+ [piValue, data];
+ ctr++;
+ if (threads[this.id]) {
+ threads[this.id]+= 1;
+ }
+ else {
+ threads[this.id]= 1;
+ }
+}
+
+var threads= [];
+i= Math.floor(process.argv[3]) || 1e3;
+console.log("The pool will run "+ pi+ ' '+ i+ " times\n");
+while (i--) {
+ pool.any.eval("pi()", cb);
+}
+
+var t= Date.now();
+function display () {
+ var e= Date.now()- t;
+ var tps= (ctr*1e3/e).toFixed(1);
+ console.log("threadsPerSecond: "+ tps+ ', pool.pendingJobs: '+ pool.pendingJobs()+ ', pool.idleThreads: '+ pool.idleThreads());
+ console.log("distribution : "+ threads.join('+ ')+ "= "+ ctr+ "\n");
+ if (!pool.pendingJobs()) {
+ pool.destroy();
+ clearInterval(interval);
+ console.log("Done, BYE !");
+ }
+}
+
+var interval= setInterval(display, 1e3);
+
diff --git a/node_modules/webworker-threads/test/test18_pool_any_as_fast_as_possible.js b/node_modules/webworker-threads/test/test18_pool_any_as_fast_as_possible.js
new file mode 100644
index 0000000..06b2674
--- /dev/null
+++ b/node_modules/webworker-threads/test/test18_pool_any_as_fast_as_possible.js
@@ -0,0 +1,47 @@
+
+
+var T= require('webworker-threads');
+
+var i= Math.floor(process.argv[2]) || 1;
+console.log("Creating a pool of "+ i+ " threads");
+
+var pool= T.createPool(i);
+pool.all.eval(ƒ);
+
+function ƒ () { return 3.14 }
+
+var ctr= 0;
+function cb (err, data) {
+ if (err) throw data;
+ if (data !== '3.14') throw "*** BAD DATA ERROR -> "+ ['3.14', data];
+ ctr++;
+ if (threads[this.id]) {
+ threads[this.id]+= 1;
+ }
+ else {
+ threads[this.id]= 1;
+ }
+}
+
+var threads= [];
+i= Math.floor(process.argv[3]) || 4e5;
+console.log("The pool will run "+ ƒ+ ' '+ i+ " times\n");
+while (i--) {
+ pool.any.eval("ƒ()", cb);
+}
+
+var t= Date.now();
+function display () {
+ var e= Date.now()- t;
+ var tps= (ctr*1e3/e).toFixed(1);
+ console.log("threadsPerSecond: "+ tps+ ', pool.pendingJobs: '+ pool.pendingJobs()+ ', pool.idleThreads: '+ pool.idleThreads());
+ console.log("distribution : "+ threads.join('+ ')+ "= "+ ctr+ "\n");
+ if (!pool.pendingJobs()) {
+ pool.destroy();
+ clearInterval(interval);
+ console.log("Done, BYE !");
+ }
+}
+
+var interval= setInterval(display, 1e3);
+
diff --git a/node_modules/webworker-threads/test/test19_pool_emit_any_all.js b/node_modules/webworker-threads/test/test19_pool_emit_any_all.js
new file mode 100644
index 0000000..3133fd1
--- /dev/null
+++ b/node_modules/webworker-threads/test/test19_pool_emit_any_all.js
@@ -0,0 +1,37 @@
+
+
+var T= require('webworker-threads');
+
+var i= process.argv[2] || 1;
+console.log("Creating a pool of "+ i+ " threads");
+
+var pool= T.createPool(i);
+
+pool.all.eval('('+ ƒ+ ')()');
+
+pool.on('myEvent', function myEventHandler (data) {
+ console.log("Received myEvent with data -> "+ data);
+ if (data === "QUIT") {
+ setTimeout(function () { pool.destroy() }, 1e3);
+ }
+});
+
+function ƒ () {
+ thread.on('myEvent', function cb (data) {
+ thread.emit('myEvent', data);
+ });
+}
+
+
+console.log("pool.any.emit('myEvent', 'POOL.ANY')");
+pool.any.emit('myEvent', "POOL.ANY");
+
+console.log("pool.all.emit('myEvent', 'POOL.ALL')");
+pool.all.emit('myEvent', "POOL.ALL");
+
+console.log("pool.any.emit('myEvent', 'QUIT')");
+pool.any.emit('myEvent', "QUIT");
+
+process.on('exit', function () {
+ console.log("BYE !");
+});
diff --git a/node_modules/webworker-threads/test/test20_removeAllListeners.js b/node_modules/webworker-threads/test/test20_removeAllListeners.js
new file mode 100644
index 0000000..3550b0a
--- /dev/null
+++ b/node_modules/webworker-threads/test/test20_removeAllListeners.js
@@ -0,0 +1,23 @@
+
+
+var t= require('webworker-threads');
+
+function eHandler (data) {
+ console.log("TEST FAIL");
+}
+
+function boot () {
+ thread.on('e', function (data) {
+ thread.emit('e', 0);
+ });
+}
+
+o= t.create().once('e', eHandler).on('e', eHandler).eval(boot).eval('boot()').emit('e', 0).removeAllListeners();
+
+setTimeout(function () {
+ o.destroy();
+}, 1e3);
+
+process.on('exit', function () {
+ console.log("OK: Bye!");
+});
diff --git a/node_modules/webworker-threads/test/test21_emit_ping_pong_big_string.js b/node_modules/webworker-threads/test/test21_emit_ping_pong_big_string.js
new file mode 100644
index 0000000..a40ccc2
--- /dev/null
+++ b/node_modules/webworker-threads/test/test21_emit_ping_pong_big_string.js
@@ -0,0 +1,32 @@
+
+
+var i= 23; //8MB
+var big= "*";
+while (i--) big+= big;
+
+console.log("big.length is "+ big.length);
+
+var i= 0;
+var s= Date.now();
+var o= require('webworker-threads')
+ .create()
+ .eval(function boot () {
+ thread.on('b', function (data) {
+ thread.emit('a',data);
+ });
+ })
+ .eval('boot()')
+ .emit('b',big)
+ .on('a', function (data) {
+ o.emit('b',data);
+ i+= 2;
+ });
+
+
+function display () {
+ var e= Date.now()- s;
+ var ppps= (i*1e3/e).toFixed(1);
+ console.log("ping-pongs: "+ i+ ", ping-pongs-per-second: "+ ppps);
+}
+
+setInterval(display, 1e3);
diff --git a/node_modules/webworker-threads/test/test22_create_destroy_loop.js b/node_modules/webworker-threads/test/test22_create_destroy_loop.js
new file mode 100644
index 0000000..c568391
--- /dev/null
+++ b/node_modules/webworker-threads/test/test22_create_destroy_loop.js
@@ -0,0 +1,25 @@
+
+
+var T= require('webworker-threads');
+
+
+var i= 0;
+var k= 5;
+(function again () {
+ var j= k;
+ while (j--) {
+ T.create().destroy();
+ }
+ i+= k;
+ process.nextTick(again);
+})();
+
+
+var t= Date.now();
+function display () {
+ var e= Date.now()- t;
+ var tps= (i*1e3/e).toFixed(1);
+ process.stdout.write('\nt (ms) -> '+ e+ ', i -> '+ i+ ', created/destroyed-per-second -> '+ tps);
+}
+
+setInterval(display, 1e3); \ No newline at end of file
diff --git a/node_modules/webworker-threads/test/test23_create_destroy_loop.js b/node_modules/webworker-threads/test/test23_create_destroy_loop.js
new file mode 100644
index 0000000..3284e28
--- /dev/null
+++ b/node_modules/webworker-threads/test/test23_create_destroy_loop.js
@@ -0,0 +1,25 @@
+
+
+var T= require('webworker-threads');
+
+
+var i= 0;
+var k= 5;
+(function again () {
+ var j= k;
+ while (j--) {
+ T.create().destroy();
+ }
+ i+= k;
+ setTimeout(again, 5);
+})();
+
+
+var t= Date.now();
+function display () {
+ var e= Date.now()- t;
+ var tps= (i*1e3/e).toFixed(1);
+ process.stdout.write('\nt (ms) -> '+ e+ ', i -> '+ i+ ', created/destroyed-per-second -> '+ tps);
+}
+
+setInterval(display, 1e3); \ No newline at end of file
diff --git a/node_modules/webworker-threads/test/test24_puts.js b/node_modules/webworker-threads/test/test24_puts.js
new file mode 100644
index 0000000..7f52f3f
--- /dev/null
+++ b/node_modules/webworker-threads/test/test24_puts.js
@@ -0,0 +1,17 @@
+var Threads= require('webworker-threads');
+
+function cb (err, msg) {
+ if (err) {
+ process.stdout.write("["+ this.id+ "] -> "+ err+ '\n');
+ }
+ this.destroy();
+}
+
+function ƒ () {
+ puts("["+ thread.id+ "] -> puts('Hello!')\n");
+}
+
+var i= Math.abs(parseInt(process.argv[2], 10)) || 1;
+console.log('Using '+ i+ ' threads');
+
+Threads.createPool(i).all.eval(ƒ).all.eval('ƒ()', cb); \ No newline at end of file
diff --git a/node_modules/webworker-threads/test/test25_delete_puts.js b/node_modules/webworker-threads/test/test25_delete_puts.js
new file mode 100644
index 0000000..1e30fff
--- /dev/null
+++ b/node_modules/webworker-threads/test/test25_delete_puts.js
@@ -0,0 +1,23 @@
+/*
+
+If you don't want a thread to have the privilege of writing to stdout, simply delete its global puts symbol
+
+*/
+
+var Threads= require('webworker-threads');
+
+function cb (err, msg) {
+ if (err) {
+ process.stdout.write("["+ this.id+ "] -> "+ err+ '\n');
+ }
+ this.destroy();
+}
+
+function ƒ () {
+ puts("["+ thread.id+ "] -> puts('Hello!')\n");
+}
+
+var i= Math.abs(parseInt(process.argv[2], 10)) || 1;
+console.log('Using '+ i+ ' threads');
+
+Threads.createPool(i).all.eval('delete (global= this).puts; ('+ ƒ+ ')();', cb);
diff --git a/node_modules/webworker-threads/test/test26_puts_with_many_args.js b/node_modules/webworker-threads/test/test26_puts_with_many_args.js
new file mode 100644
index 0000000..51f9e12
--- /dev/null
+++ b/node_modules/webworker-threads/test/test26_puts_with_many_args.js
@@ -0,0 +1,18 @@
+var Threads= require('webworker-threads');
+
+function cb (err, msg) {
+ if (err) {
+ process.stdout.write("["+ this.id+ "] -> "+ err+ '\n');
+ }
+ this.destroy();
+}
+
+function ƒ () {
+ var prefix= "["+ thread.id+ "] -> ";
+ puts(prefix+ "1\n", prefix+ "2\n", prefix+ "3\n", prefix+ "4\n", prefix+ "5\n");
+}
+
+var i= Math.abs(parseInt(process.argv[2], 10)) || 1;
+console.log('Using '+ i+ ' threads');
+
+Threads.createPool(i).all.eval(ƒ).all.eval('ƒ()', cb); \ No newline at end of file
diff --git a/node_modules/webworker-threads/test/test27_puts_event_loop.js b/node_modules/webworker-threads/test/test27_puts_event_loop.js
new file mode 100644
index 0000000..fa1677b
--- /dev/null
+++ b/node_modules/webworker-threads/test/test27_puts_event_loop.js
@@ -0,0 +1,14 @@
+var i= parseInt(process.argv[2], 10) || 2;
+var pool= require('webworker-threads').createPool(i);
+console.log("Using "+ i+ " threads.");
+
+pool.on('again', function onAgain () {
+ this.eval('ƒ()');
+});
+
+function ƒ () {
+ puts(" ["+ thread.id+ "]"+ (++i));
+ thread.emit('again');
+}
+
+pool.all.eval(ƒ).all.eval('i=0').all.eval('ƒ()');
diff --git a/node_modules/webworker-threads/test/test28_puts_nextTick_loop.js b/node_modules/webworker-threads/test/test28_puts_nextTick_loop.js
new file mode 100644
index 0000000..513406f
--- /dev/null
+++ b/node_modules/webworker-threads/test/test28_puts_nextTick_loop.js
@@ -0,0 +1,14 @@
+var i= parseInt(process.argv[2], 10) || 2;
+var pool= require('webworker-threads').createPool(i);
+console.log("Using "+ i+ " threads.");
+
+function program () {
+ var i= 0;
+ function ƒ () {
+ puts(" ["+ thread.id+ "]"+ (++i));
+ thread.nextTick(ƒ);
+ }
+ ƒ();
+}
+
+pool.all.eval(program).all.eval('program()');
diff --git a/node_modules/webworker-threads/test/test29_puts_callback_loop.js b/node_modules/webworker-threads/test/test29_puts_callback_loop.js
new file mode 100644
index 0000000..d6cecae
--- /dev/null
+++ b/node_modules/webworker-threads/test/test29_puts_callback_loop.js
@@ -0,0 +1,14 @@
+var i= parseInt(process.argv[2], 10) || 2;
+var pool= require('webworker-threads').createPool(i);
+console.log("Using "+ i+ " threads.");
+
+function ƒ () {
+ puts(" ["+ thread.id+ "]"+ (++i));
+ //if (!(i%1e3)) gc();
+}
+
+function callback (err, data) {
+ this.eval('ƒ()', callback);
+}
+
+pool.all.eval('i=0').all.eval(ƒ).all.eval('ƒ()', callback);