OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 import "dart:uri"; | 5 import "dart:uri"; |
6 | 6 |
7 import 'compiler_helper.dart'; | 7 import 'compiler_helper.dart'; |
8 import 'parser_helper.dart'; | 8 import 'parser_helper.dart'; |
9 | 9 |
10 import '../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar
t'; | 10 import '../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar
t'; |
(...skipping 26 matching lines...) Expand all Loading... |
37 $declaration | 37 $declaration |
38 main() {}"""; | 38 main() {}"""; |
39 | 39 |
40 compileAndCheck(source, name, (compiler, element) { | 40 compileAndCheck(source, name, (compiler, element) { |
41 compiler.enqueuer.resolution.queueIsClosed = false; | 41 compiler.enqueuer.resolution.queueIsClosed = false; |
42 Expect.equals(2, length(element.metadata)); | 42 Expect.equals(2, length(element.metadata)); |
43 MetadataAnnotation annotation1 = element.metadata.head; | 43 MetadataAnnotation annotation1 = element.metadata.head; |
44 MetadataAnnotation annotation2 = element.metadata.tail.head; | 44 MetadataAnnotation annotation2 = element.metadata.tail.head; |
45 annotation1.ensureResolved(compiler); | 45 annotation1.ensureResolved(compiler); |
46 annotation2.ensureResolved(compiler); | 46 annotation2.ensureResolved(compiler); |
47 Expect.isTrue(annotation1 !== annotation2, 'expected unique instances'); | 47 Expect.isFalse(identical(annotation1, annotation2), |
| 48 'expected unique instances'); |
48 Expect.notEquals(annotation1, annotation2, 'expected unequal instances'); | 49 Expect.notEquals(annotation1, annotation2, 'expected unequal instances'); |
49 Constant value1 = annotation1.value; | 50 Constant value1 = annotation1.value; |
50 Constant value2 = annotation2.value; | 51 Constant value2 = annotation2.value; |
51 Expect.identical(value1, value2, 'expected same compile-time constant'); | 52 Expect.identical(value1, value2, 'expected same compile-time constant'); |
52 Expect.stringEquals('xyz', value1.value.slowToString()); | 53 Expect.stringEquals('xyz', value1.value.slowToString()); |
53 Expect.stringEquals('xyz', value2.value.slowToString()); | 54 Expect.stringEquals('xyz', value2.value.slowToString()); |
54 }); | 55 }); |
55 | 56 |
56 if (isTopLevelOnly) return; | 57 if (isTopLevelOnly) return; |
57 | 58 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 compiler.enqueuer.resolution.queueIsClosed = false; | 91 compiler.enqueuer.resolution.queueIsClosed = false; |
91 Expect.equals(0, length(element.metadata)); | 92 Expect.equals(0, length(element.metadata)); |
92 element.ensureResolved(compiler); | 93 element.ensureResolved(compiler); |
93 Expect.equals(0, length(element.metadata)); | 94 Expect.equals(0, length(element.metadata)); |
94 element = element.lookupLocalMember(buildSourceString(name)); | 95 element = element.lookupLocalMember(buildSourceString(name)); |
95 Expect.equals(2, length(element.metadata)); | 96 Expect.equals(2, length(element.metadata)); |
96 MetadataAnnotation annotation1 = element.metadata.head; | 97 MetadataAnnotation annotation1 = element.metadata.head; |
97 MetadataAnnotation annotation2 = element.metadata.tail.head; | 98 MetadataAnnotation annotation2 = element.metadata.tail.head; |
98 annotation1.ensureResolved(compiler); | 99 annotation1.ensureResolved(compiler); |
99 annotation2.ensureResolved(compiler); | 100 annotation2.ensureResolved(compiler); |
100 Expect.isTrue(annotation1 !== annotation2, 'expected unique instances'); | 101 Expect.isFalse(identical(annotation1, annotation2), |
| 102 'expected unique instances'); |
101 Expect.notEquals(annotation1, annotation2, 'expected unequal instances'); | 103 Expect.notEquals(annotation1, annotation2, 'expected unequal instances'); |
102 Constant value1 = annotation1.value; | 104 Constant value1 = annotation1.value; |
103 Constant value2 = annotation2.value; | 105 Constant value2 = annotation2.value; |
104 Expect.identical(value1, value2, 'expected same compile-time constant'); | 106 Expect.identical(value1, value2, 'expected same compile-time constant'); |
105 Expect.stringEquals('xyz', value1.value.slowToString()); | 107 Expect.stringEquals('xyz', value1.value.slowToString()); |
106 Expect.stringEquals('xyz', value2.value.slowToString()); | 108 Expect.stringEquals('xyz', value2.value.slowToString()); |
107 }); | 109 }); |
108 } | 110 } |
109 | 111 |
110 void testClassMetadata() { | 112 void testClassMetadata() { |
111 checkAnnotation('Foo', 'class Foo {}', isTopLevelOnly: true); | 113 checkAnnotation('Foo', 'class Foo {}', isTopLevelOnly: true); |
112 } | 114 } |
113 | 115 |
114 void testTopLevelMethodMetadata() { | 116 void testTopLevelMethodMetadata() { |
115 checkAnnotation('foo', 'foo() {}'); | 117 checkAnnotation('foo', 'foo() {}'); |
116 } | 118 } |
117 | 119 |
118 void testTopLevelFieldMetadata() { | 120 void testTopLevelFieldMetadata() { |
119 checkAnnotation('foo', 'var foo;'); | 121 checkAnnotation('foo', 'var foo;'); |
120 } | 122 } |
121 | 123 |
122 void main() { | 124 void main() { |
123 testClassMetadata(); | 125 testClassMetadata(); |
124 testTopLevelMethodMetadata(); | 126 testTopLevelMethodMetadata(); |
125 testTopLevelFieldMetadata(); | 127 testTopLevelFieldMetadata(); |
126 } | 128 } |
OLD | NEW |