Skip to content

Commit

Permalink
fix: require for Haxe 4.2 or higher
Browse files Browse the repository at this point in the history
  • Loading branch information
sebthom committed Dec 19, 2024
1 parent acbd41a commit 816092d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 42 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ jobs:
- nightly
- 4.3.6
- 4.2.5
- 4.1.5
- 4.0.5
with:
haxe-reusable-workflows-version: dev

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ within FlashDevelop.
|0.1.0 to 1.1.4 |3.2.1 or higher|
|1.2.0 to 2.0.1 |3.4.2 or higher|
|3.0.0 or higher |4.0.5 or higher|
|3.3.0 or higher |4.2.0 or higher|


## <a name="declaring-test-assertions"></a>Declaring test assertions
Expand Down
4 changes: 2 additions & 2 deletions src/hx/doctest/DocTestGenerator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ class DocTestGenerator {
// generate a new testMethod if required
if (testMethodAssertions.length == MAX_ASSERTIONS_PER_TEST_METHOD //
// for haxe-unit and munit we create a new test-method per assertion:
|| Types.isInstanceOf(doctestAdapter, HaxeUnitDocTestAdapter)
|| Types.isInstanceOf(doctestAdapter, MUnitDocTestAdapter) //
|| Std.isOfType(doctestAdapter, HaxeUnitDocTestAdapter)
|| Std.isOfType(doctestAdapter, MUnitDocTestAdapter) //
) {
testMethodsCount++;
final testMethodName = 'test${src.haxeModuleName}_${testMethodsCount}${DocTestUtils.GENERATED_TEST_METHOD_SUFFIX}';
Expand Down
9 changes: 4 additions & 5 deletions src/hx/doctest/internal/DocTestUtils.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package hx.doctest.internal;

import haxe.CallStack;
import haxe.Constraints.IMap;
import hx.doctest.internal.Types;

using StringTools;

Expand Down Expand Up @@ -42,15 +41,15 @@ class DocTestUtils {
return false;

// match regular pattern
if (Types.isInstanceOf(right, EReg))
if (Std.isOfType(right, EReg))
#if python @:nullSafety(Off) #end // TODO
return cast(right, EReg).match(Std.string(left));

if (Types.isInstanceOf(left, String))
if (Std.isOfType(left, String))
return false;

// compare arrays
if (Types.isInstanceOf(left, Array) && Types.isInstanceOf(right, Array)) {
if (Std.isOfType(left, Array) && Std.isOfType(right, Array)) {
final leftArr:Array<Dynamic> = left;
final rightArr:Array<Dynamic> = right;
if (leftArr.length == rightArr.length) {
Expand All @@ -63,7 +62,7 @@ class DocTestUtils {
}

// compare maps
if (Types.isInstanceOf(left, IMap) && Types.isInstanceOf(right, IMap)) {
if (Std.isOfType(left, IMap) && Std.isOfType(right, IMap)) {
final leftMap:IMap<Dynamic, Dynamic> = cast left;
final rightMap:IMap<Dynamic, Dynamic> = cast right;

Expand Down
14 changes: 4 additions & 10 deletions src/hx/doctest/internal/Macros.hx
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,17 @@ import haxe.macro.*;
@:noCompletion
class Macros {

#if (haxe_ver < 4)
#if (haxe_ver < 4.2)
static var __static_init(default, never) = {
throw '[ERROR] As of haxe-doctest 3.0.0, Haxe 4.x or higher is required!';
throw '[ERROR] Haxe 4.2 or higher is required!';
};
#end


macro //
public static function configureNullSafety() {
#if (haxe_ver >= 4)
haxe.macro.Compiler.nullSafety("hx.doctest",
#if (haxe_ver < 4.1)
Strict // Haxe 4.x does not have StrictThreaded
#else
StrictThreaded
#end
);
#if (haxe_ver >= 4.2)
haxe.macro.Compiler.nullSafety("hx.doctest", StrictThreaded);
#end
return macro {}
}
Expand Down
23 changes: 0 additions & 23 deletions src/hx/doctest/internal/Types.hx

This file was deleted.

0 comments on commit 816092d

Please sign in to comment.