| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 'package:compiler/src/compiler.dart' show Compiler; | 5 import 'package:compiler/src/compiler.dart' show Compiler; |
| 6 import 'package:compiler/src/elements/elements.dart'; | 6 import 'package:compiler/src/elements/elements.dart'; |
| 7 import 'package:test/test.dart'; | 7 import 'package:test/test.dart'; |
| 8 | 8 |
| 9 import 'helper.dart' show check; | 9 import 'helper.dart' show check; |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 class Foo { | 39 class Foo { |
| 40 final int value; | 40 final int value; |
| 41 const Foo({int number: 0}) : this.poodle(number * 2); | 41 const Foo({int number: 0}) : this.poodle(number * 2); |
| 42 const Foo.poodle(this.value); | 42 const Foo.poodle(this.value); |
| 43 } | 43 } |
| 44 | 44 |
| 45 main() => new Foo(number: 3); | 45 main() => new Foo(number: 3); |
| 46 '''; | 46 '''; |
| 47 return check(code, lookup: defaultConstructorFor('Foo')); | 47 return check(code, lookup: defaultConstructorFor('Foo')); |
| 48 }); | 48 }); |
| 49 |
| 50 // TODO(efortuna): Kernel needs to have some additional constructor |
| 51 // implementaion work before this is legitimately equivalent code to the |
| 52 // original AST. |
| 53 /*test('initialized field and constructor', () { |
| 54 String code = ''' |
| 55 import 'dart:_foreign_helper' show JS, JS_EMBEDDED_GLOBAL; |
| 56 import 'package:expect/expect.dart'; |
| 57 |
| 58 |
| 59 class Foo { |
| 60 final value = JS('bool', '#()', JS_EMBEDDED_GLOBAL('', 'foo')); |
| 61 Foo() { |
| 62 print('hello world'); |
| 63 } |
| 49 } | 64 } |
| 50 | 65 |
| 66 main() => new Foo(); |
| 67 '''; |
| 68 return check(code, lookup: defaultConstructorFor('Foo')); |
| 69 }); |
| 70 }*/ |
| 71 |
| 51 defaultConstructorFor(String className) => (Compiler compiler) { | 72 defaultConstructorFor(String className) => (Compiler compiler) { |
| 52 ClassElement clazz = compiler.mainApp.find(className); | 73 ClassElement clazz = compiler.mainApp.find(className); |
| 53 return clazz.lookupDefaultConstructor(); | 74 return clazz.lookupDefaultConstructor(); |
| 54 }; | 75 }; |
| OLD | NEW |