2
0
Эх сурвалжийг харах

add tests for closed @:generic issues

Simon Krajewski 11 жил өмнө
parent
commit
44bb0745d7

+ 42 - 0
tests/unit/issues/Issue2086.hx

@@ -0,0 +1,42 @@
+package unit.issues;
+
+@:generic
+private class Node<T:Node<T>> extends Foo<T> {
+	public var node:T;
+	public function new(node:T) {
+		super();
+		this.node = node;
+		s += node.func();
+		s += node.super_func();
+	}
+
+	public function func() {
+		return "Node_func";
+	}
+}
+
+@:generic
+private class Foo<T> {
+	public var s:String = "";
+	public function new() { }
+	public function super_func() {
+		return "Foo_super_func";
+	}
+}
+
+private class StringNode extends Node<StringNode> {
+	public function new(s:String) {
+		super(this);
+	}
+
+	override function func() {
+		return "StringNode_func" + super.func();
+	}
+}
+
+class Issue2086 extends Test {
+	function test() {
+		var sNode = new StringNode("foo");
+		eq("StringNode_funcNode_funcFoo_super_func", sNode.s);
+	}
+}

+ 38 - 0
tests/unit/issues/Issue2581.hx

@@ -0,0 +1,38 @@
+package unit.issues;
+
+@:generic
+private interface Arrayable<T>
+{
+    public function toArray(?target:Array<T>):Array<T>;
+}
+
+@:generic
+private class KVPair<K, V>
+{
+    public var key:K;
+    public var value:V;
+
+    public function new():Void
+    {}
+}
+
+@:generic
+private class MMap<K, V> implements Arrayable<KVPair<K, V>>
+{
+    public function new():Void
+    {}
+
+    public function toArray(?target:Array<KVPair<K, V>>):Array<KVPair<K, V>>
+    {
+        if (target == null) {
+            target = new Array<KVPair<K, V>>();
+        }
+        return target;
+    }
+}
+
+class Issue2581 extends Test {
+	function test() {
+		var MMap:MMap<String, String> = new MMap<String, String>();
+	}
+}