OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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 library named_constructor_test; | 5 library named_constructor_test; |
6 | 6 |
7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 import 'named_constructor_lib.dart' as prefix; | 8 import 'named_constructor_lib.dart' as prefix; |
9 | 9 |
10 class Class<T> { | 10 class Class<T> { |
11 final int value; | 11 final int value; |
12 Class() : value = 0; | 12 Class() : value = 0; |
13 Class.named() : value = 1; | 13 Class.named() : value = 1; |
14 } | 14 } |
15 | 15 |
16 void main() { | 16 void main() { |
17 Expect.equals(0, new Class().value); | 17 Expect.equals(0, new Class().value); |
18 Expect.equals(0, new Class<int>().value); | 18 Expect.equals(0, new Class<int>().value); |
19 | 19 |
20 Expect.equals(1, new Class.named().value); | 20 Expect.equals(1, new Class.named().value); |
21 Expect.equals(1, new Class<int>.named().value); | 21 Expect.equals(1, new Class<int>.named().value); |
22 // 'Class.named' is not a type: | 22 // 'Class.named' is not a type: |
23 Expect.equals(1, new Class.named<int>().value); /// 01: runtime error | 23 Expect.equals(1, new Class.named<int>().value); //# 01: runtime error |
24 // 'Class<int>.named<int>' doesn't fit the grammar syntax T.id: | 24 // 'Class<int>.named<int>' doesn't fit the grammar syntax T.id: |
25 Expect.equals(1, new Class<int>.named<int>().value); /// 02: compile-time erro
r | 25 Expect.equals(1, new Class<int>.named<int>().value); //# 02: compile-time erro
r |
26 | 26 |
27 Expect.equals(2, new prefix.Class().value); | 27 Expect.equals(2, new prefix.Class().value); |
28 // 'prefix' is not a type: | 28 // 'prefix' is not a type: |
29 Expect.equals(2, new prefix<int>.Class().value); /// 03: runtime error | 29 Expect.equals(2, new prefix<int>.Class().value); //# 03: runtime error |
30 Expect.equals(2, new prefix.Class<int>().value); | 30 Expect.equals(2, new prefix.Class<int>().value); |
31 // 'prefix<int>.Class<int>' doesn't fit the grammar syntax T.id: | 31 // 'prefix<int>.Class<int>' doesn't fit the grammar syntax T.id: |
32 Expect.equals(2, new prefix<int>.Class<int>().value); /// 04: compile-time err
or | 32 Expect.equals(2, new prefix<int>.Class<int>().value); //# 04: compile-time err
or |
33 | 33 |
34 Expect.equals(3, new prefix.Class.named().value); | 34 Expect.equals(3, new prefix.Class.named().value); |
35 // 'prefix<int>.Class.named' doesn't fit the grammar syntax T.id: | 35 // 'prefix<int>.Class.named' doesn't fit the grammar syntax T.id: |
36 Expect.equals(3, new prefix<int>.Class.named().value); /// 05: compile-time er
ror | 36 Expect.equals(3, new prefix<int>.Class.named().value); //# 05: compile-time er
ror |
37 // 'prefix.Class<int>.named' doesn't fit the grammar syntax T.id: | 37 // 'prefix.Class<int>.named' doesn't fit the grammar syntax T.id: |
38 Expect.equals(3, new prefix.Class<int>.named().value); | 38 Expect.equals(3, new prefix.Class<int>.named().value); |
39 // 'prefix.Class.named<int>' doesn't fit the grammar syntax T.id: | 39 // 'prefix.Class.named<int>' doesn't fit the grammar syntax T.id: |
40 Expect.equals(3, new prefix.Class.named<int>().value); /// 06: compile-time er
ror | 40 Expect.equals(3, new prefix.Class.named<int>().value); //# 06: compile-time er
ror |
41 // 'prefix<int>.Class<int>' doesn't fit the grammar syntax T.id: | 41 // 'prefix<int>.Class<int>' doesn't fit the grammar syntax T.id: |
42 Expect.equals(3, new prefix<int>.Class<int>.named().value); /// 07: compile-ti
me error | 42 Expect.equals(3, new prefix<int>.Class<int>.named().value); //# 07: compile-ti
me error |
43 // 'prefix<int>.Class.named<int>' doesn't fit the grammar syntax T.id: | 43 // 'prefix<int>.Class.named<int>' doesn't fit the grammar syntax T.id: |
44 Expect.equals(3, new prefix<int>.Class.named<int>().value); /// 08: compile-ti
me error | 44 Expect.equals(3, new prefix<int>.Class.named<int>().value); //# 08: compile-ti
me error |
45 // 'prefix.Class<int>.named<int>' doesn't fit the grammar syntax T.id: | 45 // 'prefix.Class<int>.named<int>' doesn't fit the grammar syntax T.id: |
46 Expect.equals(3, new prefix.Class<int>.named<int>().value); /// 09: compile-ti
me error | 46 Expect.equals(3, new prefix.Class<int>.named<int>().value); //# 09: compile-ti
me error |
47 // 'prefix<int>.Class<int>.named<int>' doesn't fit the grammar syntax T.id: | 47 // 'prefix<int>.Class<int>.named<int>' doesn't fit the grammar syntax T.id: |
48 Expect.equals(3, new prefix<int>.Class<int>.named<int>().value); /// 10: compi
le-time error | 48 Expect.equals(3, new prefix<int>.Class<int>.named<int>().value); //# 10: compi
le-time error |
49 } | 49 } |
OLD | NEW |