Explorar o código

add test for field access on null (#8452)

Dan Korostelev %!s(int64=5) %!d(string=hai) anos
pai
achega
873cbead37
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  1. 8 0
      tests/unit/src/unit/TestMisc.hx

+ 8 - 0
tests/unit/src/unit/TestMisc.hx

@@ -596,4 +596,12 @@ class TestMisc extends Test {
 		var s = try test() catch(e:String) e;
 		eq(s,"never call me");
 	}
+
+	static var nf1:Base = null;
+	static var nf2:{s:String} = null;
+
+	function testNullFieldAccess() {
+		eq("NPE", try nf1.s catch (e:Any) "NPE");
+		eq("NPE", try nf2.s catch (e:Any) "NPE");
+	}
 }