Kaynağa Gözat

hl: started working on unit tests compilation

Nicolas Cannasse 9 yıl önce
ebeveyn
işleme
27307831b4

+ 1 - 1
Makefile

@@ -52,7 +52,7 @@ RELDIR=../../..
 
 MODULES=ast type lexer common genxml parser typecore optimizer typeload \
 	codegen gencommon genas3 gencpp genjs genneko genphp \
-	genswf9 genswf genjava gencs genpy genhl interp dce analyzer filters typer matcher version main
+	genswf9 genswf genjava gencs genpy interp genhl dce analyzer filters typer matcher version main
 
 ADD_REVISION?=0
 

+ 94 - 19
genhl.ml

@@ -84,6 +84,8 @@ type opcode =
 	| OMul of reg * reg * reg
 	| OSDiv of reg * reg * reg
 	| OUDiv of reg * reg * reg
+	| OSMod of reg * reg * reg
+	| OUMod of reg * reg * reg
 	| OShl of reg * reg * reg
 	| OSShr of reg * reg * reg
 	| OUShr of reg * reg * reg
@@ -146,6 +148,7 @@ type opcode =
 	| OSetF32 of reg * reg * reg
 	| OSetF64 of reg * reg * reg
 	| OSetArray of reg * reg * reg
+	| OSafeCast of reg * reg
 	| OUnsafeCast of reg * reg
 	| OArraySize of reg * reg
 	| OError of string index
@@ -439,7 +442,7 @@ let rec to_type ctx t =
 
 and resolve_class ctx c pl =
 	let not_supported() =
-		failwith ("Generic type not supported : " ^ s_type (print_context()) (TInst (c,pl)))
+		failwith ("Extern type not supported : " ^ s_type (print_context()) (TInst (c,pl)))
 	in
 	match c.cl_path, pl with
 	| ([],"Array"), [t] ->
@@ -613,7 +616,7 @@ and cast_to ctx (r:reg) (t:ttype) p =
 	let rt = rtype ctx r in
 	if safe_cast rt t then r else
 	match rt, t with
-	| HVirtual _, HDyn _ ->
+	| HVirtual _, HDyn None ->
 		let tmp = alloc_tmp ctx (HDyn None) in
 		op ctx (OUnVirtual (tmp,r));
 		tmp
@@ -621,10 +624,6 @@ and cast_to ctx (r:reg) (t:ttype) p =
 		let tmp = alloc_tmp ctx (HDyn None) in
 		op ctx (OUnVirtual (tmp,r));
 		cast_to ctx tmp t p
-	| _ , HDyn _ ->
-		let tmp = alloc_tmp ctx (HDyn (Some rt)) in
-		op ctx (OToDyn (tmp, r));
-		tmp
 	| (HI8 | HI16 | HI32), (HF32 | HF64) ->
 		let tmp = alloc_tmp ctx t in
 		op ctx (OToFloat (tmp, r));
@@ -647,10 +646,18 @@ and cast_to ctx (r:reg) (t:ttype) p =
 		op ctx (OCall2 (bytes,alloc_std ctx "ftos" [HF64;HRef HI32] HBytes,cast_to ctx r HF64 p,lref));
 		op ctx (OCall3 (out,alloc_fun_path ctx ([],"String") "__alloc__",bytes,len,len));
 		out
-	| (HObj _ | HDynObj | HDyn _) , HVirtual _ ->
+	| (HObj _ | HDynObj | HDyn None) , HVirtual _ ->
 		let out = alloc_tmp ctx t in
 		op ctx (OToVirtual (out,r));
 		out
+	| HDyn None, (HObj _ | HDynObj | HFun _ | HArray _ | HDyn _) ->
+		let out = alloc_tmp ctx t in
+		op ctx (OSafeCast (out, r));
+		out
+	| _ , HDyn _ ->
+		let tmp = alloc_tmp ctx (HDyn (Some rt)) in
+		op ctx (OToDyn (tmp, r));
+		tmp
 	| _ ->
 		error ("Don't know how to cast " ^ tstr rt ^ " to " ^ tstr t) p
 
@@ -995,11 +1002,12 @@ and eval_expr ctx e =
 		) o;
 		r
 	| TNew (c,pl,el) ->
