OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // | 4 // |
5 // Process test program to test that invalid arguments throw exceptions. | 5 // Process test program to test that invalid arguments throw exceptions. |
6 | 6 |
7 void testNonStringPath() { | 7 void testNonStringPath() { |
8 try { | 8 try { |
9 Process p = new Process(["true"], []); | 9 Process p = new Process(["true"], []); |
10 Expect.fail("Did not throw exception"); | 10 Expect.fail("Did not throw exception"); |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 void testNonStringArgument() { | 25 void testNonStringArgument() { |
26 try { | 26 try { |
27 Process p = new Process("true", ["asdf", 1]); | 27 Process p = new Process("true", ["asdf", 1]); |
28 Expect.fail("Did not throw exception"); | 28 Expect.fail("Did not throw exception"); |
29 } catch(var e) { | 29 } catch(var e) { |
30 Expect.isTrue(e is ProcessException, "Wrong exception type: $e"); | 30 Expect.isTrue(e is ProcessException, "Wrong exception type: $e"); |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 class MyString implements String { | |
35 MyString(); | |
36 } | |
37 | |
38 void testMyStringArgument() { | |
39 Process p = new Process("true", [new MyString()]); | |
40 try { | |
41 p.start(); | |
42 Expect.fail("Did not throw exception"); | |
43 } catch(var e) { | |
44 Expect.isTrue(e is ProcessException, "Wrong exception type: $e"); | |
45 } | |
46 } | |
47 | |
48 void testMyStringPath() { | |
49 Process p = new Process(new MyString(), ['asdf']); | |
50 try { | |
51 p.start(); | |
52 Expect.fail("Did not throw exception"); | |
53 } catch(var e) { | |
54 Expect.isTrue(e is ProcessException, "Wrong exception type: $e"); | |
55 } | |
56 } | |
57 | |
58 void main() { | 34 void main() { |
59 testNonStringPath(); | 35 testNonStringPath(); |
60 testNonListArguments(); | 36 testNonListArguments(); |
61 testNonStringArgument(); | 37 testNonStringArgument(); |
62 testMyStringArgument(); | |
63 testMyStringPath(); | |
64 } | 38 } |
OLD | NEW |