Преглед изворни кода

add test for field access on null (#8452)

Dan Korostelev пре 5 година
родитељ
комит
873cbead37
1 измењених фајлова са 8 додато и 0 уклоњено
  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");
+	}
 }