OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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('dart:uri'); | 5 #import('dart:uri'); |
6 #import('parser_helper.dart'); | 6 #import('parser_helper.dart'); |
7 #import("../../../lib/compiler/compiler.dart"); | 7 #import("../../../lib/compiler/compiler.dart"); |
8 #import("../../../lib/compiler/implementation/tree/tree.dart"); | 8 #import("../../../lib/compiler/implementation/tree/tree.dart"); |
9 | 9 |
10 testUnparse(String statement) { | 10 testUnparse(String statement) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 testEmptyList() { | 78 testEmptyList() { |
79 testUnparse('var x= [];'); | 79 testUnparse('var x= [];'); |
80 } | 80 } |
81 | 81 |
82 testClosure() { | 82 testClosure() { |
83 testUnparse('var x=(var x)=> x;'); | 83 testUnparse('var x=(var x)=> x;'); |
84 } | 84 } |
85 | 85 |
86 testIndexedOperatorDecl() { | 86 testIndexedOperatorDecl() { |
87 testUnparseMember('operator[](int i)=> null;'); | 87 testUnparseMember('operator[](int i)=> null;'); |
| 88 testUnparseMember('operator[]=(int i, int j)=> null;'); |
88 } | 89 } |
89 | 90 |
90 testNativeMethods() { | 91 testNativeMethods() { |
91 testUnparseMember('foo()native;'); | 92 testUnparseMember('foo()native;'); |
92 testUnparseMember('foo()native "bar";'); | 93 testUnparseMember('foo()native "bar";'); |
93 testUnparseMember('foo()native "this.x = 41";'); | 94 testUnparseMember('foo()native "this.x = 41";'); |
94 } | 95 } |
95 | 96 |
96 testPrefixIncrements() { | 97 testPrefixIncrements() { |
97 testUnparse('++i;'); | 98 testUnparse('++i;'); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 155 |
155 testGetSet() { | 156 testGetSet() { |
156 // Top-level get/set. | 157 // Top-level get/set. |
157 testDart2Dart('get foo(){return 5;}set foo(arg){}main(){foo; foo=5;}'); | 158 testDart2Dart('get foo(){return 5;}set foo(arg){}main(){foo; foo=5;}'); |
158 // Field get/set. | 159 // Field get/set. |
159 testDart2Dart('main(){var a=new A(); a.foo; a.foo=5;}class A{set foo(a){}get f
oo(){return 5;}}'); | 160 testDart2Dart('main(){var a=new A(); a.foo; a.foo=5;}class A{set foo(a){}get f
oo(){return 5;}}'); |
160 // Typed get/set. | 161 // Typed get/set. |
161 testDart2Dart('String get foo(){return "a";}main(){foo;}'); | 162 testDart2Dart('String get foo(){return "a";}main(){foo;}'); |
162 } | 163 } |
163 | 164 |
| 165 testFactoryConstructor() { |
| 166 testDart2Dart('main(){new A.fromFoo();}class A{A.fromFoo();}'); |
| 167 // Now more complicated, with normal constructor and factory parameters. |
| 168 testDart2Dart('main(){new A.fromFoo(5);}' |
| 169 'class A{A(this.f);A.fromFoo(foo):this("f");final String f;}'); |
| 170 } |
| 171 |
164 main() { | 172 main() { |
165 testGenericTypes(); | 173 testGenericTypes(); |
166 testForLoop(); | 174 testForLoop(); |
167 testEmptyList(); | 175 testEmptyList(); |
168 testClosure(); | 176 testClosure(); |
169 testIndexedOperatorDecl(); | 177 testIndexedOperatorDecl(); |
170 testNativeMethods(); | 178 testNativeMethods(); |
171 testPrefixIncrements(); | 179 testPrefixIncrements(); |
172 testConstModifier(); | 180 testConstModifier(); |
173 testSimpleFileUnparse(); | 181 testSimpleFileUnparse(); |
174 testSimpleObjectInstantiation(); | 182 testSimpleObjectInstantiation(); |
175 testSimpleTopLevelClass(); | 183 testSimpleTopLevelClass(); |
176 testClassWithSynthesizedConstructor(); | 184 testClassWithSynthesizedConstructor(); |
177 testClassWithMethod(); | 185 testClassWithMethod(); |
178 testVariableDefinitions(); | 186 testVariableDefinitions(); |
179 testGetSet(); | 187 testGetSet(); |
| 188 testFactoryConstructor(); |
180 testTopLevelField(); | 189 testTopLevelField(); |
181 } | 190 } |
OLD | NEW |