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

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

Issue 17413013: Revert "Support runtime check of function types." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « tests/co19/co19-dart2js.status ('k') | tests/compiler/dart2js/type_representation_test.dart » ('j') | 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) 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 library subtype_test; 5 library subtype_test;
6 6
7 import 'package:expect/expect.dart'; 7 import 'package:expect/expect.dart';
8 import 'type_test_helper.dart'; 8 import 'type_test_helper.dart';
9 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart'; 9 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart';
10 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t" 10 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 expect(true, A, function); 257 expect(true, A, function);
258 expect(true, A, m1); 258 expect(true, A, m1);
259 expect(true, A, m2); 259 expect(true, A, m2);
260 expect(false, A, m3); 260 expect(false, A, m3);
261 expect(false, A, m4); 261 expect(false, A, m4);
262 expect(true, A, m5); 262 expect(true, A, m5);
263 } 263 }
264 264
265 testFunctionSubtyping() { 265 testFunctionSubtyping() {
266 var env = new TypeEnvironment(r""" 266 var env = new TypeEnvironment(r"""
267 _() => null;
268 void void_() {} 267 void void_() {}
269 void void_2() {} 268 void void_2() {}
270 int int_() => 0; 269 int int_() => 0;
271 int int_2() => 0; 270 int int_2() => 0;
272 Object Object_() => null; 271 Object Object_() => null;
273 double double_() => 0.0; 272 double double_() => 0.0;
274 void void__int(int i) {} 273 void void__int(int i) {}
275 int int__int(int i) => 0; 274 int int__int(int i) => 0;
276 int int__int2(int i) => 0; 275 int int__int2(int i) => 0;
277 int int__Object(Object o) => 0; 276 int int__Object(Object o) => 0;
278 Object Object__int(int i) => null; 277 Object Object__int(int i) => null;
279 int int__double(double d) => 0; 278 int int__double(double d) => 0;
280 int int__int_int(int i1, int i2) => 0; 279 int int__int_int(int i1, int i2) => 0;
281 void inline_void_(void f()) {} 280 void inline_void_(void f()) {}
282 void inline_void__int(void f(int i)) {} 281 void inline_void__int(void f(int i)) {}
283 """); 282 """);
284 functionSubtypingHelper(env); 283 functionSubtypingHelper(env);
285 } 284 }
286 285
287 testTypedefSubtyping() { 286 testTypedefSubtyping() {
288 var env = new TypeEnvironment(r""" 287 var env = new TypeEnvironment(r"""
289 typedef _();
290 typedef void void_(); 288 typedef void void_();
291 typedef void void_2(); 289 typedef void void_2();
292 typedef int int_(); 290 typedef int int_();
293 typedef int int_2(); 291 typedef int int_2();
294 typedef Object Object_(); 292 typedef Object Object_();
295 typedef double double_(); 293 typedef double double_();
296 typedef void void__int(int i); 294 typedef void void__int(int i);
297 typedef int int__int(int i); 295 typedef int int__int(int i);
298 typedef int int__int2(int i); 296 typedef int int__int2(int i);
299 typedef int int__Object(Object o); 297 typedef int int__Object(Object o);
(...skipping 12 matching lines...) Expand all
312 DartType supertype = env.getElementType(sup); 310 DartType supertype = env.getElementType(sup);
313 Expect.equals(expectedResult, env.isSubtype(subtype, supertype), 311 Expect.equals(expectedResult, env.isSubtype(subtype, supertype),
314 '$subtype <: $supertype'); 312 '$subtype <: $supertype');
315 } 313 }
316 314
317 // () -> int <: Function 315 // () -> int <: Function
318 expect(true, 'int_', 'Function'); 316 expect(true, 'int_', 'Function');
319 // Function <: () -> int 317 // Function <: () -> int
320 expect(false, 'Function', 'int_'); 318 expect(false, 'Function', 'int_');
321 319
322 // () -> dynamic <: () -> dynamic
323 expect(true, '_', '_');
324 // () -> dynamic <: () -> void
325 expect(true, '_', 'void_');
326 // () -> void <: () -> dynamic
327 expect(true, 'void_', '_');
328
329 // () -> int <: () -> void 320 // () -> int <: () -> void
330 expect(true, 'int_', 'void_'); 321 expect(true, 'int_', 'void_');
331 // () -> void <: () -> int 322 // () -> void <: () -> int
332 expect(false, 'void_', 'int_'); 323 expect(false, 'void_', 'int_');
333 // () -> void <: () -> void 324 // () -> void <: () -> void
334 expect(true, 'void_', 'void_2'); 325 expect(true, 'void_', 'void_2');
335 // () -> int <: () -> int 326 // () -> int <: () -> int
336 expect(true, 'int_', 'int_2'); 327 expect(true, 'int_', 'int_2');
337 // () -> int <: () -> Object 328 // () -> int <: () -> Object
338 expect(true, 'int_', 'Object_'); 329 expect(true, 'int_', 'Object_');
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 expect(true, J_U, Object_); 720 expect(true, J_U, Object_);
730 expect(false, J_U, num_); 721 expect(false, J_U, num_);
731 expect(false, J_U, int_); 722 expect(false, J_U, int_);
732 expect(false, J_U, String_); 723 expect(false, J_U, String_);
733 expect(true, J_U, dynamic_); 724 expect(true, J_U, dynamic_);
734 expect(false, J_U, J_T); 725 expect(false, J_U, J_T);
735 expect(true, J_U, J_S); 726 expect(true, J_U, J_S);
736 expect(true, J_U, J_U); 727 expect(true, J_U, J_U);
737 expect(false, J_U, A_T); 728 expect(false, J_U, A_T);
738 } 729 }
OLDNEW
« no previous file with comments | « tests/co19/co19-dart2js.status ('k') | tests/compiler/dart2js/type_representation_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698