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

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

Issue 111803002: Implement tracing for function expressions and statements, and infer types of parameters of these c… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'package:expect/expect.dart';
6 import "package:async_helper/async_helper.dart";
7
8 import 'compiler_helper.dart';
9 import 'parser_helper.dart';
10
11 const String TEST = '''
12 testFunctionStatement() {
13 var res;
14 closure(a) => res = a;
15 closure(42);
16 return res;
17 }
18
19 testFunctionExpression() {
20 var res;
21 var closure = (a) => res = a;
22 closure(42);
23 return res;
24 }
25
26 var staticField;
27
28 testStoredInStatic() {
29 var res;
30 closure(a) => res = a;
31 staticField = closure;
32 staticField(42);
33 return res;
34 }
35
36 class A {
37 var field;
38 A(this.field);
39 }
40
41 testStoredInInstance() {
42 var res;
43 closure(a) => res = a;
44 var a = new A(closure);
45 a.field(42);
46 return res;
47 }
48
49 main() {
kasperl 2013/12/11 07:35:35 Add test for "stored" in parameter?
ngeoffray 2013/12/16 11:47:43 Done.
50 testFunctionStatement();
51 testFunctionExpression();
52 testStoredInStatic();
53 testStoredInInstance();
54 }
55 ''';
56
57 void main() {
58 Uri uri = new Uri(scheme: 'source');
59 var compiler = compilerFor(TEST, uri);
60 asyncTest(() => compiler.runCompiler(uri).then((_) {
61 var typesTask = compiler.typesTask;
62 var typesInferrer = typesTask.typesInferrer;
63
64 checkType(String name, type) {
65 var element = findElement(compiler, name);
66 var mask = typesInferrer.getReturnTypeOfElement(element);
67 Expect.equals(type.nullable(), mask.simplify(compiler), name);
68 }
69
70 checkType('testFunctionStatement', typesTask.uint31Type);
71 checkType('testFunctionExpression', typesTask.uint31Type);
72 checkType('testStoredInInstance', typesTask.uint31Type);
73 checkType('testStoredInStatic', typesTask.uint31Type);
74 }));
75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698