Prechádzať zdrojové kódy

[tests] small cleanup

Rudy Ges 7 mesiacov pred
rodič
commit
9ae3a10a42

+ 5 - 13
tests/server/test/templates/csSafeTypeBuilding/Macro.macro.hx

@@ -11,23 +11,19 @@ class Macro {
 
 
 	@:persistent static var generated = new Map<String, Bool>();
 	@:persistent static var generated = new Map<String, Bool>();
 
 
-	#if config.getType
-	static function isAlive(name:String):Bool {
+	static function isAlive(name:String, ct:ComplexType, pos:Position):Bool {
 		// Null check is just there to make it a one liner
 		// Null check is just there to make it a one liner
 		// Basically returning true if no exception is caught
 		// Basically returning true if no exception is caught
+		#if config.getType
 		return try Context.getType(name) != null
 		return try Context.getType(name) != null
 			catch(s:String) {
 			catch(s:String) {
 				if (s != 'Type not found \'$name\'') throw s;
 				if (s != 'Type not found \'$name\'') throw s;
 				false;
 				false;
 			};
 			};
-	}
-	#else
-	static function isAlive(ct:ComplexType, pos:Position):Bool {
-		// Null check is just there to make it a one liner
-		// Basically returning true if no exception is caught
+		#else
 		return try Context.resolveType(ct, pos) != null catch(e) false;
 		return try Context.resolveType(ct, pos) != null catch(e) false;
+		#end
 	}
 	}
-	#end
 
 
 	public static function buildFoo() {
 	public static function buildFoo() {
 		var from = '[${Context.getLocalModule()}] ';
 		var from = '[${Context.getLocalModule()}] ';
@@ -41,11 +37,7 @@ class Macro {
 				var ct = TPath({pack: [], name: key});
 				var ct = TPath({pack: [], name: key});
 
 
 				if (generated.exists(key)) {
 				if (generated.exists(key)) {
-					#if config.getType
-					if (isAlive(key)) {
-					#else
-					if (isAlive(ct, pos)) {
-					#end
+					if (isAlive(key, ct, pos)) {
 						print('Reusing previously generated type for $key.');
 						print('Reusing previously generated type for $key.');
 						return ct;
 						return ct;
 					}
 					}