+		let c = resolve_class ctx c pl in
 		let r = alloc_tmp ctx (class_type ctx c pl) in
 		op ctx (ONew r);
 		(match c.cl_constructor with
 		| None -> ()
-		| Some { cf_expr = None } -> assert false
+		| Some { cf_expr = None } -> error (s_type_path c.cl_path ^ " does not have a constructor") e.epos
 		| Some ({ cf_expr = Some { eexpr = TFunction({ tf_expr = { eexpr = TBlock([]) } }) } }) when el = [] -> ()
 		| Some ({ cf_expr = Some cexpr } as constr) ->
 			let rl = eval_args ctx el (to_type ctx cexpr.etype) in
@@ -1099,7 +1107,7 @@ and eval_expr ctx e =
 				r
 			| _ ->
 				assert false)
-		| OpSub | OpMult | OpDiv ->
+		| OpSub | OpMult | OpDiv | OpMod ->
 			let t = to_type ctx e.etype in
 			let r = alloc_tmp ctx t in
 			(match t with
@@ -1109,6 +1117,7 @@ and eval_expr ctx e =
 				(match bop with
 				| OpSub -> op ctx (OSub (r,a,b))
 				| OpMult -> op ctx (OMul (r,a,b))
+				| OpMod -> op ctx (if unsigned e1.etype && unsigned e2.etype then OUMod (r,a,b) else OSMod (r,a,b))
 				| OpDiv -> op ctx (if unsigned e1.etype && unsigned e2.etype then OUDiv (r,a,b) else OSDiv (r,a,b))
 				| _ -> assert false);
 				r
@@ -1202,8 +1211,6 @@ and eval_expr ctx e =
 				op ctx (OMov (l, r));
 				r
 			| _ -> assert false)
-		| OpMod ->
-			assert false
 		| OpInterval | OpArrow ->
 			assert false)
 	| TUnop (Not,_,v) ->
@@ -1399,7 +1406,25 @@ and eval_expr ctx e =
 				assert false)
 	| TMeta (_,e) ->
 		eval_expr ctx e
-	| TTypeExpr _ | TFor _ | TSwitch _ | TTry _ | TBreak | TContinue | TEnumParameter _ | TCast (_,Some _) ->
+	| TFor _ ->
+		assert false (* eliminated with pf_for_to_while *)
+(*
+	| TFor (v, it, e) ->
+		let it = gen_expr ctx it in
+		let e = gen_expr ctx e in
+		let next = call p (field p (ident p "@tmp") "next") [] in
+		let next = (if v.v_capture then call p (builtin p "array") [next] else next) in
+		(EBlock
+			[(EVars ["@tmp", Some it],p);
+			(EWhile (call p (field p (ident p "@tmp") "hasNext") [],
+				(EBlock [
+					(EVars [v.v_name, Some next],p);
+					e
+				],p)
+			,NormalWhile),p)]
+		,p)
+*)
+	| TTypeExpr _ | TSwitch _ | TTry _ | TBreak | TContinue | TEnumParameter _ | TCast (_,Some _) ->
 		error ("TODO " ^ s_expr (s_type (print_context())) e) e.epos
 
 and make_fun ctx fidx f cthis =
@@ -1429,7 +1454,23 @@ and make_fun ctx fidx f cthis =
 	) f.tf_args in
 	ignore(eval_expr ctx f.tf_expr);
 	let tret = to_type ctx f.tf_type in
-	if tret = HVoid then op ctx (ORet (alloc_tmp ctx HVoid));
+	let rec has_final_jump e =
+		match e.eexpr with
+		| TBlock el -> (match List.rev el with e :: _ -> has_final_jump e | [] -> false)
+		| TParenthesis e -> has_final_jump e
+		| TReturn _ -> false
+		| _ -> true
+	in
+	if tret = HVoid then
+		op ctx (ORet (alloc_tmp ctx HVoid))
+	else if has_final_jump f.tf_expr then begin
+		let r = alloc_tmp ctx tret in
+		(match tret with
+		| HI32 | HI8 | HI16 -> op ctx (OInt (r,alloc_i32 ctx 0l))
+		| HF32 | HF64 -> op ctx (OFloat (r,alloc_float ctx 0.))
+		| _ -> op ctx (ONull r));
+		op ctx (ORet r)
+	end;
 	let f = {
 		findex = fidx;
 		ftype = HFun ((match tthis with None -> args | Some t -> t :: args), tret);
@@ -1452,6 +1493,8 @@ let generate_static ctx c f =
 					Hashtbl.add ctx.defined_funs fid ();
 					(alloc_string ctx lib, alloc_string ctx name,to_type ctx f.cf_type,fid)
 				));
