Fix tests for 4.3 and make use of getConfiguration.

This commit is contained in:
Juraj Kirchheim
2023-04-06 06:41:28 +00:00
parent c400f5af51
commit 2471637905
5 changed files with 22 additions and 15 deletions

View File

@@ -1,3 +1,3 @@
# @install: lix --silent download "gh://github.com/haxetink/tink_core#abee932c4e724517090238b6527eac28874c0354" into tink_core/1.27.1/github/abee932c4e724517090238b6527eac28874c0354 # @install: lix --silent download "haxelib:/tink_core#2.1.0" into tink_core/2.1.0/haxelib
-cp ${HAXE_LIBCACHE}/tink_core/1.27.1/github/abee932c4e724517090238b6527eac28874c0354/src -cp ${HAXE_LIBCACHE}/tink_core/2.1.0/haxelib/src
-D tink_core=1.27.1 -D tink_core=2.1.0

View File

@@ -33,15 +33,22 @@ class MacroApi {
static var MAIN_CANDIDATES = ['-main', '-x', '--run']; static var MAIN_CANDIDATES = ['-main', '-x', '--run'];
static public function getMainClass():Option<String> { static public function getMainClass():Option<String> {
var args = Sys.args(); #if (haxe_ver >= 4.3)
return switch haxe.macro.Compiler.getConfiguration().mainClass {
for (c in MAIN_CANDIDATES) case null: None;
switch args.indexOf(c) { case p: Some(p.pack.concat([p.name]).join('.'));
case -1:
case v: return Some(args[v+1]);
} }
#else
var args = Sys.args();
return None; for (c in MAIN_CANDIDATES)
switch args.indexOf(c) {
case -1:
case v: return Some(args[v+1]);
}
return None;
#end
} }
@:persistent static var idCounter = 0; @:persistent static var idCounter = 0;

View File

@@ -214,7 +214,7 @@ class Types {
static public function deduceCommonType(types:Array<Type>):Outcome<Type, Error> { static public function deduceCommonType(types:Array<Type>):Outcome<Type, Error> {
var exprs = types.map(function(t) { var exprs = types.map(function(t) {
var ct = t.toComplex(); var ct = t.toComplex();
return macro (null:$ct); return macro (cast null:$ct);
}); });
return switch (macro $a{exprs}).typeof() { return switch (macro $a{exprs}).typeof() {

View File

@@ -29,7 +29,9 @@ abstract PhysicalType<T>(Either<Class<T>, Enum<T>>) {
} }
//TODO: this helper should go somewhere //TODO: this helper should go somewhere
class Base extends TestCase { class Base extends TestCase {
function stringCompare<A>(v1:A, v2:A, ?pos)
assertEquals(Std.string(v1), Std.string(v2), pos);
function fail(msg:String, ?c : PosInfos) { function fail(msg:String, ?c : PosInfos) {
currentTest.done = true; currentTest.done = true;
currentTest.success = false; currentTest.success = false;

View File

@@ -6,8 +6,6 @@ import haxe.macro.Expr;
using tink.MacroApi; using tink.MacroApi;
class Positions extends Base { class Positions extends Base {
function stringCompare<A>(v1:A, v2:A)
assertEquals(Std.string(v1), Std.string(v2));
function testSanitize() { function testSanitize() {
var p:Position = null; var p:Position = null;
@@ -19,6 +17,6 @@ class Positions extends Base {
function testBlank() { function testBlank() {
var p:Position = null; var p:Position = null;
var t = p.makeBlankType(); var t = p.makeBlankType();
stringCompare('TMono(<mono>)', cast t.toType().sure()); stringCompare('TMono(<mono>)', cast t.toType().sure().reduce());
} }
} }