| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /// And end-to-end test that generates code and checks that the output matches | 5 /// And end-to-end test that generates code and checks that the output matches |
| 6 /// the code in `static_test.dart`. Techincally we could run the result in an | 6 /// the code in `static_test.dart`. Techincally we could run the result in an |
| 7 /// isolate, but instead we decided to split that up in two tests. This test | 7 /// isolate, but instead we decided to split that up in two tests. This test |
| 8 /// ensures that we generate the code as it was written in static_test, and | 8 /// ensures that we generate the code as it was written in static_test, and |
| 9 /// separately static_test ensures that the smoke.static library behaves as | 9 /// separately static_test ensures that the smoke.static library behaves as |
| 10 /// expected. | 10 /// expected. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 runQuery('A', new QueryOptions()); | 100 runQuery('A', new QueryOptions()); |
| 101 runQuery('D', new QueryOptions(includeInherited: true)); | 101 runQuery('D', new QueryOptions(includeInherited: true)); |
| 102 | 102 |
| 103 var vars = lib.definingCompilationUnit.topLevelVariables; | 103 var vars = lib.definingCompilationUnit.topLevelVariables; |
| 104 expect(vars[0].name, 'a1'); | 104 expect(vars[0].name, 'a1'); |
| 105 expect(vars[1].name, 'a2'); | 105 expect(vars[1].name, 'a2'); |
| 106 | 106 |
| 107 runQuery('H', new QueryOptions(includeInherited: true, | 107 runQuery('H', new QueryOptions(includeInherited: true, |
| 108 withAnnotations: [vars[0], vars[1], lib.getType('Annot')])); | 108 withAnnotations: [vars[0], vars[1], lib.getType('Annot')])); |
| 109 | 109 |
| 110 runQuery('K', new QueryOptions(includeInherited: true, |
| 111 withAnnotations: [lib.getType('AnnotC')])); |
| 112 |
| 110 var code = _createEntrypoint(generator); | 113 var code = _createEntrypoint(generator); |
| 111 var staticTestFile = new File(path.join(testDir, 'static_test.dart')); | 114 var staticTestFile = new File(path.join(testDir, 'static_test.dart')); |
| 112 var existingCode = staticTestFile.readAsStringSync(); | 115 var existingCode = staticTestFile.readAsStringSync(); |
| 113 if (!updateStaticTest) { | 116 if (!updateStaticTest) { |
| 114 expect(code, existingCode); | 117 expect(code, existingCode); |
| 115 } else if (code == existingCode) { | 118 } else if (code == existingCode) { |
| 116 print('static_test.dart is already up to date'); | 119 print('static_test.dart is already up to date'); |
| 117 } else { | 120 } else { |
| 118 staticTestFile.writeAsStringSync(code); | 121 staticTestFile.writeAsStringSync(code); |
| 119 print('static_test.dart has been updated.'); | 122 print('static_test.dart has been updated.'); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 142 ..writeln(' common.main();') | 145 ..writeln(' common.main();') |
| 143 ..writeln('}'); | 146 ..writeln('}'); |
| 144 return sb.toString(); | 147 return sb.toString(); |
| 145 } | 148 } |
| 146 | 149 |
| 147 _resolveImportUrl(LibraryElement lib) { | 150 _resolveImportUrl(LibraryElement lib) { |
| 148 if (lib.isDartCore) return 'dart:core'; | 151 if (lib.isDartCore) return 'dart:core'; |
| 149 if (lib.displayName == 'smoke.test.common') return 'common.dart'; | 152 if (lib.displayName == 'smoke.test.common') return 'common.dart'; |
| 150 return 'unknown.dart'; | 153 return 'unknown.dart'; |
| 151 } | 154 } |
| OLD | NEW |