Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Side by Side Diff: tests/compiler/dart2js/kernel/constructors_test.dart

Issue 2607013003: Some constructor fixes: implement redirecting constructors, work with finding default constructors … (Closed)
Patch Set: . Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sdk/bin/dart2js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 15 matching lines...) Expand all
26 class A { 26 class A {
27 int x = 1; 27 int x = 1;
28 } 28 }
29 29
30 main() { 30 main() {
31 var a = new A(); 31 var a = new A();
32 return a; 32 return a;
33 }'''; 33 }''';
34 return check(code, lookup: defaultConstructorFor('A')); 34 return check(code, lookup: defaultConstructorFor('A'));
35 }); 35 });
36
37 test('redirecting constructor with field', () {
38 String code = '''
39 class Foo {
40 final int value;
41 const Foo({int number: 0}) : this.poodle(number * 2);
42 const Foo.poodle(this.value);
43 }
44
45 main() => new Foo(number: 3);
46 ''';
47 return check(code, lookup: defaultConstructorFor('Foo'));
48 });
36 } 49 }
37 50
38 defaultConstructorFor(String className) => (Compiler compiler) { 51 defaultConstructorFor(String className) => (Compiler compiler) {
39 ClassElement clazz = compiler.mainApp.find(className); 52 ClassElement clazz = compiler.mainApp.find(className);
40 return clazz.lookupDefaultConstructor(); 53 return clazz.lookupDefaultConstructor();
41 }; 54 };
OLDNEW
« no previous file with comments | « sdk/bin/dart2js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698