Browse Source

[tests] clean up a bit

Simon Krajewski 2 năm trước cách đây
mục cha
commit
aff9c5182a

+ 0 - 76
tests/TestMakefile.hx

@@ -1,76 +0,0 @@
-class TestMakefile {
-	static public function main() {
-		Sys.setCwd("../");
-		var mlFiles = [];
-		FileSystemTools.mapFiles("./src", function(s) {
-			mlFiles.push(s);
-		}, ~/\.ml$/);
-
-		var failure = false;
-		var times = [];
-
-		function makeWithTimer(name) {
-			var start = haxe.Timer.stamp();
-			var code = make();
-			var time = haxe.Timer.stamp() - start;
-			times.push({name: name, time: time});
-			return code;
-		}
-
-		Sys.command("make", ["clean_haxe"]);
-		makeWithTimer("initial");
-
-		for (mlFile in mlFiles) {
-			Sys.command("touch", [mlFile]);
-			Sys.println('[START] $mlFile');
-			var code = makeWithTimer(mlFile);
-			if (code == 0) {
-				Sys.println('[DONE] $mlFile');
-			} else {
-				Sys.println('[ERROR] $mlFile');
-				failure = true;
-				break;
-			}
-		}
-
-		times.sort(function(t1, t2) return t1.time < t2.time ? -1 : 1);
-		var total = 0.;
-		for (time in times) {
-			Sys.println('${time.name}: ${ghettoFormatTime(time.time)}');
-			total += time.time;
-		}
-		Sys.println('Total: ${ghettoFormatTime(total)}');
-		Sys.exit(failure ? 1 : 0);
-	}
-
-	static function make() {
-		return Sys.command("make", ["LFLAGS=-c", "haxe"]);
-	}
-
-	static function ghettoFormatTime(f:Float) {
-		var s = Std.string(f);
-		return s.substr(0, s.indexOf(".") + 3);
-	}
-}
-
-class FileSystemTools {
-	static public function mapFiles(directory:String, f:String -> Void, ?match:EReg) {
-		var workList = [directory];
-		while (workList.length > 0) {
-			var current = workList.shift();
-			if (sys.FileSystem.isDirectory(current)) {
-				var files = sys.FileSystem.readDirectory(current);
-				for (file in files) {
-					switch (file) {
-						case "." | "..":
-						case _: workList.push(haxe.io.Path.join([current, file]));
-					}
-				}
-			} else {
-				if (match.match == null || match.match(current)) {
-					f(current);
-				}
-			}
-		}
-	}
-}

+ 0 - 2
tests/TestMakefile.hxml

@@ -1,2 +0,0 @@
---main TestMakefile
--neko TestMakefile.n

+ 0 - 153
tests/benchs/mandelbrot/Mandelbrot.hx

@@ -1,153 +0,0 @@
-#if (!js && !flash)
-import haxe.io.Bytes;
-#end
-
-#if anon_objects
-typedef RGB = { r:Int, g:Int, b:Int };
-typedef Complex = { i:Float, j:Float };
-#else
-class RGB
-{
-   public var r:Int;
-   public var g:Int;
-   public var b:Int;
-
-   public function new(inR:Int, inG:Int, inB:Int)
-   {
-      r = inR;
-      g = inG;
-      b = inB;
-   }
-}
-
-class Complex
-{
-   public var i:Float;
-   public var j:Float;
-   
-   public function new(inI:Float, inJ:Float)
-   {
-      i = inI;
-      j = inJ;
-   }
-}
-#end
-
-
-
-class Mandelbrot
-{
-   static inline var SIZE = 25;
-   static inline var MaxIterations = 1000;
-   static inline var MaxRad = 1<<16;
-   static inline var width = 35*SIZE;
-   static inline var height = 20*SIZE;
-
-
-   public static function main()
-   {
-      var t0 = now();
-
-      var palette = [];
-      for(i in 0...MaxIterations+1)
-         palette.push( createPalette(i/MaxIterations) );
-
-      var image = [];
-      image[ width*height-1 ] = null;
-      var outPixel = 0;
-      var scale = 0.1/SIZE;
-      for(y in 0...height)
-      { 
-         if ( (y%10)== 0)
-            trace(y);
-         for(x in 0...width)
-         {
-            var iteration = 0;
-
-            #if reduce_allocs
-            var offsetI = x*scale - 2.5;
-            var offsetJ =  y*scale - 1.0;
-            var valI = 0.0;
-            var valJ = 0.0;
-            while( valI*valI+valJ*valJ<MaxRad && iteration<MaxIterations)
-            {
-               var vi = valI;
-               valI = valI*valI - valJ*valJ + offsetI;
-               valJ = 2.0*vi*valJ + offsetJ;
-               iteration++;
-            }
-            #else
-            var offset = createComplex(x*scale - 2.5,y*scale - 1);
-            var val = createComplex(0.0,0.0);
-            while( complexLength2(val)<MaxRad && iteration<MaxIterations)
-            {
-               val = complexAdd( complexSquare(val), offset );
-               iteration++;
-            }
-            #end
-
-            image[outPixel++] = palette[iteration];
-         }
-      }
-
-      var time = now()-t0;
-      trace('Mandelbrot $width x $height : $time s');
-
-      #if (!js && !flash)
-      var header = 'P6 $width $height 255\n';
-      var buffer = Bytes.alloc(header.length + width*height*3);
-      var pos = header.length;
-      buffer.blit(0,  Bytes.ofString(header), 0, pos );
-      for(pixel in image)
-      {
-         buffer.set(pos++, pixel.r);
-         buffer.set(pos++, pixel.g);
-         buffer.set(pos++, pixel.b);
-      }
-      sys.io.File.saveBytes("mandelbrot.ppm", buffer);
-      #end
-
-   }
-
-   public static function now()
-   {
-      return haxe.Timer.stamp();
-   }
-
-   public static function complexLength2(val:Complex) : Float
-   {
-      return val.i*val.i + val.j*val.j;
-   }
-
-   public inline static function complexAdd(val0:Complex, val1:Complex)
-   {
-      return createComplex( val0.i + val1.i, val0.j + val1.j );
-   }
-
-   public inline static function complexSquare(val:Complex)
-   {
-      return createComplex(  val.i*val.i - val.j*val.j, 2.0 * val.i * val.j );
-   }
-
-
-   #if anon_objects
-   public static function createComplex(inI:Float, inJ:Float) return @:fixed { i:inI, j:inJ };
-   #else
-   inline public static function createComplex(inI:Float, inJ:Float) return new Complex(inI, inJ);
-   #end
-
-
-   public static function createPalette(inFraction:Float)
-   {
-      var r = Std.int(inFraction*255);
-      var g = Std.int((1-inFraction)*255);
-      var b = Std.int( (0.5-Math.abs(inFraction-0.5))*2*255 );
-      #if anon_objects
-      return { r:r, g:g, b:b };
-      #else
-      return new RGB(r,g,b);
-      #end
-   }
-}
-
-