+			| (Meta.Custom ":hlNative",_ ,p) :: _ ->
+				error "Invalid @:hlNative decl" p
 			| [] ->
 				make_fun ctx (alloc_fid ctx c f) (match f.cf_expr with Some { eexpr = TFunction f } -> f | _ -> assert false) None
 			| _ :: l ->
@@ -1634,7 +1677,7 @@ let check code =
 				(match rtype r with
 				| HObj _ | HDyn _ | HVirtual _ -> ()
 				| t -> error (tstr t ^ " is not nullable"))
-			| OAdd (r,a,b) | OSub (r,a,b) | OMul (r,a,b) | OSDiv (r,a,b) | OUDiv (r,a,b) ->
+			| OAdd (r,a,b) | OSub (r,a,b) | OMul (r,a,b) | OSDiv (r,a,b) | OUDiv (r,a,b) | OSMod (r,a,b) | OUMod(r,a,b) ->
 				numeric r;
 				reg a (rtype r);
 				reg b (rtype r);
@@ -1789,6 +1832,9 @@ let check code =
 			| OUnsafeCast (a,b) ->
 				ignore(rtype a);
 				ignore(rtype b);
+			| OSafeCast (a,b) ->
+				reg a (HDyn None);
+				if not (safe_cast (rtype b) (HDyn None)) then reg b HDynObj;
 			| OArraySize (r,a) ->
 				(match rtype a with
 				| HArray _ -> ()
@@ -2068,6 +2114,8 @@ let interp code =
 			| OMul (r,a,b) -> set r (numop Int32.mul ( *. ) a b)
 			| OSDiv (r,a,b) -> set r (numop (fun a b -> if b = 0l then 0l else Int32.div a b) ( /. ) a b)
 			| OUDiv (r,a,b) -> set r (iop (fun a b -> if b = 0l then 0l else assert false (* TODO : unsigned div *)) a b)
+			| OSMod (r,a,b) -> set r (numop (fun a b -> if b = 0l then 0l else Int32.rem a b) mod_float a b)
+			| OUMod (r,a,b) -> set r (iop (fun a b -> if b = 0l then 0l else assert false (* TODO : unsigned mod *)) a b)
 			| OShl (r,a,b) -> set r (iop (fun a b -> Int32.shift_left a (Int32.to_int b)) a b)
 			| OSShr (r,a,b) -> set r (iop (fun a b -> Int32.shift_right a (Int32.to_int b)) a b)
 			| OUShr (r,a,b) -> set r (iop (fun a b -> Int32.shift_right_logical a (Int32.to_int b)) a b)
@@ -2218,6 +2266,12 @@ let interp code =
 				(match get a, get i with
 				| VArray (a,_), VInt i -> a.(Int32.to_int i) <- get v
 				| _ -> assert false);
+			| OSafeCast (r, v) ->
+				let v = get v in
+				set r (match v, rtype r with
+					| VObj o, HObj c when o.oproto.pclass == c -> v
+					| _, t -> error ("Failed to cast " ^ vstr_d v ^ " to " ^ tstr t)
+				)
 			| OUnsafeCast (r,v) ->
 				set r (get v)
 			| OArraySize (r,a) ->
@@ -2358,6 +2412,7 @@ let interp code =
 		with
 			Return v -> v
 	in
+	let int = Int32.to_int in
 	let load_native lib name =
 		FNativeFun (lib ^ "@" ^ name, (match lib with
 		| "std" ->
@@ -2366,22 +2421,22 @@ let interp code =
 				(fun args -> print_endline (vstr (List.hd args)); VNull);
 			| "balloc" ->
 				(function
-				| [VInt i] -> VBytes (String.create (Int32.to_int i))
+				| [VInt i] -> VBytes (String.create (int i))
 				| _ -> assert false)
 			| "aalloc" ->
 				(function
-				| [VType t;VInt i] -> VArray (Array.create (Int32.to_int i) VNull,t)
+				| [VType t;VInt i] -> VArray (Array.create (int i) VNull,t)
 				| _ -> assert false)
 			| "ablit" ->
 				(function
 				| [VArray (dst,_); VInt dp; VArray (src,_); VInt sp; VInt len] ->
-					Array.blit src (Int32.to_int sp) dst (Int32.to_int dp) (Int32.to_int len);
+					Array.blit src (int sp) dst (int dp) (int len);
 					VNull
 				| _ -> assert false)
 			| "bblit" ->
 				(function
 				| [VBytes dst; VInt dp; VBytes src; VInt sp; VInt len] ->
-					String.blit src (Int32.to_int sp) dst (Int32.to_int dp) (Int32.to_int len);
+					String.blit src (int sp) dst (int dp) (int len);
 					VNull
 				| _ -> assert false)
 			| "itos" ->
@@ -2408,12 +2463,29 @@ let interp code =
 			| "utf8length" ->
 				(function
 				| [VBytes b; VInt start; VInt len] ->
-					VInt (Int32.of_int (UTF8.length (String.sub b (Int32.to_int start) (Int32.to_int len))))
+					VInt (Int32.of_int (UTF8.length (String.sub b (int start) (int len))))
 				| _ -> assert false)
 			| "math_sqrt" ->
 				(function
 				| [VFloat f] -> VFloat (sqrt f)
 				| _ -> assert false)
+			| "parse_int" ->
+				(function
+				| [VBytes str; VInt len] ->
+					(try
+						let i = (match Interp.parse_int (String.sub str 0 (int len)) with
+							| Interp.VInt v -> Int32.of_int v
+							| Interp.VInt32 v -> v
+							| _ -> assert false
+						) in
+						VInt i
+					with _ ->
+						VNull)
+				| _ -> assert false)
+			| "parse_float" ->
+				(function
+				| [VBytes str; VInt len] -> (try VFloat (Interp.parse_float (String.sub str 0 (int len))) with _ -> VFloat nan)
+				| _ -> assert false)
 			| _ -> (fun args -> error ("Unresolved native " ^ name)))
 		| _ ->
 			(fun args -> error ("Unresolved native " ^ name))))
