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

Unified Diff: tests/standalone/from_environment_test.dart

Issue 50983002: Implement fromEnvironment on bool, int and String (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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/standalone/from_environment_test.dart
diff --git a/tests/standalone/from_environment_test.dart b/tests/standalone/from_environment_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..6d3fc1b21a058b38590bc2337271785a61ac0f5b
--- /dev/null
+++ b/tests/standalone/from_environment_test.dart
@@ -0,0 +1,93 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// 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 'dart:convert';
+import 'dart:io';
+
+import "package:expect/expect.dart";
+import 'package:path/path.dart';
+
+Future test(List defines, String script, Map expected, {bool fail: false}) {
+ String executable = new File(Platform.executable).fullPathSync();
+ var script_path = join(dirname(Platform.script), script);
+ var args = [];
+ args.addAll(defines);
+ args.add(script_path);
+ print(args);
+ Map fromEnviromnemt;
+ return Process.run(executable, args)
+ .then((result) {
+ print(result.stderr);
+ if (!fail) {
+ Expect.equals(0, result.exitCode);
+ print(result.stdout);
+ fromEnviromnemt = JSON.decode(result.stdout);
+ expected.forEach((key, value) {
+ Expect.equals(value, fromEnviromnemt[key]);
+ });
+ } else {
+ print(result.exitCode);
+ print(result.stdout);
+ Expect.isFalse(result.exitCode == 0);
+ }
+ });
+}
+
+main() {
+ //String tests.
+ test(['-Da=a', '-Db=bb', '-Dc=ccc'],
+ 'from_environment_string_script.dart',
+ {'a' : 'a', 'b' : 'bb', 'c': 'ccc'})
+ .then((_) {
+ test(['-Da=a'],
+ 'from_environment_string_script.dart',
+ {'a' : 'a', 'b' : '', 'c': 'default'});
+ })
+ .then((_) {
+ test(['-Da=1', '-Db=12', '-Dc=123'],
+ 'from_environment_int_script.dart',
+ {'a' : 1, 'b' : 12, 'c': 123});
+ })
+ // Integer tests.
+ .then((_) {
+ test(['-Da=1', '-Db=12', '-Dc=123'],
+ 'from_environment_int_script.dart',
+ {'a' : 1, 'b' : 12, 'c': 123});
+ })
+ // Boolean tests.
+ .then((_) {
+ test(['-Da=true', '-Db=false', '-Dc=yes'],
+ 'from_environment_bool_script.dart',
+ {'a' : true, 'b' : false, 'c': true});
+ })
+ .then((_) {
+ test(['-Da=0', '-Db=false', '-Dc'],
+ 'from_environment_bool_script.dart',
+ {'a' : true, 'b' : false, 'c': true});
+ })
+ .then((_) {
+ test(['-Da=a'],
+ 'from_environment_bool_script.dart',
+ {'a' : true, 'b' : false, 'c': true});
+ })
+ // Failing tests
+ .then((_) {
+ test(['-Da'],
+ 'from_environment_string_script.dart',
+ null,
+ fail: true);
+ })
+ .then((_) {
+ test(['-Da'],
+ 'from_environment_int_script.dart',
+ null,
+ fail: true);
+ })
+ .then((_) {
+ test(['-Db=12', '-Dc=13'],
+ 'from_environment_bool_script.dart',
+ null,
+ fail: true);
+ });
+}
« runtime/vm/object.cc ('K') | « tests/standalone/from_environment_string_script.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698