| 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 library kernel.type_substitute_bounds_test; | 4 library kernel.type_substitute_bounds_test; |
| 5 | 5 |
| 6 import 'package:kernel/kernel.dart'; | 6 import 'package:kernel/kernel.dart'; |
| 7 import 'package:kernel/type_algebra.dart'; | 7 import 'package:kernel/type_algebra.dart'; |
| 8 import 'package:test/test.dart'; | 8 import 'package:test/test.dart'; |
| 9 import 'type_parser.dart'; | 9 import 'type_parser.dart'; |
| 10 | 10 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 test('$testCase', () { | 65 test('$testCase', () { |
| 66 var environment = new LazyTypeEnvironment(); | 66 var environment = new LazyTypeEnvironment(); |
| 67 var type = environment.parse(testCase.type); | 67 var type = environment.parse(testCase.type); |
| 68 var upperBounds = <TypeParameter, DartType>{}; | 68 var upperBounds = <TypeParameter, DartType>{}; |
| 69 var lowerBounds = <TypeParameter, DartType>{}; | 69 var lowerBounds = <TypeParameter, DartType>{}; |
| 70 testCase.bounds.forEach((String name, TypeBound bounds) { | 70 testCase.bounds.forEach((String name, TypeBound bounds) { |
| 71 var parameter = environment.getTypeParameter(name); | 71 var parameter = environment.getTypeParameter(name); |
| 72 upperBounds[parameter] = environment.parse(bounds.upper); | 72 upperBounds[parameter] = environment.parse(bounds.upper); |
| 73 lowerBounds[parameter] = environment.parse(bounds.lower); | 73 lowerBounds[parameter] = environment.parse(bounds.lower); |
| 74 }); | 74 }); |
| 75 var substituted = substituteBounds(type, upperBounds, lowerBounds); | 75 var substituted = Substitution |
| 76 .fromUpperAndLowerBounds(upperBounds, lowerBounds) |
| 77 .substituteType(type); |
| 76 var expected = environment.parse(testCase.expected); | 78 var expected = environment.parse(testCase.expected); |
| 77 if (substituted != expected) { | 79 if (substituted != expected) { |
| 78 fail('Expected `$expected` but got `$substituted`'); | 80 fail('Expected `$expected` but got `$substituted`'); |
| 79 } | 81 } |
| 80 }); | 82 }); |
| 81 } | 83 } |
| 82 } | 84 } |
| OLD | NEW |