+ 0 - 32
tests/benchs/mandelbrot/Readme.md

@@ -1,32 +0,0 @@
-This test has not been written for pure speed - object allocations are deliberately (over) used to measure how memory access/GC mixes with numeric processing.
-
-Each target generates 2 outputs - one that uses classes and one that uses anonymous objects, so the speed can be compared.
-
-Usage:
-```
-haxe compile-cpp.hxml
-./bin/cpp/Mandelbrot
-./bin/cpp-anon/Mandelbrot
-
-# Note - need to time externally at the moment
-haxe compile-cppia.hxml
-time haxelib run hxcpp bin/Mandelbrot.cppia
-time haxelib run hxcpp bin/Mandelbrot-anon.cppia
-
-# Time externally to get sub-second accuracy
-haxe compile-java.hxml
-time java -jar bin/java/Mandelbrot.jar
-time java -jar bin/java-anon/Mandelbrot.jar
-
-haxe compile-js.hxml
-node bin/Mandelbrot.js
-node bin/Mandelbrot-anon.js
-
-haxe compile-neko.hxml
-neko bin/Mandelbrot.n
-neko bin/Mandelbrot-anon.n
-
-haxe compile-php.hxml
-php bin/php/index.php
-php bin/php-anon/index.php
-```

+ 0 - 7
tests/benchs/mandelbrot/compile-cpp.hxml

@@ -1,7 +0,0 @@
---main Mandelbrot
--cpp bin/cpp
-
---next
---main Mandelbrot
--cpp bin/cpp-anon
--D anon_objects

+ 0 - 9
tests/benchs/mandelbrot/compile-cppia.hxml

@@ -1,9 +0,0 @@
---main Mandelbrot
--cpp bin/Mandelbrot.cppia
--D cppia
-
---next
---main Mandelbrot
--cpp bin/Mandelbrot-anon.cppia
--D cppia
--D anon_objects

+ 0 - 18
tests/benchs/mandelbrot/compile-hl.hxml

@@ -1,18 +0,0 @@
---main Mandelbrot
--hl bin/mandelbrot.hl
-
---next
---main Mandelbrot
--hl bin/mandelbrot-anon.hl
--D anon_objects
-
---next
---main Mandelbrot
--hl bin/hl/mandelbrot.c
-
---next
---main Mandelbrot
--hl bin/hl_anon/mandelbrot.c
--D anon_objects
-
-# cl.exe /Ox -I C:/GitHub/hl/src -I . mandelbrot.c C:/GitHub/hl/Release/libhl.lib

+ 0 - 7
tests/benchs/mandelbrot/compile-java.hxml

@@ -1,7 +0,0 @@
---main Mandelbrot
--java bin/java
-
---next
---main Mandelbrot
--java bin/java-anon
--D anon_objects

+ 0 - 7
tests/benchs/mandelbrot/compile-js.hxml

@@ -1,7 +0,0 @@
---main Mandelbrot
--js bin/Mandelbrot.js
-
---next
---main Mandelbrot
--js bin/Mandelbrot-anon.js
--D anon_objects

+ 0 - 7
tests/benchs/mandelbrot/compile-jvm.hxml

@@ -1,7 +0,0 @@
---main Mandelbrot
---jvm bin/Mandelbrot.jar
-
---next
---main Mandelbrot
---jvm bin/Mandelbrot-anon.jar
--D anon_objects

+ 0 - 7
tests/benchs/mandelbrot/compile-macro.hxml

@@ -1,7 +0,0 @@
---main Mandelbrot
---interp
-
---next
---main Mandelbrot
---interp
--D anon_objects

+ 0 - 7
tests/benchs/mandelbrot/compile-neko.hxml

@@ -1,7 +0,0 @@
---main Mandelbrot
--neko bin/Mandelbrot.n
-
---next
---main Mandelbrot
--neko bin/Mandelbrot-anon.n
--D anon_objects

+ 0 - 7
tests/benchs/mandelbrot/compile-php.hxml

