[test] Fix some tests for Dart2Wasm.
* bool_from_environment_test is updated with the correct check.
* env_test is updated to consolidate some of the test cases so that it
has the correct behavior on all backends.
Change-Id: I1cb2d7f3ddd7042b26eda4fee2616aa47a55bd74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267221
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
diff --git a/pkg/expect/lib/config.dart b/pkg/expect/lib/config.dart
index 5229645..baf5107 100644
--- a/pkg/expect/lib/config.dart
+++ b/pkg/expect/lib/config.dart
@@ -31,3 +31,6 @@
bool get isVmAotConfiguration {
return _configuration.compiler == Compiler.dartkp;
}
+
+bool get isDart2WasmConfiguration =>
+ _configuration.compiler == Compiler.dart2wasm;
diff --git a/tests/corelib/bool_from_environment_test.dart b/tests/corelib/bool_from_environment_test.dart
index 5d01bde..a5f6856 100644
--- a/tests/corelib/bool_from_environment_test.dart
+++ b/tests/corelib/bool_from_environment_test.dart
@@ -4,6 +4,7 @@
// SharedOptions=-Da=true -Db=false -Dc=NOTBOOL -Dd=True
import "package:expect/expect.dart";
+import 'package:expect/config.dart';
main() {
Expect.isTrue(const bool.fromEnvironment('a'));
@@ -11,5 +12,9 @@
Expect.isTrue(const bool.fromEnvironment('c', defaultValue: true));
Expect.isFalse(const bool.fromEnvironment('c', defaultValue: false));
Expect.isFalse(const bool.fromEnvironment('d', defaultValue: false));
- Expect.equals(const bool.fromEnvironment('dart.isVM'), !identical(1.0, 1));
+ Expect.equals(
+ const bool.fromEnvironment('dart.isVM'),
+ !isDart2jsConfiguration &&
+ !isDdcConfiguration &&
+ !isDart2WasmConfiguration);
}
diff --git a/tests/language/library/env_test.dart b/tests/language/library/env_test.dart
index 3dc36dd..6539c22 100644
--- a/tests/language/library/env_test.dart
+++ b/tests/language/library/env_test.dart
@@ -21,9 +21,9 @@
const bool.fromEnvironment("dart.library._internal",
defaultValue: NOT_PRESENT));
+ bool htmlSupportExpected = isDart2jsConfiguration || isDdcConfiguration;
bool? hasHtmlSupport;
- hasHtmlSupport = true; //# has_html_support: ok
- hasHtmlSupport = false; //# has_no_html_support: ok
+ hasHtmlSupport = htmlSupportExpected; //# has_html_support: ok
if (hasHtmlSupport != null) {
bool expectedResult = hasHtmlSupport ? true : NOT_PRESENT;
@@ -50,9 +50,12 @@
defaultValue: NOT_PRESENT));
}
+ bool ioSupportExpected = !isDart2jsConfiguration &&
+ !isDdcConfiguration &&
+ !isVmAotConfiguration &&
+ !isDart2WasmConfiguration;
bool? hasIoSupport;
- hasIoSupport = true; //# has_io_support: ok
- hasIoSupport = false; //# has_no_io_support: ok
+ hasIoSupport = ioSupportExpected; //# has_io_support: ok
if (hasIoSupport != null) {
// Web platforms override 'dart.library.io' to return "false".
@@ -63,7 +66,7 @@
}
bool hasMirrorSupport = !isDart2jsConfiguration &&
- !isDdcConfiguration && !isVmAotConfiguration;
+ !isDdcConfiguration && !isVmAotConfiguration && !isDart2WasmConfiguration;
Expect.equals(
hasMirrorSupport,
const bool.fromEnvironment("dart.library.mirrors",