Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Unified Diff: tests/language/library_env_test.dart

Issue 1404183002: Add support for 'dart.library.X' environment variables in dart2js. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add more tests. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/language/library_env_test.dart
diff --git a/tests/language/library_env_test.dart b/tests/language/library_env_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d076ede53610f733112e634913e9b482453af7f2
--- /dev/null
+++ b/tests/language/library_env_test.dart
@@ -0,0 +1,87 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
Johnni Winther 2015/10/16 09:34:31 Could you (additionally) make this a unittest to a
floitsch 2015/10/16 19:05:06 Done.
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:expect/expect.dart';
+
+main() {
+ const NOT_PRESENT = null;
+
+ Expect.isTrue(const bool.fromEnvironment("dart.library.async"));
+ Expect.isTrue(const bool.fromEnvironment("dart.library.collection"));
+ Expect.isTrue(const bool.fromEnvironment("dart.library.convert"));
+ Expect.isTrue(const bool.fromEnvironment("dart.library.core"));
+ Expect.isTrue(const bool.fromEnvironment("dart.library.typed_data"));
+
+
+ bool hasHtmlSupport;
+ hasHtmlSupport = true; /// has_html_support: ok
+ hasHtmlSupport = false; /// has_no_html_support: ok
+
+ if (hasHtmlSupport != null) {
+ bool expectedResult = hasHtmlSupport ? true : NOT_PRESENT;
+
+ Expect.equals(expectedResult,
+ const bool.fromEnvironment("dart.library.html",
+ defaultValue: NOT_PRESENT));
+ Expect.equals(expectedResult,
+ const bool.fromEnvironment("dart.library.indexed_db",
+ defaultValue: NOT_PRESENT));
+ Expect.equals(expectedResult,
+ const bool.fromEnvironment("dart.library.svg",
+ defaultValue: NOT_PRESENT));
+ Expect.equals(expectedResult,
+ const bool.fromEnvironment("dart.library.web_audio",
+ defaultValue: NOT_PRESENT));
+ Expect.equals(expectedResult,
+ const bool.fromEnvironment("dart.library.web_gl",
+ defaultValue: NOT_PRESENT));
+ Expect.equals(expectedResult,
+ const bool.fromEnvironment("dart.library.web_sql",
+ defaultValue: NOT_PRESENT));
+ }
+
+ bool hasIoSupport;
+ hasIoSupport = true; /// has_io_support: ok
+ hasIoSupport = false; /// has_no_io_support: ok
+
+ if (hasIoSupport != null) {
+ bool expectedResult = hasIoSupport ? true : NOT_PRESENT;
+
+ Expect.equals(expectedResult,
+ const bool.fromEnvironment("dart.library.io",
+ defaultValue: NOT_PRESENT));
+ Expect.equals(expectedResult,
+ const bool.fromEnvironment("dart.library.developer",
+ defaultValue: NOT_PRESENT));
+ }
+
+ bool hasMirrorSupport;
+ hasMirrorSupport = true; /// has_mirror_support: ok
+ hasMirrorSupport = false; /// has_no_mirror_support: ok
+
+ if (hasMirrorSupport != null) {
+ bool expectedResult = hasMirrorSupport ? true : NOT_PRESENT;
+
+ Expect.equals(expectedResult,
+ const bool.fromEnvironment("dart.library.mirrors",
+ defaultValue: NOT_PRESENT));
+ }
+
+ Expect.equals(NOT_PRESENT,
+ const bool.fromEnvironment("dart.library.XYZ",
+ defaultValue: NOT_PRESENT));
+ Expect.equals(NOT_PRESENT,
+ const bool.fromEnvironment("dart.library.Collection",
+ defaultValue: NOT_PRESENT));
+ Expect.equals(NOT_PRESENT,
+ const bool.fromEnvironment("dart.library.converT",
+ defaultValue: NOT_PRESENT));
+ Expect.equals(NOT_PRESENT,
+ const bool.fromEnvironment("dart.library.",
+ defaultValue: NOT_PRESENT));
+ Expect.equals(NOT_PRESENT,
+ const bool.fromEnvironment("dart.library.core ",
+ defaultValue: NOT_PRESENT));
+
+}
« pkg/compiler/lib/src/apiimpl.dart ('K') | « tests/language/language_dart2js.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698