Browse Source

[tests] patch funny Vector test

Simon Krajewski 2 năm trước cách đây
mục cha
commit
5b6b76ea2d
1 tập tin đã thay đổi với 14 bổ sung0 xóa
  1. 14 0
      tests/server/test/templates/issues/Issue10986/Vector.hx

+ 14 - 0
tests/server/test/templates/issues/Issue10986/Vector.hx

@@ -3,6 +3,12 @@ package haxe.ds;
 private typedef VectorData<T> = java.NativeArray<T>
 
 abstract Vector<T>(VectorData<T>) {
+	public var length(get, never):Int;
+
+	inline function get_length():Int {
+		return this.length;
+	}
+
 	extern overload public inline function new(length:Int) {
 		this = new java.NativeArray(length);
 	}
@@ -15,6 +21,14 @@ abstract Vector<T>(VectorData<T>) {
 		// trace("uncomment me");
 	}
 
+	@:op([]) public inline function get(index:Int):T {
+		return this[index];
+	}
+
+	@:op([]) public inline function set(index:Int, val:T):T {
+		return this[index] = val;
+	}
+
 	public static function blit<T>(src:Vector<T>, srcPos:Int, dest:Vector<T>, destPos:Int, len:Int):Void {}
 
 	static public function fromData<T>(data:VectorData<T>):Vector<T>