[dart:io] Fix failure on Interent_address_test on macOS

Fixes the failure caused by https://dart-review.googlesource.com/c/sdk/+/155840

log: https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket.appspot.com/8872034801609634816/+/steps/test_results/0/logs/new_test_failures__logs_/0

Change-Id: I80f6ed4092f1a2528b463b1310ae9e857a2df553
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158485
Reviewed-by: Zichang Guo <zichangguo@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
diff --git a/tests/standalone/io/internet_address_test.dart b/tests/standalone/io/internet_address_test.dart
index 6671b92..306affc 100644
--- a/tests/standalone/io/internet_address_test.dart
+++ b/tests/standalone/io/internet_address_test.dart
@@ -210,9 +210,13 @@
 }
 
 void testInvalidScopedId() {
-  Expect.throws<ArgumentError>(() => InternetAddress('::1%invalid'), (error) {
-    return error.toString().contains('scope ID');
-  });
+  // macOS will not throw an error.
+  try {
+    InternetAddress('::1%invalid');
+  } catch (e) {
+    Expect.type<ArgumentError>(e);
+    Expect.isTrue(e.toString().contains('scope ID'));
+  }
 }
 
 void main() {
diff --git a/tests/standalone_2/io/internet_address_test.dart b/tests/standalone_2/io/internet_address_test.dart
index 47fc491..e7af9cd 100644
--- a/tests/standalone_2/io/internet_address_test.dart
+++ b/tests/standalone_2/io/internet_address_test.dart
@@ -209,9 +209,13 @@
 }
 
 void testInvalidScopedId() {
-  Expect.throws<ArgumentError>(() => InternetAddress('::1%invalid'), (error) {
-    return error.toString().contains('scope ID');
-  });
+  // macOS will not throw an error.
+  try {
+    InternetAddress('::1%invalid');
+  } catch (e) {
+    Expect.type<ArgumentError>(e);
+    Expect.isTrue(e.toString().contains('scope ID'));
+  }
 }
 
 void main() {