Quellcode durchsuchen

[swf] add test (see #8218)

Dan Korostelev vor 6 Jahren
Ursprung
Commit
e47d8c93f0

+ 6 - 1
tests/unit/compile-as3.hxml

@@ -1,4 +1,9 @@
+-cmd compc -output native_swf/lib.swc -include-sources native_swf/
+
+--next
+
 compile-each.hxml
 --main unit.TestMain
 -as3 bin/as3
--cmd mxmlc -static-link-runtime-shared-libraries=true -debug bin/as3/__main__.as --output bin/unit9_as3.swf
+-swf-lib native_swf/lib.swc
+-cmd mxmlc -include-libraries=native_swf/lib.swc -static-link-runtime-shared-libraries=true -debug bin/as3/__main__.as --output bin/unit9_as3.swf

+ 6 - 1
tests/unit/compile-flash9.hxml

@@ -1,4 +1,9 @@
+-cmd compc -output native_swf/lib.swc -include-sources native_swf/
+
+--next
+
 compile-each.hxml
 --main unit.TestMain
 --swf-version 11
--swf bin/unit9.swf
+-swf bin/unit9.swf
+-swf-lib native_swf/lib.swc

+ 1 - 0
tests/unit/native_swf/.gitignore

@@ -0,0 +1 @@
+/lib.swc

+ 17 - 0
tests/unit/native_swf/Lib.as

@@ -0,0 +1,17 @@
+package {
+	public class Lib {
+		protected var x:int = 42;
+		protected function f():String { return "hello" }
+
+		private var _i:int = 5;
+		protected function get i():int { return _i }
+		protected function set i(v:int):void { _i = v }
+
+		static protected var sx:int = 42;
+		static protected function sf():String { return "hello" }
+
+		static private var _si:int = 5;
+		static protected function get si():int { return _si }
+		static protected function set si(v:int):void { _si = v }
+	}
+}

+ 4 - 0
tests/unit/native_swf/Lib2.as

@@ -0,0 +1,4 @@
+package {
+	public class Lib2 extends Lib {
+	}
+}

+ 56 - 0
tests/unit/src/unit/issues/Issue8218.hx

@@ -0,0 +1,56 @@
+package unit.issues;
+
+class Issue8218 extends unit.Test {
+	#if flash
+	function test() {
+		new Child(this);
+	}
+	#end
+}
+
+#if flash
+@:access(unit.Test)
+private class Child extends Lib2 {
+	public function new(test:unit.Test) {
+		super();
+
+		// this. protected access
+		test.eq(x, 42);
+		x = 50;
+		test.eq(x, 50);
+
+		test.eq(i, 5);
+		i = 10;
+		test.eq(i, 10);
+
+		test.eq(f(), "hello");
+		test.eq(call(f), "hello");
+
+		// super. protected access
+		test.eq(super.x, 50);
+		super.x = 55;
+		test.eq(super.x, 55);
+
+		test.eq(super.i, 10);
+		super.i = 15;
+		test.eq(super.i, 15);
+
+		test.eq(super.f(), "hello");
+
+		// static protected access
+		test.eq(Lib.sx, 42);
+		Lib.sx = 50;
+		test.eq(Lib.sx, 50);
+
+		test.eq(Lib.si, 5);
+		Lib.si = 10;
+		test.eq(Lib.si, 10);
+
+		test.eq(Lib.sf(), "hello");
+	}
+
+	static function call(f:()->String):String {
+		return f();
+	}
+}
+#end