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

Unified Diff: tests/standalone/src/ProcessInvalidArgumentsTest.dart

Issue 8383037: Improve error handling in the process library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 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
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/src/ProcessInvalidArgumentsTest.dart
diff --git a/tests/standalone/src/ProcessInvalidArgumentsTest.dart b/tests/standalone/src/ProcessInvalidArgumentsTest.dart
new file mode 100644
index 0000000000000000000000000000000000000000..aeaf479846e3adc048db46bfea8255df95aca68f
--- /dev/null
+++ b/tests/standalone/src/ProcessInvalidArgumentsTest.dart
@@ -0,0 +1,64 @@
+// Copyright (c) 2011, 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.
+//
+// Process test program to test that invalid arguments throw exceptions.
+
+void testNonStringPath() {
+ try {
+ Process p = new Process(["true"], []);
+ Expect.fail("Did not throw exception");
+ } catch(var e) {
+ Expect.isTrue(e is ProcessException, "Wrong exception type: $e");
+ }
+}
+
+void testNonListArguments() {
+ try {
+ Process p = new Process("true", "asdf");
+ Expect.fail("Did not throw exception");
+ } catch(var e) {
+ Expect.isTrue(e is ProcessException, "Wrong exception type: $e");
+ }
+}
+
+void testNonStringArgument() {
+ try {
+ Process p = new Process("true", ["asdf", 1]);
+ Expect.fail("Did not throw exception");
+ } catch(var e) {
+ Expect.isTrue(e is ProcessException, "Wrong exception type: $e");
+ }
+}
+
+class MyString implements String {
+ MyString();
+}
+
+void testMyStringArgument() {
+ Process p = new Process("true", [new MyString()]);
+ try {
+ p.start();
+ Expect.fail("Did not throw exception");
+ } catch(var e) {
+ Expect.isTrue(e is ProcessException, "Wrong exception type: $e");
+ }
+}
+
+void testMyStringPath() {
+ Process p = new Process(new MyString(), ['asdf']);
+ try {
+ p.start();
+ Expect.fail("Did not throw exception");
+ } catch(var e) {
+ Expect.isTrue(e is ProcessException, "Wrong exception type: $e");
+ }
+}
+
+void main() {
+ testNonStringPath();
+ testNonListArguments();
+ testNonStringArgument();
+ testMyStringArgument();
+ testMyStringPath();
+}
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698