Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // TODO(jmesserly): this file needs to be refactored, it's a port from | 5 // TODO(jmesserly): this file needs to be refactored, it's a port from |
| 6 // package:dev_compiler's tests | 6 // package:dev_compiler's tests |
| 7 /// General type checking tests | 7 /// General type checking tests |
| 8 library analyzer.test.src.task.strong.checker_test; | 8 library analyzer.test.src.task.strong.checker_test; |
| 9 | 9 |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1382 /*=B*/ then/*<B>*/(/*=B*/ onValue(A a)) => null; | 1382 /*=B*/ then/*<B>*/(/*=B*/ onValue(A a)) => null; |
| 1383 } | 1383 } |
| 1384 | 1384 |
| 1385 class DerivedFuture3<T> extends Future<T> { | 1385 class DerivedFuture3<T> extends Future<T> { |
| 1386 /*=S*/ then/*<S>*/(Object onValue(T t)) => null; | 1386 /*=S*/ then/*<S>*/(Object onValue(T t)) => null; |
| 1387 } | 1387 } |
| 1388 | 1388 |
| 1389 class DerivedFuture4<A> extends Future<A> { | 1389 class DerivedFuture4<A> extends Future<A> { |
| 1390 /*=B*/ then/*<B>*/(Object onValue(A a)) => null; | 1390 /*=B*/ then/*<B>*/(Object onValue(A a)) => null; |
| 1391 } | 1391 } |
| 1392 ''' | 1392 ''' |
| 1393 }); | |
| 1394 | |
| 1395 testChecker('generic function wrong number of arguments', { | |
| 1396 '/main.dart': r''' | |
| 1397 /*=T*/ foo/*<T>*/(/*=T*/ x) => x; | |
| 1398 main() { | |
| 1399 // resolving thses shouldn't crash. | |
| 1400 foo(1, 2); | |
| 1401 String x = foo('1', '2'); | |
| 1402 String x = /*severe:STATIC_TYPE_ERROR*/foo(1, 2); | |
|
Leaf
2016/01/13 00:43:10
Also add a call with too few arguments, and maybe
Jennifer Messerly
2016/01/13 19:10:36
Good idea. Added.
| |
| 1403 } | |
| 1404 ''' | |
| 1393 }); | 1405 }); |
| 1394 | 1406 |
| 1395 testChecker('unary operators', { | 1407 testChecker('unary operators', { |
| 1396 '/main.dart': ''' | 1408 '/main.dart': ''' |
| 1397 class A { | 1409 class A { |
| 1398 A operator ~() {} | 1410 A operator ~() {} |
| 1399 A operator +(int x) {} | 1411 A operator +(int x) {} |
| 1400 A operator -(int x) {} | 1412 A operator -(int x) {} |
| 1401 A operator -() {} | 1413 A operator -() {} |
| 1402 } | 1414 } |
| (...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2467 | 2479 |
| 2468 baz1() sync* { yield* (/*info:DYNAMIC_CAST*/x); } | 2480 baz1() sync* { yield* (/*info:DYNAMIC_CAST*/x); } |
| 2469 Iterable baz2() sync* { yield* (/*info:DYNAMIC_CAST*/x); } | 2481 Iterable baz2() sync* { yield* (/*info:DYNAMIC_CAST*/x); } |
| 2470 Iterable<int> baz3() sync* { yield* (/*warning:DOWN_CAST_COMPOSITE*/x); } | 2482 Iterable<int> baz3() sync* { yield* (/*warning:DOWN_CAST_COMPOSITE*/x); } |
| 2471 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } | 2483 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } |
| 2472 Iterable<int> baz5() sync* { yield* (/*info:INFERRED_TYPE_ALLOCATION*/ne w Iterable()); } | 2484 Iterable<int> baz5() sync* { yield* (/*info:INFERRED_TYPE_ALLOCATION*/ne w Iterable()); } |
| 2473 ''' | 2485 ''' |
| 2474 }); | 2486 }); |
| 2475 }); | 2487 }); |
| 2476 } | 2488 } |
| OLD | NEW |