@@ -2656,6 +2728,8 @@ let ostr o =
 	| OMul (r,a,b) -> Printf.sprintf "mul %d,%d,%d" r a b
 	| OSDiv (r,a,b) -> Printf.sprintf "sdiv %d,%d,%d" r a b
 	| OUDiv (r,a,b) -> Printf.sprintf "udiv %d,%d,%d" r a b
+	| OSMod (r,a,b) -> Printf.sprintf "smod %d,%d,%d" r a b
+	| OUMod (r,a,b) -> Printf.sprintf "umod %d,%d,%d" r a b
 	| OShl (r,a,b) -> Printf.sprintf "shl %d,%d,%d" r a b
 	| OSShr (r,a,b) -> Printf.sprintf "sshr %d,%d,%d" r a b
 	| OUShr (r,a,b) -> Printf.sprintf "ushr %d,%d,%d" r a b
@@ -2719,6 +2793,7 @@ let ostr o =
 	| OSetF32 (r,p,v) -> Printf.sprintf "setf32 %d,%d,%d" r p v
 	| OSetF64 (r,p,v) -> Printf.sprintf "setf64 %d,%d,%d" r p v
 	| OSetArray (a,i,v) -> Printf.sprintf "setarray %d[%d],%d" a i v
+	| OSafeCast (r,v) -> Printf.sprintf "safecast %d,%d" r v
 	| OUnsafeCast (r,v) -> Printf.sprintf "unsafecast %d,%d" r v
 	| OArraySize (r,a) -> Printf.sprintf "arraysize %d,%d" r a
 	| OError s -> Printf.sprintf "error @%d" s

+ 93 - 0
std/hl/_std/Date.hx

