From 8d03c9285c94c83471a504352359ea454caad9f9 Mon Sep 17 00:00:00 2001 From: Tess Strickland Date: Thu, 12 Dec 2024 11:44:13 +0100 Subject: [PATCH 1/3] Add entry-point pragmas for test-only code. --- testing/dart/plugin_utilities_test.dart | 2 ++ testing/dart/spawn_helper.dart | 1 + 2 files changed, 3 insertions(+) diff --git a/testing/dart/plugin_utilities_test.dart b/testing/dart/plugin_utilities_test.dart index a30c029ea073b..41f26661b82cf 100644 --- a/testing/dart/plugin_utilities_test.dart +++ b/testing/dart/plugin_utilities_test.dart @@ -9,8 +9,10 @@ import 'package:test/test.dart'; typedef StringFunction = String Function(); typedef IntFunction = int Function(); +@pragma('vm:entry-point', 'get') String top() => 'top'; +@pragma('vm:entry-point') class Foo { const Foo(); static int getInt() => 1; diff --git a/testing/dart/spawn_helper.dart b/testing/dart/spawn_helper.dart index 31d1acefd6e71..22e8281417e77 100644 --- a/testing/dart/spawn_helper.dart +++ b/testing/dart/spawn_helper.dart @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +@pragma('vm:entry-point', 'get') void main() {} @pragma('vm:entry-point') From 09cc307929a9ea4bb0ee502a757149c1e7e3a707 Mon Sep 17 00:00:00 2001 From: Tess Strickland Date: Thu, 12 Dec 2024 14:27:41 +0100 Subject: [PATCH 2/3] Add entry point annotations for the methods that are retrieved as well. --- testing/dart/plugin_utilities_test.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testing/dart/plugin_utilities_test.dart b/testing/dart/plugin_utilities_test.dart index 41f26661b82cf..88d5ad33de29d 100644 --- a/testing/dart/plugin_utilities_test.dart +++ b/testing/dart/plugin_utilities_test.dart @@ -15,7 +15,9 @@ String top() => 'top'; @pragma('vm:entry-point') class Foo { const Foo(); + @pragma('vm:entry-point') static int getInt() => 1; + @pragma('vm:entry-point') double getDouble() => 1.0; } From fd14d98b0065db24845c6edda527600f44665dc4 Mon Sep 17 00:00:00 2001 From: Tess Strickland Date: Fri, 13 Dec 2024 14:52:35 +0100 Subject: [PATCH 3/3] Reformat and move ignore comment appropriately. --- testing/dart/plugin_utilities_test.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/testing/dart/plugin_utilities_test.dart b/testing/dart/plugin_utilities_test.dart index 88d5ad33de29d..8c6392022a064 100644 --- a/testing/dart/plugin_utilities_test.dart +++ b/testing/dart/plugin_utilities_test.dart @@ -27,14 +27,16 @@ void main() { final CallbackHandle hTop = PluginUtilities.getCallbackHandle(top)!; expect(hTop, isNot(0)); expect(PluginUtilities.getCallbackHandle(top), hTop); - final StringFunction topClosure = PluginUtilities.getCallbackFromHandle(hTop)! as StringFunction; + final StringFunction topClosure = + PluginUtilities.getCallbackFromHandle(hTop)! as StringFunction; expect(topClosure(), 'top'); // Static method callback. final CallbackHandle hGetInt = PluginUtilities.getCallbackHandle(Foo.getInt)!; expect(hGetInt, isNot(0)); expect(PluginUtilities.getCallbackHandle(Foo.getInt), hGetInt); - final IntFunction getIntClosure = PluginUtilities.getCallbackFromHandle(hGetInt)! as IntFunction; + final IntFunction getIntClosure = + PluginUtilities.getCallbackFromHandle(hGetInt)! as IntFunction; expect(getIntClosure(), 1); // Instance method callbacks cannot be looked up. @@ -42,7 +44,8 @@ void main() { expect(PluginUtilities.getCallbackHandle(foo.getDouble), isNull); // Anonymous closures cannot be looked up. - final Function anon = (int a, int b) => a + b; // ignore: prefer_function_declarations_over_variables + final Function anon = // ignore: prefer_function_declarations_over_variables + (int a, int b) => a + b; expect(PluginUtilities.getCallbackHandle(anon), isNull); }); }