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

Side by Side 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, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'dart:convert';
6 import 'dart:io';
7
8 import "package:expect/expect.dart";
9 import 'package:path/path.dart';
10
11 Future test(List defines, String script, Map expected, {bool fail: false}) {
12 String executable = new File(Platform.executable).fullPathSync();
13 var script_path = join(dirname(Platform.script), script);
14 var args = [];
15 args.addAll(defines);
16 args.add(script_path);
17 print(args);
18 Map fromEnviromnemt;
19 return Process.run(executable, args)
20 .then((result) {
21 print(result.stderr);
22 if (!fail) {
23 Expect.equals(0, result.exitCode);
24 print(result.stdout);
25 fromEnviromnemt = JSON.decode(result.stdout);
26 expected.forEach((key, value) {
27 Expect.equals(value, fromEnviromnemt[key]);
28 });
29 } else {
30 print(result.exitCode);
31 print(result.stdout);
32 Expect.isFalse(result.exitCode == 0);
33 }
34 });
35 }
36
37 main() {
38 //String tests.
39 test(['-Da=a', '-Db=bb', '-Dc=ccc'],
40 'from_environment_string_script.dart',
41 {'a' : 'a', 'b' : 'bb', 'c': 'ccc'})
42 .then((_) {
43 test(['-Da=a'],
44 'from_environment_string_script.dart',
45 {'a' : 'a', 'b' : '', 'c': 'default'});
46 })
47 .then((_) {
48 test(['-Da=1', '-Db=12', '-Dc=123'],
49 'from_environment_int_script.dart',
50 {'a' : 1, 'b' : 12, 'c': 123});
51 })
52 // Integer tests.
53 .then((_) {
54 test(['-Da=1', '-Db=12', '-Dc=123'],
55 'from_environment_int_script.dart',
56 {'a' : 1, 'b' : 12, 'c': 123});
57 })
58 // Boolean tests.
59 .then((_) {
60 test(['-Da=true', '-Db=false', '-Dc=yes'],
61 'from_environment_bool_script.dart',
62 {'a' : true, 'b' : false, 'c': true});
63 })
64 .then((_) {
65 test(['-Da=0', '-Db=false', '-Dc'],
66 'from_environment_bool_script.dart',
67 {'a' : true, 'b' : false, 'c': true});
68 })
69 .then((_) {
70 test(['-Da=a'],
71 'from_environment_bool_script.dart',
72 {'a' : true, 'b' : false, 'c': true});
73 })
74 // Failing tests
75 .then((_) {
76 test(['-Da'],
77 'from_environment_string_script.dart',
78 null,
79 fail: true);
80 })
81 .then((_) {
82 test(['-Da'],
83 'from_environment_int_script.dart',
84 null,
85 fail: true);
86 })
87 .then((_) {
88 test(['-Db=12', '-Dc=13'],
89 'from_environment_bool_script.dart',
90 null,
91 fail: true);
92 });
93 }
OLDNEW
« 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