Skip to content

Commit

Permalink
Fix tests for 4.3 and make use of getConfiguration.
Browse files Browse the repository at this point in the history
  • Loading branch information
back2dos committed Apr 6, 2023
1 parent c400f5a commit 2471637
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
6 changes: 3 additions & 3 deletions haxe_libraries/tink_core.hxml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# @install: lix --silent download "gh://github.com/haxetink/tink_core#abee932c4e724517090238b6527eac28874c0354" into tink_core/1.27.1/github/abee932c4e724517090238b6527eac28874c0354
-cp ${HAXE_LIBCACHE}/tink_core/1.27.1/github/abee932c4e724517090238b6527eac28874c0354/src
-D tink_core=1.27.1
# @install: lix --silent download "haxelib:/tink_core#2.1.0" into tink_core/2.1.0/haxelib
-cp ${HAXE_LIBCACHE}/tink_core/2.1.0/haxelib/src
-D tink_core=2.1.0
21 changes: 14 additions & 7 deletions src/tink/MacroApi.hx
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,22 @@ class MacroApi {

static var MAIN_CANDIDATES = ['-main', '-x', '--run'];
static public function getMainClass():Option<String> {
var args = Sys.args();

for (c in MAIN_CANDIDATES)
switch args.indexOf(c) {
case -1:
case v: return Some(args[v+1]);
#if (haxe_ver >= 4.3)
return switch haxe.macro.Compiler.getConfiguration().mainClass {
case null: None;
case p: Some(p.pack.concat([p.name]).join('.'));
}
#else
var args = Sys.args();

for (c in MAIN_CANDIDATES)
switch args.indexOf(c) {
case -1:
case v: return Some(args[v+1]);
}

return None;
return None;
#end
}

@:persistent static var idCounter = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/tink/macro/Types.hx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class Types {
static public function deduceCommonType(types:Array<Type>):Outcome<Type, Error> {
var exprs = types.map(function(t) {
var ct = t.toComplex();
return macro (null:$ct);
return macro (cast null:$ct);
});

return switch (macro $a{exprs}).typeof() {
Expand Down
4 changes: 3 additions & 1 deletion tests/Base.hx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ abstract PhysicalType<T>(Either<Class<T>, Enum<T>>) {
}
//TODO: this helper should go somewhere
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) {
currentTest.done = true;
currentTest.success = false;
Expand Down
4 changes: 1 addition & 3 deletions tests/Positions.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import haxe.macro.Expr;
using tink.MacroApi;

class Positions extends Base {
function stringCompare<A>(v1:A, v2:A)
assertEquals(Std.string(v1), Std.string(v2));

function testSanitize() {
var p:Position = null;
Expand All @@ -19,6 +17,6 @@ class Positions extends Base {
function testBlank() {
var p:Position = null;
var t = p.makeBlankType();
stringCompare('TMono(<mono>)', cast t.toType().sure());
stringCompare('TMono(<mono>)', cast t.toType().sure().reduce());
}
}

0 comments on commit 2471637

Please sign in to comment.