瀏覽代碼

add Unit constructor

Simon Krajewski 5 月之前
父節點
當前提交
9537ebd2cd
共有 2 個文件被更改,包括 8 次插入7 次删除
  1. 3 2
      std/haxe/Unit.hx
  2. 5 5
      tests/unit/src/unitstd/haxe/Unit.unit.hx

+ 3 - 2
std/haxe/Unit.hx

@@ -25,5 +25,6 @@ package haxe;
 /**
 	A unit type which can only be `null` at run-time.
 **/
-@:nullable
-enum Unit {}
+enum Unit {
+	Unit;
+}

+ 5 - 5
tests/unit/src/unitstd/haxe/Unit.unit.hx

@@ -1,9 +1,9 @@
-var u:haxe.Unit = null;
+var u:haxe.Unit = Unit;
 Reflect.isObject(u) == false;
-Reflect.isEnumValue(u) == false;
+Reflect.isEnumValue(u) == true;
 Reflect.isFunction(u) == false;
-Reflect.compare(u, null) == 0;
-Reflect.compare(null, u) == 0;
+Reflect.compare(u, haxe.Unit.Unit.Unit) == 0;
+Reflect.compare(haxe.Unit.Unit.Unit, u) == 0;
 Reflect.compare(u, u) == 0;
 Type.getClass(u) == null;
-Type.getEnum(u) == null;
+Type.getEnum(u) == haxe.Unit;