@@ -0,0 +1,93 @@
+/*
+ * Copyright (C)2005-2012 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+@:coreApi @:final class Date {
+
+	private var t : Int;
+
+	public function new(year : Int, month : Int, day : Int, hour : Int, min : Int, sec : Int ) : Void {
+		throw "TODO";
+	}
+
+	public function getTime() : Float {
+		throw "TODO";
+		return 0.;
+	}
+
+	public function getFullYear() : Int {
+		throw "TODO";
+		return 0;
+	}
+
+	public function getMonth() : Int {
+		throw "TODO";
+		return 0;
+	}
+
+	public function getDate() : Int {
+		throw "TODO";
+		return 0;
+	}
+
+	public function getHours() : Int {
+		throw "TODO";	
+		return 0;
+	}
+
+	public function getMinutes() : Int {
+		throw "TODO";
+		return 0;
+	}
+
+	public function getSeconds() : Int {
+		throw "TODO";
+		return 0;
+	}
+
+	public function getDay() : Int {
+		throw "TODO";
+		return 0;
+	}
+
+	@:keep public function toString():String {
+		throw "TODO";
+		return "";
+	}
+
+	public static function now() : Date {
+		throw "TODO";
+		return null;
+	}
+
+	public static function fromTime( t : Float ) : Date {
+		throw "TODO";
+		return null;
+	}
+
+	public static function fromString( s : String ) : Date {
+		throw "TODO";
+		return null;
+	}
+
+}
+
+

+ 42 - 2
std/hl/_std/Math.hx

@@ -1,3 +1,43 @@
-extern class Math {
-	@:hlNative("std","math_sqrt") static function sqrt( v : Float ) : Float;
+
+@:coreApi
+class Math {
+
+	@:hlNative("std","math_sqrt") public static function sqrt( v : Float ) : Float 			return 0.;
+	@:hlNative("std","math_abs") public static function abs( v : Float ) : Float 			return 0.;
+	@:hlNative("std","math_floor") public static function floor( v : Float ) : Int 			return 0;
+	@:hlNative("std","math_round") public static function round( v : Float ) : Int 			return 0;
+	@:hlNative("std","math_ceil") public static function ceil( v : Float ) : Int 			return 0;
+	@:hlNative("std","math_finite") public static function isFinite( v : Float ) : Bool 	return true;
+	@:hlNative("std","math_isnane") public static function isNaN( v : Float ) : Bool 		return false;
+
+	@:hlNative("std","math_ffloor") public static function ffloor( v : Float ) : Float 		return 0.;
+	@:hlNative("std","math_fround") public static function fround( v : Float ) : Float 		return 0.;
+	@:hlNative("std","math_fceil") public static function fceil( v : Float ) : Float 		return 0.;
+	
+	@:hlNative("std","math_cos") public static function cos( v : Float ) : Float 			return 0.;
+	@:hlNative("std","math_sin") public static function sin( v : Float ) : Float 			return 0.;
+	@:hlNative("std","math_exp") public static function exp( v : Float ) : Float 			return 0.;
+	@:hlNative("std","math_log") public static function log( v : Float ) : Float 			return 0.;
+	@:hlNative("std","math_tan") public static function tan( v : Float ) : Float 			return 0.;
+	@:hlNative("std","math_atan") public static function atan( v : Float ) : Float 			return 0.;
+	@:hlNative("std","math_acos") public static function acos( v : Float ) : Float 			return 0.;
+	@:hlNative("std","math_asin") public static function asin( v : Float ) : Float 			return 0.;
+	@:hlNative("std","math_pow") public static function pow( v : Float, pow : Float ) : Float 				return 0.;
+	@:hlNative("std","math_atan2") public static function atan2( a : Float, b : Float ) : Float 			return 0.;
+
+	public static function min( a : Float, b : Float ) : Float 			return a < b || isNaN(a) ? a : b;
+	public static function max( a : Float, b : Float ) : Float 			return a < b || isNaN(b) ? b : a;
+	
+	public static var PI(default,null) : Float;
+	public static var NaN(default,null) : Float;
+	public static var POSITIVE_INFINITY(default,null) : Float;
+	public static var NEGATIVE_INFINITY(default,null) : Float;
+	
+	static function __init__() : Void {
+		PI = 3.14159265359;
+		NaN = 0. / 0.;
+		POSITIVE_INFINITY = 1. / 0.;
+		NEGATIVE_INFINITY = -1. / 0.;
+	}
+	
 }

+ 25 - 0
std/hl/_std/Std.hx

@@ -23,8 +23,24 @@ import hl.types.ArrayObj;
 import hl.types.ArrayI32;
 import hl.types.ArrayF64;
 
+@:coreApi
 class Std {
 
+	public static function random( max : Int ) : Int {
+		throw "TODO:Std.random";
+		return 0;
+	}
+
+	public static function is( v : Dynamic, t : Dynamic ) : Bool {
+		throw "TODO:Std.is";
+		return false;
+	}
+
+	public static function instance<T:{},S:T>( value : T, c : Class<S> ) : S {
+		throw "TODO:Std.instance";
+		return null;
+	}
+
 	public static inline function int( v : Float ) : Int {
 		return untyped $int(v);
 	}
@@ -34,5 +50,14 @@ class Std {
 		var bytes = hl.types.Bytes.ofValue(v,new hl.types.Ref(len));
 		return @:privateAccess String.__alloc__(bytes,len,bytes.utf8Length(0,len));
 	}
+	
+	public static function parseInt( s : String ) : Null<Int> {
+		return @:privateAccess s.bytes.parseInt(s.length);
+	}
+
+	public static function parseFloat( s : String ) : Float {
+		return @:privateAccess s.bytes.parseFloat(s.length);
+	}
+
 
 }

+ 3 - 0
std/hl/_std/Sys.hx

@@ -4,4 +4,7 @@ class Sys {
 		hl.Boot.log(v);
 	}
 	
+	@:hlNative("std","sys_time") public static function time() : Float { return 0.; };
+	@:hlNative("std","sys_exit") public static function exit( code : Int ) : Void {};
+	
 }

+ 10 - 0
std/hl/types/Bytes.hx

@@ -43,6 +43,16 @@ package hl.types;
 		untyped $bsetf64(this, pos, value);
 	}
 	
+	@:hlNative("std","parse_int")
+	public function parseInt( size : Int ) : Null<Int> {
+		return null;
+	}
+	
+	@:hlNative("std","parse_float")
+	public function parseFloat( size : Int ) : Float {
+		return 0.;
+	}
+	
 	@:hlNative("std","utf8length")
 	function utf8Length( startPos : Int, bytesCount : Int ) : Int {
 		return 0;

+ 3 - 0
tests/unit/compile-hl.hxml

@@ -0,0 +1,3 @@
+compile-each.hxml
+unit.Test
+-hl bin/unit.hl

+ 1 - 1
tests/unit/src/unit/Test.hx

@@ -252,7 +252,7 @@ class Test {
 	}
 
 	static function resetTimer() {
-		#if (neko || php || cpp || java || cs || python)
+		#if (neko || php || cpp || java || cs || python || hl)
 		#else
 		if( timer != null ) timer.stop();
 		timer = new haxe.Timer(30000);

+ 2 - 2
tests/unit/src/unit/TestMisc.hx

@@ -380,14 +380,14 @@ class TestMisc extends Test {
 		eq( opt3(7.4).y, 7.4 );
 
 		eq( opt4(), 11 );
-		#if !(flash || cpp || cs || java)
+		#if !(flash || cpp || cs || java || hl)
 		eq( opt4(null), 11 );
 		#end
 
 		var opt4b : ?Int -> Null<Int> = opt4;
 		eq( opt4b(), 11 );
 		eq( opt4b(3), 4 );
-		#if !(flash || cpp || cs || java)
+		#if !(flash || cpp || cs || java || hl)
 		eq( opt4b(null), 11 );
 		#end
 

+ 2 - 2
tests/unit/src/unit/TestReflect.hx

@@ -227,8 +227,8 @@ class TestReflect extends Test {
 		eq( i.intValue, 55 );
 		var i = Type.createEmptyInstance(MyClass);
 		t( (i is MyClass) );
-		eq( i.get(), #if (flash || cpp || java || cs) 0 #else null #end );
-		eq( i.intValue, #if (flash || cpp || java || cs) 0 #else null #end );
+		eq( i.get(), #if (flash || cpp || java || cs || hl) 0 #else null #end );
+		eq( i.intValue, #if (flash || cpp || java || cs || hl) 0 #else null #end );
 		var e : MyEnum = Type.createEnum(MyEnum,__unprotect__("A"));
 		eq( e, MyEnum.A );
 		var e : MyEnum = Type.createEnum(MyEnum,__unprotect__("C"),[55,"hello"]);

+ 1 - 1
tests/unit/src/unit/TestType.hx

@@ -296,7 +296,7 @@ class TestType extends Test {
 
 		// TODO: this fails on flash 9
 		var foo = function(bar = 2) { return bar; };
-		#if flash
+		#if (flash || hl)
 		t(typeError(foo.bind(_)));
 		#else
 		var l = foo.bind(_);

+ 3 - 3
tests/unit/src/unitstd/haxe/ds/Vector.unit.hx

@@ -1,7 +1,7 @@
 var vec = new haxe.ds.Vector(3);
-var vNullInt = #if (flash || cpp || java || cs) 0 #else null #end;
-var vNullBool = #if (flash || cpp || java || cs) false #else null #end;
-var vNullFloat = #if (flash || cpp || java || cs) 0.0 #else null #end;
+var vNullInt = #if (flash || cpp || java || cs || hl) 0 #else null #end;
+var vNullBool = #if (flash || cpp || java || cs || hl) false #else null #end;
+var vNullFloat = #if (flash || cpp || java || cs || hl) 0.0 #else null #end;
 
 vec.length == 3;
 vec.get(0) == vNullInt;