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

Side by Side Diff: tests/compiler/dart2js/simple_inferrer_final_field_test.dart

Issue 16019002: Merge the dart:uri library into dart:core and update the Uri class (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Final cleanup Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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:expect/expect.dart'; 5 import 'package:expect/expect.dart';
6 import 'compiler_helper.dart'; 6 import 'compiler_helper.dart';
7 import 'parser_helper.dart'; 7 import 'parser_helper.dart';
8 8
9 const String TEST = """ 9 const String TEST = """
10 10
11 class A { 11 class A {
12 final intField; 12 final intField;
13 final giveUpField1; 13 final giveUpField1;
14 final giveUpField2; 14 final giveUpField2;
15 final fieldParameter; 15 final fieldParameter;
16 A() : intField = 42, giveUpField1 = 'foo', giveUpField2 = 'foo'; 16 A() : intField = 42, giveUpField1 = 'foo', giveUpField2 = 'foo';
17 A.bar() : intField = 54, giveUpField1 = 42, giveUpField2 = new A(); 17 A.bar() : intField = 54, giveUpField1 = 42, giveUpField2 = new A();
18 A.foo(this.fieldParameter); 18 A.foo(this.fieldParameter);
19 } 19 }
20 20
21 main() { 21 main() {
22 new A(); 22 new A();
23 new A.bar(); 23 new A.bar();
24 new A.foo(42); 24 new A.foo(42);
25 } 25 }
26 """; 26 """;
27 27
28 void main() { 28 void main() {
29 Uri uri = new Uri.fromComponents(scheme: 'source'); 29 Uri uri = new Uri(scheme: 'source');
30 var compiler = compilerFor(TEST, uri); 30 var compiler = compilerFor(TEST, uri);
31 compiler.runCompiler(uri); 31 compiler.runCompiler(uri);
32 var typesInferrer = compiler.typesTask.typesInferrer; 32 var typesInferrer = compiler.typesTask.typesInferrer;
33 33
34 checkFieldTypeInClass(String className, String fieldName, type) { 34 checkFieldTypeInClass(String className, String fieldName, type) {
35 var cls = findElement(compiler, className); 35 var cls = findElement(compiler, className);
36 var element = cls.lookupLocalMember(buildSourceString(fieldName)); 36 var element = cls.lookupLocalMember(buildSourceString(fieldName));
37 Expect.equals(type, 37 Expect.equals(type,
38 typesInferrer.internal.typeOf[element].simplify(compiler)); 38 typesInferrer.internal.typeOf[element].simplify(compiler));
39 } 39 }
40 40
41 checkFieldTypeInClass('A', 'intField', typesInferrer.intType); 41 checkFieldTypeInClass('A', 'intField', typesInferrer.intType);
42 checkFieldTypeInClass('A', 'giveUpField1', 42 checkFieldTypeInClass('A', 'giveUpField1',
43 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass')); 43 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'));
44 checkFieldTypeInClass('A', 'giveUpField2', 44 checkFieldTypeInClass('A', 'giveUpField2',
45 typesInferrer.dynamicType.nonNullable()); 45 typesInferrer.dynamicType.nonNullable());
46 checkFieldTypeInClass('A', 'fieldParameter', typesInferrer.intType); 46 checkFieldTypeInClass('A', 'fieldParameter', typesInferrer.intType);
47 } 47 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698