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 // Test to stress Frog's named parameter scheme. | 5 // Test to stress Frog's named parameter scheme. |
6 | 6 |
7 main() { | 7 main() { |
8 testDollar(); | 8 testDollar(); |
9 testPsycho(); | 9 testPsycho(); |
10 } | 10 } |
(...skipping 19 matching lines...) Expand all Loading... |
30 fragments.add(']'); | 30 fragments.add(']'); |
31 return Strings.concatAll(fragments); | 31 return Strings.concatAll(fragments); |
32 } | 32 } |
33 return thing.toString(); | 33 return thing.toString(); |
34 } | 34 } |
35 | 35 |
36 // Hopefully inscrutable to static analysis. | 36 // Hopefully inscrutable to static analysis. |
37 makeTestClass(n) => [new TestClass(), new Decoy(), 'string'][n % 3]; | 37 makeTestClass(n) => [new TestClass(), new Decoy(), 'string'][n % 3]; |
38 | 38 |
39 class Decoy { | 39 class Decoy { |
40 method([a$b, b, a]) { throw const NotImplementedException(); } | 40 method([a$b, b, a]) { throw new UnimplementedError(); } |
41 psycho([$$$, $$, $]) { throw const NotImplementedException(); } | 41 psycho([$$$, $$, $]) { throw new UnimplementedError(); } |
42 } | 42 } |
43 | 43 |
44 testDollar() { | 44 testDollar() { |
45 Expect.equals('[]', format([])); | 45 Expect.equals('[]', format([])); |
46 | 46 |
47 Expect.equals('[-, -, -, -]', format(globalMethod())); | 47 Expect.equals('[-, -, -, -]', format(globalMethod())); |
48 Expect.equals('[1, 2, -, -]', format(globalMethod(a: 1, b: 2))); | 48 Expect.equals('[1, 2, -, -]', format(globalMethod(a: 1, b: 2))); |
49 Expect.equals('[1, 2, -, -]', format(globalMethod(b: 2, a: 1))); | 49 Expect.equals('[1, 2, -, -]', format(globalMethod(b: 2, a: 1))); |
50 Expect.equals('[-, -, 3, -]', format(globalMethod(a$b: 3))); | 50 Expect.equals('[-, -, 3, -]', format(globalMethod(a$b: 3))); |
51 Expect.equals('[-, -, -, 4]', format(globalMethod(a$$b: 4))); | 51 Expect.equals('[-, -, -, 4]', format(globalMethod(a$$b: 4))); |
(...skipping 23 matching lines...) Expand all Loading... |
75 Expect.equals('[1, 2, -, -]', format(t.psycho($:1, $$:2))); | 75 Expect.equals('[1, 2, -, -]', format(t.psycho($:1, $$:2))); |
76 Expect.equals('[-, -, -, 4]', format(t.psycho($$$$: 4))); | 76 Expect.equals('[-, -, -, 4]', format(t.psycho($$$$: 4))); |
77 | 77 |
78 var obj = makeTestClass(0); | 78 var obj = makeTestClass(0); |
79 | 79 |
80 Expect.equals('[1, 2, -, -]', format(obj.psycho($:1, $$:2))); | 80 Expect.equals('[1, 2, -, -]', format(obj.psycho($:1, $$:2))); |
81 Expect.equals('[-, -, -, 4]', format(obj.psycho($$$$: 4))); | 81 Expect.equals('[-, -, -, 4]', format(obj.psycho($$$$: 4))); |
82 Expect.equals('[1, 2, 3, -]', format(obj.psycho($:1, $$:2, $$$:3))); | 82 Expect.equals('[1, 2, 3, -]', format(obj.psycho($:1, $$:2, $$$:3))); |
83 Expect.equals('[1, 2, 3, -]', format(obj.psycho($$$:3, $$:2, $:1))); | 83 Expect.equals('[1, 2, 3, -]', format(obj.psycho($$$:3, $$:2, $:1))); |
84 } | 84 } |
OLD | NEW |