OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:kernel/type_algebra.dart'; | 4 import 'package:kernel/type_algebra.dart'; |
5 import 'package:test/test.dart'; | 5 import 'package:test/test.dart'; |
6 import 'type_parser.dart'; | 6 import 'type_parser.dart'; |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 final List<TestCase> testCases = <TestCase>[ | 9 final List<TestCase> testCases = <TestCase>[ |
10 successCase('List<T>', 'List<String>', {'T': 'String'}), | 10 successCase('List<T>', 'List<String>', {'T': 'String'}), |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 successCase('<E>(E) => E', '<T>(T) => T', {}), | 37 successCase('<E>(E) => E', '<T>(T) => T', {}), |
38 successCase('<E>(E, S) => E', '<T>(T, int) => T', {'S': 'int'}), | 38 successCase('<E>(E, S) => E', '<T>(T, int) => T', {'S': 'int'}), |
39 failureCase('<E>(E, S) => E', '<T>(T, T) => T', ['S']), | 39 failureCase('<E>(E, S) => E', '<T>(T, T) => T', ['S']), |
40 successCase( | 40 successCase( |
41 '<E>(E) => <T>(T) => Map<E,T>', '<E>(E) => <T>(T) => Map<E,T>', {}), | 41 '<E>(E) => <T>(T) => Map<E,T>', '<E>(E) => <T>(T) => Map<E,T>', {}), |
42 successCase('<E>(E,_) => E', '<T>(T,_) => T', {}), | 42 successCase('<E>(E,_) => E', '<T>(T,_) => T', {}), |
43 | 43 |
44 successCase('(x:int,y:String) => int', '(y:String,x:int) => int', {}), | 44 successCase('(x:int,y:String) => int', '(y:String,x:int) => int', {}), |
45 successCase('<S,T>(x:S,y:T) => S', '<S,T>(y:T,x:S) => S', {}), | 45 successCase('<S,T>(x:S,y:T) => S', '<S,T>(y:T,x:S) => S', {}), |
46 successCase('(x:<T>(T)=>T,y:<S>(S)=>S) => int', '(y:<S>(S)=>S,x:<T>(T)=>T) =>
int', {}), | 46 successCase('(x:<T>(T)=>T,y:<S>(S)=>S) => int', |
47 successCase('(x:<T>(T)=>T,y:<S>(S,S,S)=>S) => int', '(y:<S>(S,S,S)=>S,x:<T>(T)
=>T) => int', {}), | 47 '(y:<S>(S)=>S,x:<T>(T)=>T) => int', {}), |
| 48 successCase('(x:<T>(T)=>T,y:<S>(S,S,S)=>S) => int', |
| 49 '(y:<S>(S,S,S)=>S,x:<T>(T)=>T) => int', {}), |
48 ]; | 50 ]; |
49 | 51 |
50 class TestCase { | 52 class TestCase { |
51 String type1; | 53 String type1; |
52 String type2; | 54 String type2; |
53 Iterable<String> quantifiedVariables; | 55 Iterable<String> quantifiedVariables; |
54 Map<String, String> expectedSubstitution; // Null if unification should fail. | 56 Map<String, String> expectedSubstitution; // Null if unification should fail. |
55 | 57 |
56 TestCase.success(this.type1, this.type2, this.expectedSubstitution) { | 58 TestCase.success(this.type1, this.type2, this.expectedSubstitution) { |
57 quantifiedVariables = expectedSubstitution.keys; | 59 quantifiedVariables = expectedSubstitution.keys; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 if (substitution != null) { | 131 if (substitution != null) { |
130 reportFailure(testCase, 'Unification was supposed to fail'); | 132 reportFailure(testCase, 'Unification was supposed to fail'); |
131 } | 133 } |
132 } | 134 } |
133 }); | 135 }); |
134 } | 136 } |
135 if (numFailures > 0) { | 137 if (numFailures > 0) { |
136 exit(1); | 138 exit(1); |
137 } | 139 } |
138 } | 140 } |
OLD | NEW |