@@ -1,7 +0,0 @@
---main Mandelbrot
--php bin/php
-
---next
---main Mandelbrot
--php bin/php-anon
--D anon_objects

+ 1 - 1
tests/benchs/src/hxbenchmark/ResultPrinter.hx

@@ -21,7 +21,7 @@ class ResultPrinter {
 				maxSampleLength = sampleLength;
 				maxSampleLength = sampleLength;
 			}
 			}
 		}
 		}
-		var best = result.cases[0].numSamples;
+		var best = Lambda.fold(result.cases, (c, max) -> max > c.numSamples ? max : c.numSamples, 0);
 		var buf = new StringBuf();
 		var buf = new StringBuf();
 		buf.add("  Suite: " + result.name + "\n");
 		buf.add("  Suite: " + result.name + "\n");
 		for (caseResult in result.cases) {
 		for (caseResult in result.cases) {

+ 0 - 4
tests/threads-old/build.hxml

@@ -1,4 +0,0 @@
--cp src
--D analyzer-optimize
--main Main
--lib utest

+ 0 - 29
tests/threads-old/res/tree1.txt

@@ -1,29 +0,0 @@
-  (2)
-  (3)
-    (4)
-    (5)
-      (6)
-    (7)
-      (8)
-    (9)
-    (10)
-      (11)
-  (12)
-    (13)
-  (14)
-    (15)
-  (16)
-    (17)
-      (18)
-      (19)
-  (20)
-    (21)
-      (22)
-        (23)
-          (24)
-          (25)
-    (26)
-    (27)
-      (28)
-        (29)
-  (30)

+ 0 - 15
tests/threads-old/src/Main.hx

@@ -1,15 +0,0 @@
-import utest.Runner;
-import utest.ui.Report;
-
-class Main {
-	static function main() {
-		var runner = new Runner();
-		runner.addCases("cases");
-		runner.onTestStart.add(test -> Sys.println("[START] " + test.fixture.target));
-		runner.onTestComplete.add(test -> Sys.println("[STOP]  " + test.fixture.target));
-		var report = Report.create(runner);
-		report.displayHeader = AlwaysShowHeader;
-		report.displaySuccessResults = NeverShowSuccessResults;
-		runner.run();
-	}
-}

+ 0 - 84
tests/threads-old/src/cases/DequeBrackets.hx

@@ -1,84 +0,0 @@
-package cases;
-
-import utest.Assert;
-import haxe.ds.GenericStack;
-import utest.ITest;
-
-class DequeBrackets implements ITest {
-	public function new() {}
-
-	/**
-		Spawns a thread to insert bracket pairs into a Deque. The opening
-		one is placed in front, the closing one in the back. This is going
-		to result in something like `([{<>}])` which we check for at the end.
-	**/
-	@:timeout(2000)
-	public function test(async:utest.Async) {
-		Thread.create(() -> {
-			var deque = new Deque();
-			var dequeMutex = new Mutex();
-			function add(open:String, close:String) {
-				dequeMutex.acquire();
-				deque.push(open);
-				deque.add(close);
-				dequeMutex.release();
-			}
-
-			var pairs = [
-				{open: "(", close: ")"},
-				{open: "[", close: "]"},
-				{open: "{", close: "}"},
-				{open: "<", close: ">"}
-			];
-			var iterationsPerThread = 100;
-
-			var lock = new Lock();
-			var self = Thread.current();
-			Thread.create(() -> {
-				for (_ in 0...pairs.length) {
-					Assert.isTrue(lock.wait());
-				}
-				self.sendMessage("done");
-			});
-			var threads = [];
-			for (pair in pairs) {
-				threads.push(Thread.create(() -> {
-					Thread.readMessage(true);
-					for (_ in 0...iterationsPerThread) {
-						add(pair.open, pair.close);
-						Sys.sleep(0.0001); // sleep a bit to increase chaos
-					}
-					lock.release();
-				}));
-			}
-			for (thread in threads) {
-				thread.sendMessage("go");
-			}
-			switch (Thread.readMessage(true)) {
-				case "done":
-				case s:
-					Assert.fail("Unexpected message: " + s);
-			}
-			var stack = new GenericStack<String>();
-			function pop() {
-				return deque.pop(false);
-			}
-			for (_ in 0...pairs.length * iterationsPerThread) {
-				stack.add(pop());
-			}
-			for (elt in stack) {
-				var expected = switch (elt) {
-					case "(": ")";
-					case "<": ">";
-					case "{": "}";
-					case "[": "]";
-					case s:
-						Assert.fail("Unexpected " + s);
-						s;
-				}
-				Assert.equals(expected, pop());
-			}
-			async.done();
-		});
-	}
-}

+ 0 - 52
tests/threads-old/src/cases/Issue3767.hx

@@ -1,52 +0,0 @@
-package cases;
-
-import utest.Assert;
-import utest.ITest;
-
-class Issue3767 implements ITest {
-	public function new() { }
-
-	#if (java || python)
-
-	function testBasicLock() {
-		var mainLock = new Lock();
-		Thread.create(() -> {
-			var lock = new Lock();
-			//it starts locked
-			Assert.isFalse(lock.wait(0.001));
-			lock.release();
-			Assert.isTrue(lock.wait(.001));
-			Assert.isFalse(lock.wait(.001));
-			Assert.isFalse(lock.wait(.001));
-
-			lock.release();
-			Assert.isTrue(lock.wait());
-			lock.release();
-			lock.release();
-			lock.release();
-			Assert.isTrue(lock.wait());
-			Assert.isTrue(lock.wait(.001));
-			Assert.isTrue(lock.wait());
-			Assert.isFalse(lock.wait(.001));
-
-			var cur = Sys.time();
-			Thread.create(function()
-			{
-				Sys.sleep(.01);
-				lock.release();
-			});
-			Assert.isTrue(lock.wait(2.0));
-			Assert.isTrue( (Sys.time() - cur) < 2 );
-			Thread.create(function()
-			{
-				Sys.sleep(.01);
-				lock.release();
-			});
-			Assert.isTrue(lock.wait());
-			mainLock.release();
-		});
-		Assert.isTrue(mainLock.wait(2.0));
-	}
-
-	#end
-}

+ 0 - 32
tests/threads-old/src/cases/Issue4878.hx

@@ -1,32 +0,0 @@
-package cases;
-
-import utest.Assert;
-import utest.ITest;
-
-class Issue4878 implements ITest {
-	public function new() { }
-
-	#if (java || python)
-
-	function test() {
-		var lock = new Lock();
-		Thread.create(() -> {
-			var mutex = new Mutex();
-			Thread.create(function() {
-				mutex.acquire();
-				mutex.acquire();
-				mutex.release();
-				Sys.sleep(.2);
-				mutex.release();
-			});
-			Sys.sleep(0.05);
-			Assert.isFalse(mutex.tryAcquire());
-			Sys.sleep(.3);
-			Assert.isTrue(mutex.tryAcquire());
-			lock.release();
-		});
-		Assert.isTrue(lock.wait(2.0));
-	}
-
-	#end
-}

+ 0 - 18
tests/threads-old/src/cases/Issue8063.hx

@@ -1,18 +0,0 @@
-package cases;
-
-import utest.Assert;
-import utest.ITest;
-
-class Issue8063 implements ITest {
-	public function new() { }
-
-	function test() {
-		var lock = new Lock();
-		Assert.isTrue(Thread.current() == Thread.current());
-		Thread.create(() -> {
-			Assert.isTrue(Thread.current() == Thread.current());
-			lock.release();
-		});
-		Assert.isTrue(lock.wait(2.0));
-	}
-}

+ 0 - 66
tests/threads-old/src/cases/Issue9863.hx

@@ -1,66 +0,0 @@
-package cases;
-
-import utest.Assert;
-import sys.thread.Thread;
-
-#if cpp
-class Issue9863 extends utest.Test {
-	public function test() {
-		Assert.pass();
-	}
-}
-#else
-
-class Issue9863 extends utest.Test {
-	static function runNative(job:()->Void) {
-		#if java
-			var t = new java.lang.Thread(new Task(job));
-			t.start();
-		#elseif cs
-			var t = new cs.system.threading.Thread(job);
-			t.Start();
-		#else
-			#error "Issue9863 is not implemented for this target"
-		#end
-	}
-
-	public function test() {
-		var childThread:Null<Thread> = null;
-		function getJob(mainThread:Thread) {
-			return () -> {
-				childThread = Thread.current();
-				mainThread.sendMessage('childThread ready');
-
-				var msg = Thread.readMessage(true);
-				Assert.equals('from main to child', msg);
-
-				mainThread.sendMessage('done');
-			}
-		}
-		runNative(getJob(Thread.current()));
-
-		var msg = Thread.readMessage(true);
-		Assert.equals('childThread ready', msg);
-
-		childThread.sendMessage('from main to child');
-
-		var msg = Thread.readMessage(true);
-		Assert.equals('done', msg);
-	}
-}
-
-#end
-
-#if java
-private class Task implements java.lang.Runnable {
-	final job:()->Void;
-
-	public function new(job:()->Void) {
-		this.job = job;
-	}
-
-	public function run() {
-		job();
-	}
-}
-#end

+ 0 - 341
tests/threads-old/src/cases/TestThreads.hx

@@ -1,341 +0,0 @@
-package cases;
-
-import utest.Assert;
-
-class TestThreads implements utest.ITest
-{
-	public function new() { }
-
-	function testSort() {
-		var lock = new Lock();
-		Thread.create(() -> {
-			doTestSort();
-			lock.release();
-		});
-		Assert.isTrue(lock.wait(40.0));
-	}
-
-	private function doTestSort()
-	{
-		var ts = new ThreadSort();
-#if java
-		ts.maxVal *= 10;
-#end
-		for (creatorWait in [.02, .05, 0])
-			for (creatorLoad in [false, true])
-				for (consumerWait in [.02,.05,0])
-					for (useTls in [false,true])
-						for (q in [new QDeque() #if java, new QLockFree()#end])
-							for (lock in [ [new DequeSemaphore(), new LockSemaphore()], [new LockSemaphore(), new DequeSemaphore() ] ])
-								{
-									ts.creatorWait = creatorWait;
-									ts.creatorLoad = creatorLoad;
-									ts.consumerWait = consumerWait;
-									ts.useTls = useTls;
-									ts.queue = q;
-									var lock1 = lock[0], lock2 = lock[1];
-									ts.lock1 = lock1;
-									ts.lock2 = lock2;
-									try
-									{
-										ts.run();
-										Assert.pass("ok");
-									}
-									catch(e:Dynamic)
-									{
-										Assert.fail('Error $e for para\\meters: $creatorWait, $creatorLoad, $consumerWait, $useTls, $q, $lock1, $lock2');
-									}
-								}
-	}
-}
-
-class ThreadSort
-{
-	//params
-	public var creatorWait:Seconds = .2;
-	//should an extra load be performed on the creator?
-	public var creatorLoad:Bool = false;
-	public var consumerWait:Seconds = 0;
-	//should an extra load be performed on the consumer?
-	public var consumerLoad:Bool = false;
-	public var useTls:Bool = false;
-
-	public var nThreads:Int = 10;
-	public var maxVal:Int = 1000;
-
-	public var queue:QueueStrategy<Int>;
-	public var lock1:SemaphoreStrategy;
-	public var lock2:SemaphoreStrategy;
-
-	public function new()
-	{
-
-	}
-
-	public function run()
-	{
-		//spawning creators
-		lock1.reset(); lock2.reset(); queue.reset();
-		lock1.setReleaseCount(nThreads);
-		lock2.setReleaseCount(nThreads);
-		var finishedMutex = new Mutex();
-		finishedMutex.acquire();
-
-		var tls = new Tls();
-		for (i in 0...nThreads)
-		{
-			Thread.create(function() {
-				tls.value = i;
-				Sys.sleep(creatorWait.secs());
-				var i = useTls ? tls.value : i;
-				for (j in 1...maxVal)
-				{
-					if (j % nThreads == i)
-					{
-						queue.add(j);
-					}
-					if (j % Std.int(maxVal / 10) == 0 && creatorLoad)
-						Sys.sleep(.01);
-				}
-				//creator thread finished
-				lock1.release();
-			});
-		}
-
-		//spawning consumers
-		if (consumerWait != 0)
-			Sys.sleep(consumerWait.secs());
-
-		var arr = [];
-		for (i in 0...nThreads)
-		{
-			var myarr = [];
-			arr.push(myarr);
-			Thread.create(function() {
-				var i = 0;
-				while(true)
-				{
-					var val = queue.pop();
-					if (val != null) {
-						myarr.push(val);
-					} else if (finishedMutex.tryAcquire()) {
-						finishedMutex.release();
-						break;
-					}
-					#if eval
-					Thread.yield(); // no system threads, we need this or the scheduler has issues
-					#end
-					if (++i % Std.int(maxVal / 10) == 0 && consumerLoad)
-						Sys.sleep(.01);
-				}
-				lock2.release();
-			});
-		}
-
-		//wait creators to finish
-		lock1.block();
-
-		//release finishedMutex
-		finishedMutex.release();
-
-		//wait consumers to finish
-		lock2.block();
-
-		//start checking
-		var mainarr = [];
-		mainarr[maxVal] = maxVal; //prealloc
-
-		for(a in arr)
-		{
-			for (a in a)
-			{
-				var val = mainarr[a];
-				if (val == a)
-					throw 'Same value detected for $val and $a';
-				mainarr[a] = a;
-			}
-		}
-
-		//no repeats, ok!
-
-		for (i in 1...mainarr.length)
-		{
-			if (i != mainarr[i])
-				throw 'No value found for $i and ${mainarr[i]}';
-		}
-	}
-}
-
-private interface SemaphoreStrategy //may be released by another thread
-{
-	function block():Void; //block until all semaphores are released
-	function release():Void;
-	function setReleaseCount(i:Int):Void;
-	function reset():Void;
-}
-
-private class DequeSemaphore implements SemaphoreStrategy
-{
-	var d:Deque<Bool>;
-	var c:Int = 0;
-
-	public function new()
-	{
-		this.d = new Deque();
-		this.c = 0;
-	}
-
-	public function block()
-	{
-		for (i in 0...c)
-		{
-			d.pop(true);
-		}
-		this.c = 0;
-	}
-
-	public function release()
-	{
-		d.push(true);
-	}
-
-	public function setReleaseCount(c:Int)
-	{
-		this.c = c;
-	}
-
-	public function reset()
-	{
-		this.d = new Deque();
-		this.c = 0;
-	}
-
-	@:keep public function toString()
-	{
-		return "DequeSemaphore";
-	}
-}
-
-private class LockSemaphore implements SemaphoreStrategy
-{
-	var l:Lock;
-	var c:Int = 0;
-
-	public function new()
-	{
-		this.l = new Lock();
-		this.l.release();
-	}
-
-	public function block()
-	{
-		for(_ in 0...c)
-		{
-			Assert.isTrue(l.wait(1.));
-		}
-		this.c = 0;
-	}
-
-	public function release()
-	{
-		this.l.release();
-	}
-
-	public function setReleaseCount(c:Int)
-	{
-		this.c = c;
-	}
-
-	public function reset()
-	{
-		this.l = new Lock();
-		this.c = 0;
-	}
-
-	@:keep public function toString()
-	{
-		return "LockSemaphore";
-	}
-}
-
-
-private interface QueueStrategy<T>
-{
-	function add(t:T):Void;
-	function pop():Null<T>; //not blocking
-	function reset():Void;
-}
-
-private class QDeque<T> implements QueueStrategy<T>
-{
-	var q:Deque<T>;
-	public function new()
-	{
-		this.q = new Deque();
-	}
-
-	public function add(t:T)
-	{
-		this.q.add(t);
-	}
-
-	public function pop():Null<T>
-	{
-		return this.q.pop(false);
-	}
-
-	public function reset()
-	{
-		this.q = new Deque();
-	}
-
-	@:keep public function toString()
-	{
-		return "QDeque";
-	}
-}
-
-#if java
-private class QLockFree<T> implements QueueStrategy<T>
-{
-	var q:java.vm.AtomicList<T>;
-
-	public function new()
-	{
-		this.q = new java.vm.AtomicList();
-	}
-
-	public function add(t:T)
-	{
-		this.q.add(t);
-	}
-
-	public function pop():Null<T>
-	{
-		return this.q.pop();
-	}
-
-	public function reset()
-	{
-		this.q = new java.vm.AtomicList();
-	}
-
-	@:keep public function toString()
-	{
-		return "QLockFree";
-	}
-}
-#end
-
-private abstract Seconds(Float) from Float
-{
-	public inline function secs():Float
-	{
-		return this;
-	}
-
-	public inline function ms():Float
-	{
-		return this * 1000;
-	}
-}

+ 0 - 181
tests/threads-old/src/cases/WeirdTreeSum.hx

@@ -1,181 +0,0 @@
-package cases;
-
-import sys.io.File;
-import utest.Assert;
-import sys.thread.Lock;
-
-using StringTools;
-class Ref<T> {
-	public var value:T;
-
-	public function new(value:T) {
-		this.value = value;
-	}
-
-	public function toString() {
-		return Std.string(value);
-	}
-}
-
-@:using(cases.WeirdTreeSum.TreeTools)
-
-enum Tree<T> {
-	Node(value:Ref<T>, children:Array<Tree<T>>);
-	Leaf(value:Ref<T>);
-}
-
-class TreeTools {
-	static public function toString<T>(tree:Tree<T>) {
-		var buf = new StringBuf();
-		function loop(tabs:String, tree:Tree<T>) {
-			switch (tree) {
-				case Leaf(value):
-					buf.add('$tabs($value)\n');
-				case Node(value, children):
-					buf.add('$tabs($value)\n');
-					for (child in children) {
-						loop(tabs + "  ", child);
-					}
-			}
-		}
-		loop("", tree);
-		return buf.toString();
-	}
-
-	static public function copy<T>(tree:Tree<T>) {
-		return switch (tree) {
-			case Leaf(ref): Leaf(new Ref(ref.value));
-			case Node(ref, children): Node(new Ref(ref.value), children.map(copy));
-		}
-	}
-}
-
-typedef TreeNode<T> = {
-	var indent:Int;
-	var children:Array<Tree<T>>;
-}
-
-class WeirdTreeSum implements utest.ITest {
-	public function new() {}
-
-	public function test() {
-		var lock = new Lock();
-		Thread.create(() -> {
-			var fileContent = File.getContent("res/tree1.txt");
-			var buf = new StringBuf();
-			buf.add("(1)\n");
-			for (i in 0...10) {
-				buf.add(fileContent + "\n");
-			}
-			var tree = parseTree(buf.toString().trim())[0];
-			compare(tree);
-			lock.release();
-		});
-		Assert.isTrue(lock.wait(2.0));
-	}
-
-	static function compare(tree:Tree<Int>) {
-		var treeSingle = tree.copy();
-		var treeMulti = tree.copy();
-		traverseSingleThreaded(treeSingle);
-		traverseMultiThreaded(treeMulti);
-		Assert.equals(treeSingle.toString(), treeMulti.toString());
-	}
-
-	static function parseTree(s:String) {
-		var split = s.split("\n");
-		var children = [];
-		var nullNode:Dynamic = null;
-		var node = {elt: {children: children, indent: -1}, next: nullNode};
-		for (offset in 0...split.length) {
-			var line = split[offset];
-			var lineIndent = line.indexOf("(");
-			var value = line.substr(lineIndent + 1, line.indexOf(")") - lineIndent - 1);
-			var ref = new Ref(Std.parseInt(value));
-			while (lineIndent <= node.elt.indent) {
-				node = node.next;
-			}
-			if (offset == split.length - 1) {
-				node.elt.children.push(Leaf(ref));
-			} else if (lineIndent >= split[offset + 1].indexOf("(")) {
-				node.elt.children.push(Leaf(ref));
-			} else {
-				var children = [];
-				node.elt.children.push(Node(ref, children));
-				node = {elt: {children: children, indent: lineIndent}, next: node};
-			}
-		}
-		return children;
-	}
-
-	static function traverseSingleThreaded(tree:Tree<Int>) {
-		return switch (tree) {
-			case Leaf(value): value.value;
-			case Node(value, children):
-				for (child in children) {
-					value.value += traverseSingleThreaded(child);
-				}
-				value.value;
-		}
-	}
-
-	/**
-		For each node, we spawn N threads where N is the number of children
-		that node has. Each thread waits for a "go" message from its parent
-		thread, and then calculates the node value recursively.
-
-		Once done, it sends a "done" message to the waiter thread, which
-		counts how many results we're still expecting. Once that number reaches
-		0, it sends "done!" to the parent thread which may then return.
-
-		This isn't meant to be fast or elegant, but tests message passing between
-		a couple thousand threads.
-	**/
-	static function traverseMultiThreaded(tree:Tree<Int>) {
-		return switch (tree) {
-			case Leaf(value): value.value;
-			case Node(value, children):
-				var self = Thread.current();
-				var todo = children.length;
-				var valueMutex = new Mutex();
-				var todoMutex = new Mutex();
-				var waiterThread = Thread.create(() -> {
-					while (true) {
-						switch (Thread.readMessage(true)) {
-							case "done":
-								todoMutex.acquire();
-								todo--;
-								todoMutex.release();
-								if (todo == 0) {
-									break;
-								}
-							case _:
-								throw "Something went wrong";
-						}
-					}
-					self.sendMessage("done!");
-				});
-				var childrenThreads = [];
-				for (child in children) {
-					var childThread = Thread.create(() -> {
-						switch (Thread.readMessage(true)) {
-							case "go":
-							case _: throw "Something went wrong";
-						}
-						valueMutex.acquire();
-						value.value += traverseMultiThreaded(child);
-						valueMutex.release();
-						waiterThread.sendMessage("done");
-					});
-					childrenThreads.push(childThread);
-				}
-				for (childThread in childrenThreads) {
-					childThread.sendMessage("go");
-				}
-				switch (Thread.readMessage(true)) {
-					case "done!": value.value;
-					case _: throw "Something went wrong";
-				}
-		}
-	}
-}

+ 0 - 5
tests/threads-old/src/import.hx

@@ -1,5 +0,0 @@
-import sys.thread.Thread;
-import sys.thread.Deque;
-import sys.thread.Lock;
-import sys.thread.Tls;
-import sys.thread.Mutex;

+ 0 - 3
tests/unit/server.bat

@@ -1,3 +0,0 @@
-@echo off
-neko remoting.n
-pause

+ 0 - 28
tests/unit/unit-js.html

@@ -1,28 +0,0 @@
-<!DOCTYPE html>
-<html>
-    <head>
-        <meta charset="utf-8">
-        <title>Haxe Tests (JS)</title>
-        <meta name="description" content="">
-        <meta name="viewport" content="width=device-width, initial-scale=1">
-    </head>
-    <body id="haxe:trace">
-		<script type="text/javascript" src="//code.jquery.com/jquery-3.3.1.min.js"></script>
-        <script type="text/javascript">
-            // http://stackoverflow.com/questions/11582512/how-to-get-url-parameters-with-javascript
-            function getURLParameter(name) {
-                return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null
-            }
-            $.ajax({
-                url: getURLParameter("js") || "bin/unit.js",
-                dataType: "script",
-                success: function() {
-                    unit.TestMain.main();
-                },
-                error: function(jqXHR, textStatus, errorThrown) {
-                    throw errorThrown;
-                }
-            });
-        </script>
-    </body>
-</html>

+ 0 - 127
tests/unit/unit.html

@@ -1,127 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
-	<title>Haxe Tests</title>
-	<style>
-body {
-  font-family: Verdana;
-  font-size: 9pt;
-}
-
-iframe {
-  border: 0; padding: 0; margin: 0;
-  width: 100%; height: 100%;
-}
-
-.label {
-  padding: 2px;
-  font-weight: bold;
-  background-color: #000000;
-  color: #ffffff;
-  text-align: center;
-}
-
-.window {
-  float:left;
-  border: 1px solid #000000;
-  margin: 0 4px 4px 0;
-}
-
-.window .cont {
-  width: 400px;
-  height: 300px;
-  overflow: auto;
-  font-family: monospace;
-  white-space: pre;
-}
-	</style>
-</head>
-<body>
-<p>Note : These tests need to be run from a local domain called <code>dev.unit-tests</code> which is running mod_neko in this directory.</p>
-<div class="window">
-  <div class="label">JavaScript</div>
-  <div id="js_container" class="cont"><iframe src="unit-js.html"></iframe></div>
-</div>
-<div class="window">
-  <div class="label">Neko</div>
-  <div id="neko_container" class="cont"><iframe src="bin/unit.n"></iframe></div>
-</div>
-<div class="window">
-  <div class="label">Lua</div>
-  <div id="lua_container" class="cont"><iframe src="bin/runexe.n?bin/lua/bin/unit.lua"></iframe></div>
-</div>
-<div class="window">
-  <div class="label">Php</div>
-  <div id="php_container" class="cont"><iframe src="bin/php/index.php"></iframe></div>
-</div>
-<div class="window">
-  <div class="label">Flash</div>
-  <object	classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
-	width="400"
-	height="300"
-	id="haxeFlash"
-	align="middle">
-    <param name="movie" value="bin/unit.swf"/>
-    <param name="allowScriptAccess" value="always" />
-    <param name="quality" value="high" />
-    <param name="scale" value="noscale" />
-    <param name="salign" value="lt" />
-    <param name="bgcolor" value="#ffffff"/>
-    <embed src="bin/unit.swf"
-      bgcolor="#ffffff"
-      width="400"
-      height="300"
-      name="haxeFlash"
-      quality="high"
-      align="middle"
-      allowScriptAccess="always"
-      type="application/x-shockwave-flash"
-      pluginspage="http://www.macromedia.com/go/getflashplayer"
-    />
-  </object>
-</div>
-<div class="window">
-  <div class="label">As3</div>
-  <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
-  width="400"
-  height="300"
-  id="haxeAs3"
-  align="middle">
-    <param name="movie" value="bin/unit9_as3.swf"/>
-    <param name="allowScriptAccess" value="always" />
-    <param name="quality" value="high" />
-    <param name="scale" value="noscale" />
-    <param name="salign" value="lt" />
-    <param name="bgcolor" value="#ffffff"/>
-    <embed src="bin/unit9_as3.swf"
-      bgcolor="#ffffff"
-      width="400"
-      height="300"
-      name="haxeAs3"
-      quality="high"
-      align="middle"
-      allowScriptAccess="always"
-      type="application/x-shockwave-flash"
-      pluginspage="http://www.macromedia.com/go/getflashplayer"
-    />
-  </object>
-</div>
-<div class="window">
-  <div class="label">CPP</div>
-  <div id="cpp_container" class="cont"><iframe src="bin/runexe.n?bin/cpp/Test-debug"></iframe></div>
-</div>
-<div class="window">
-  <div class="label">Java</div>
-  <div id="java_container" class="cont"><iframe src="bin/runjava.n"></iframe></div>
-</div>
-<div class="window">
-  <div class="label">C#</div>
-  <div id="csharp_container" class="cont"><iframe src="bin/runexe.n?bin/cs/bin/Test-debug"></iframe></div>
-</div>
-<div class="window">
-  <div class="label">C#-unsafe</div>
-  <div id="csharp_unsafe_container" class="cont"><iframe src="bin/runexe.n?cs_unsafe/bin/cs_unsafe"></iframe></div>
-</div>
-</body>
-</html>

+ 0 - 77
tests/unit/unit.hxproj

@@ -1,77 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<project version="2">
-  <!-- Output SWF options -->
-  <output>
-    <movie outputType="CustomBuild" />
-    <movie input="" />
-    <movie path="unit8.swf" />
-    <movie fps="30" />
-    <movie width="300" />
-    <movie height="300" />
-    <movie version="0" />
-    <movie minorVersion="0" />
-    <movie platform="Flash Player" />
-    <movie background="#FFFFFF" />
-  </output>
-  <!-- Other classes to be compiled into your SWF -->
-  <classpaths>
-    <class path="src" />
-  </classpaths>
-  <!-- Build options -->
-  <build>
-    <option directives="" />
-    <option flashStrict="False" />
-    <option noInlineOnDebug="False" />
-    <option mainClass="unit.Test" />
-    <option enabledebug="False" />
-    <option additional="" />
-  </build>
-  <!-- haxelib libraries -->
-  <haxelib>
-    <!-- example: <library name="..." /> -->
-  </haxelib>
-  <!-- Class files to compile (other referenced classes will automatically be included) -->
-  <compileTargets>
-    <!-- example: <compile path="..." /> -->
-  </compileTargets>
-  <!-- Assets to embed into the output SWF -->
-  <library>
-    <!-- example: <asset path="..." id="..." update="..." glyphs="..." mode="..." place="..." sharepoint="..." /> -->
-  </library>
-  <!-- Paths to exclude from the Project Explorer tree -->
-  <hiddenPaths>
-    <hidden path="as3" />
-    <hidden path="cpp" />
-    <hidden path="php" />
-    <hidden path="remoting.n" />
-    <hidden path="res1.txt" />
-    <hidden path="res2.bin" />
-    <hidden path="runcpp.n" />
-    <hidden path="unit.html" />
-    <hidden path="unit.hxml" />
-    <hidden path="unit.js" />
-    <hidden path="unit.n" />
-    <hidden path="unit8.swf" />
-    <hidden path="unit9.swf" />
-    <hidden path="unit9_as3.swf" />
-    <hidden path="unit.js.map" />
-    <hidden path="java" />
-    <hidden path="runexe.n" />
-    <hidden path="runjava.n" />
-    <hidden path="server.bat" />
-    <hidden path="obj" />
-    <hidden path="serializedValues.txt" />
-  </hiddenPaths>
-  <!-- Executed before build -->
-  <preBuildCommand>"$(CompilerPath)/haxe.exe" compile$(TargetBuild).hxml</preBuildCommand>
-  <!-- Executed after build -->
-  <postBuildCommand alwaysRun="False" />
-  <!-- Other project options -->
-  <options>
-    <option showHiddenPaths="False" />
-    <option testMovie="OpenDocument" />
-    <option testMovieCommand="" />
-  </options>
-  <!-- Plugin storage -->
-  <storage />
-</project>

+ 0 - 57
tests/unit/unit_hl.hxproj

@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<project version="2">
-  <!-- Output SWF options -->
-  <output>
-    <movie outputType="CustomBuild" />
-    <movie input="" />
-    <movie path="" />
-    <movie fps="30" />
-    <movie width="800" />
-    <movie height="600" />
-    <movie version="9" />
-    <movie minorVersion="0" />
-    <movie platform="Flash Player" />
-    <movie background="#FFFFFF" />
-  </output>
-  <!-- Other classes to be compiled into your SWF -->
-  <classpaths>
-    <class path="src" />
-  </classpaths>
-  <!-- Build options -->
-  <build>
-    <option directives="" />
-    <option flashStrict="False" />
-    <option noInlineOnDebug="False" />
-    <option mainClass="" />
-    <option enabledebug="False" />
-    <option additional="-hl main.hl" />
-  </build>
-  <!-- haxelib libraries -->
-  <haxelib>
-    <!-- example: <library name="..." /> -->
-  </haxelib>
-  <!-- Class files to compile (other referenced classes will automatically be included) -->
-  <compileTargets>
-    <!-- example: <compile path="..." /> -->
-  </compileTargets>
-  <!-- Assets to embed into the output SWF -->
-  <library>
-    <!-- example: <asset path="..." id="..." update="..." glyphs="..." mode="..." place="..." sharepoint="..." /> -->
-  </library>
-  <!-- Paths to exclude from the Project Explorer tree -->
-  <hiddenPaths>
-    <hidden path="obj" />
-  </hiddenPaths>
-  <!-- Executed before build -->
-  <preBuildCommand>haxe compile-hl.hxml -D dump</preBuildCommand>
-  <!-- Executed after build -->
-  <postBuildCommand alwaysRun="False" />
-  <!-- Other project options -->
-  <options>
-    <option showHiddenPaths="False" />
-    <option testMovie="Custom" />
-    <option testMovieCommand="" />
-  </options>
-  <!-- Plugin storage -->
-  <storage />
-</project>