From 7348441514c19db0c9cf6e42b8633d9612436766 Mon Sep 17 00:00:00 2001 From: Vyacheslav Egorov Date: Tue, 28 Nov 2023 12:50:05 +0000 Subject: [PATCH] [tests] Fix language/bool/has_environment_not_new This test always fails on the VM because unlike other targets VM allows to invoke this constructor with `new`. Instead of having an always failing test change this test to test VM's current behavior. This will also allow us to catch breaking changes in the future. Closes https://github.com/dart-lang/sdk/issues/53183 R=eernst@google.com Change-Id: I4ba63dc94d2bd824df44c604b0ca1c57eb8bd559 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338124 Commit-Queue: Slava Egorov Reviewed-by: Erik Ernst --- tests/language/bool/has_environment_not_new_test.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/language/bool/has_environment_not_new_test.dart b/tests/language/bool/has_environment_not_new_test.dart index 947c6bed579..ec4a7f062a2 100644 --- a/tests/language/bool/has_environment_not_new_test.dart +++ b/tests/language/bool/has_environment_not_new_test.dart @@ -4,6 +4,14 @@ import "package:expect/expect.dart"; +const bool isVM = const bool.fromEnvironment('dart.isVM'); + main() { - Expect.throws(() => new bool.hasEnvironment("Anything")); + // On non-VM targets `new bool.hasEnvironment(...)` just throws, because it + // is only guaranted to work with `const`. However on VM it actually works. + if (!isVM) { + Expect.throws(() => new bool.hasEnvironment("Anything")); + } else { + Expect.isFalse(new bool.hasEnvironment("Anything")); + } }