Browse Source

fix benchs for non-sys targets

Aleksandr Kuzmenko 6 years ago
parent
commit
048ad50b34
3 changed files with 15 additions and 2 deletions
  1. 1 0
      tests/benchs/.gitignore
  2. 2 0
      tests/benchs/src/Macro.hx
  3. 12 2
      tests/benchs/src/Main.hx

+ 1 - 0
tests/benchs/.gitignore

@@ -0,0 +1 @@
+bin

+ 2 - 0
tests/benchs/src/Macro.hx

@@ -1,9 +1,11 @@
+#if macro
 import haxe.macro.Context;
 import haxe.macro.Context;
 import haxe.macro.Expr;
 import haxe.macro.Expr;
 import haxe.io.Path;
 import haxe.io.Path;
 
 
 using StringTools;
 using StringTools;
 using sys.FileSystem;
 using sys.FileSystem;
+#end
 
 
 class Macro {
 class Macro {
 	static var singleCaseField = null;
 	static var singleCaseField = null;

+ 12 - 2
tests/benchs/src/Main.hx

@@ -6,12 +6,22 @@ class Main {
 		var cases = Macro.getCases("cases");
 		var cases = Macro.getCases("cases");
 		var printer = new ResultPrinter();
 		var printer = new ResultPrinter();
 		function print(result:SuiteResult) {
 		function print(result:SuiteResult) {
-			Sys.println(printer.print(result));
+			println(printer.print(result));
 		}
 		}
 
 
 		for (benchCase in cases) {
 		for (benchCase in cases) {
-			Sys.println('Case: ${benchCase.name}');
+			println('Case: ${benchCase.name}');
 			benchCase.exec.run(print);
 			benchCase.exec.run(print);
 		}
 		}
 	}
 	}
+
+	static public inline function println(msg:String) {
+		#if sys
+		Sys.println(msg);
+		#elseif js
+		js.Syntax.code('console.log({0})', msg);
+		#else
+		trace(msg);
+		#end
+	}
 }
 }