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 // Dart test verifying that the parser does not confuse parameterized types with | 5 // Dart test verifying that the parser does not confuse parameterized types with |
6 // boolean expressions, since both contain '<'. | 6 // boolean expressions, since both contain '<'. |
7 | 7 |
8 class GenericSyntaxTest<B, C, D, E, F> { | 8 class GenericSyntaxTest<B, C, D, E, F> { |
9 GenericSyntaxTest() {} | 9 GenericSyntaxTest() {} |
10 | 10 |
11 void foo(x1, x2, x3, x4, x5) { | 11 void foo(x1, x2, x3, x4, x5) { |
12 Expect.equals(true, x1); | 12 Expect.equals(true, x1); |
13 Expect.equals(3, x2); | 13 Expect.equals(3, x2); |
14 Expect.equals(4, x3); | 14 Expect.equals(4, x3); |
15 Expect.equals(5, x4); | 15 Expect.equals(5, x4); |
16 Expect.equals(false, x5); | 16 Expect.equals(false, x5); |
17 } | 17 } |
18 | 18 |
19 void bar(x) { | 19 void bar(x) { |
20 Expect.equals(null, x()); | 20 Expect.equals(null, x(null)); |
21 } | 21 } |
22 | 22 |
23 test() { | 23 test() { |
24 var a = 1; | 24 var a = 1; |
25 var b = 2; | 25 var b = 2; |
26 var c = 3; | 26 var c = 3; |
27 var d = 4; | 27 var d = 4; |
28 var e = 5; | 28 var e = 5; |
29 var f = 6; | 29 var f = 6; |
30 var g = 7; | 30 var g = 7; |
31 var h = null; | 31 var h = null; |
32 bar(A<B, C, D, E, F> g() { return h; }); // 'A<B' starts a generic type. | 32 bar((A<B, C, D, E, F> g) { return h; }); // 'A<B' starts a generic type. |
33 foo(a<b, c, d, e, f> g); // 'a<b' is a boolean function argument. | 33 foo(a<b, c, d, e, f> g); // 'a<b' is a boolean function argument. |
34 } | 34 } |
35 | 35 |
36 static testMain() { | 36 static testMain() { |
37 new GenericSyntaxTest().test(); | 37 new GenericSyntaxTest().test(); |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 interface A<B, C, D, E, F> { | 41 interface A<B, C, D, E, F> { |
42 } | 42 } |
43 | 43 |
44 main() { | 44 main() { |
45 GenericSyntaxTest.testMain(); | 45 GenericSyntaxTest.testMain(); |
46 } | 46 } |
OLD | NEW |