Browse Source

Add test for the fix in commit 1c167d0

Tests the fix from commit 1c167d0 - Fix cancelled inline constructor method returning a not cancelled inline variable.
Mario Carbajal 5 năm trước cách đây
mục cha
commit
7dc565e633
1 tập tin đã thay đổi với 16 bổ sung0 xóa
  1. 16 0
      tests/optimization/src/TestInlineConstructors.hx

+ 16 - 0
tests/optimization/src/TestInlineConstructors.hx

@@ -8,6 +8,15 @@ class InlineClass {
 	public inline function method() {
 		return a + b + c;
 	}
+
+	public inline function cancelThis() {
+		noInline(this);
+		return [1,2];
+	}
+
+	// Used to ensure the cancelation of inlining of the object passed as argument
+	public static function noInline(a : InlineClass) {
+	}
 }
 
 class NestedInlineClass {
@@ -97,4 +106,11 @@ class TestInlineConstructors extends TestBase {
 		var b : Dynamic = new InlineClass();
 		return [a.method(1), b.method(2)];
 	}
+
+	@:js('var arr = new InlineClass().cancelThis();return [arr[0],arr[1]];')
+	static function testCancelOfReturnedObject() {
+		var a : {function cancelThis() : Array<Int>;} = new InlineClass();
+		var arr = a.cancelThis();
+		return [arr[0], arr[1]];
+	}
 }