| 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 library smoke.test.codegen.generator_test; | 5 library smoke.test.codegen.generator_test; |
| 6 | 6 |
| 7 import 'package:smoke/codegen/generator.dart'; | 7 import 'package:smoke/codegen/generator.dart'; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 | 9 |
| 10 import 'common.dart' show checkResults; | 10 import 'common.dart' show checkResults; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 }); | 105 }); |
| 106 | 106 |
| 107 test('declarations', () { | 107 test('declarations', () { |
| 108 var generator = new SmokeCodeGenerator(); | 108 var generator = new SmokeCodeGenerator(); |
| 109 generator.addDeclaration(new TypeIdentifier('a.dart', 'A'), 'foo', | 109 generator.addDeclaration(new TypeIdentifier('a.dart', 'A'), 'foo', |
| 110 new TypeIdentifier('dart:core', 'int'), isField: true, isFinal: true); | 110 new TypeIdentifier('dart:core', 'int'), isField: true, isFinal: true); |
| 111 generator.addDeclaration(new TypeIdentifier('a.dart', 'A'), 'bar', | 111 generator.addDeclaration(new TypeIdentifier('a.dart', 'A'), 'bar', |
| 112 new TypeIdentifier('dart:core', 'Function'), isMethod: true, | 112 new TypeIdentifier('dart:core', 'Function'), isMethod: true, |
| 113 annotations: [new ConstExpression.constructor(null, 'Annotation', | 113 annotations: [new ConstExpression.constructor(null, 'Annotation', |
| 114 [new ConstExpression.string("hi")], const {})]); | 114 [new ConstExpression.string("hi")], const {})]); |
| 115 generator.addDeclaration(new TypeIdentifier('a.dart', 'A'), '[]', |
| 116 new TypeIdentifier('dart:core', 'Function'), isMethod: true); |
| 117 var symbol = "const Symbol('[]')"; |
| 118 var details = "$symbol, Function, kind: METHOD"; |
| 115 checkResults(generator, | 119 checkResults(generator, |
| 116 imports: ["import 'a.dart' as smoke_0;"], | 120 imports: ["import 'a.dart' as smoke_0;"], |
| 117 initCall: | 121 initCall: |
| 118 'useGeneratedCode(new StaticConfiguration(\n' | 122 'useGeneratedCode(new StaticConfiguration(\n' |
| 119 ' checkedMode: false,\n' | 123 ' checkedMode: false,\n' |
| 120 ' declarations: {\n' | 124 ' declarations: {\n' |
| 121 ' smoke_0.A: {\n' | 125 ' smoke_0.A: {\n' |
| 126 ' $symbol: const Declaration($details),\n' |
| 122 ' #bar: const Declaration(#bar, Function, kind: METHOD, ' | 127 ' #bar: const Declaration(#bar, Function, kind: METHOD, ' |
| 123 'annotations: const [const Annotation(\'hi\')]),\n' | 128 'annotations: const [const Annotation(\'hi\')]),\n' |
| 124 ' #foo: const Declaration(#foo, int, isFinal: true),\n' | 129 ' #foo: const Declaration(#foo, int, isFinal: true),\n' |
| 125 ' },\n' | 130 ' },\n' |
| 126 ' }));\n'); | 131 ' }));\n'); |
| 127 }); | 132 }); |
| 128 | 133 |
| 129 test('staticMethod', () { | 134 test('staticMethod', () { |
| 130 var generator = new SmokeCodeGenerator(); | 135 var generator = new SmokeCodeGenerator(); |
| 131 generator.addStaticMethod(new TypeIdentifier('a.dart', 'A'), 'm1'); | 136 generator.addStaticMethod(new TypeIdentifier('a.dart', 'A'), 'm1'); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 ' smoke_0.A: {\n' | 192 ' smoke_0.A: {\n' |
| 188 ' #foo: const Declaration(#foo, int, isFinal: true),\n' | 193 ' #foo: const Declaration(#foo, int, isFinal: true),\n' |
| 189 ' },\n' | 194 ' },\n' |
| 190 ' },\n' | 195 ' },\n' |
| 191 ' names: {\n' | 196 ' names: {\n' |
| 192 ' #c: r\'c\',\n' | 197 ' #c: r\'c\',\n' |
| 193 ' #d: r\'d\',\n' | 198 ' #d: r\'d\',\n' |
| 194 ' }));\n'); | 199 ' }));\n'); |
| 195 }); | 200 }); |
| 196 } | 201 } |
| OLD | NEW |