mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:49:47 +00:00
[dart2js] Minor tidying up of unittests.
Change-Id: If0d6866601ea06a0b167a1a23127257e38828935 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148227 Commit-Queue: Joshua Litt <joshualitt@google.com> Reviewed-by: Mayank Patke <fishythefish@google.com>
This commit is contained in:
parent
53c77e7a16
commit
42a1f29d5b
|
@ -9,6 +9,7 @@ import 'package:compiler/src/elements/entities.dart';
|
|||
import 'package:compiler/src/elements/types.dart';
|
||||
import 'package:compiler/src/universe/call_structure.dart';
|
||||
import 'package:expect/expect.dart';
|
||||
import '../helpers/memory_compiler.dart';
|
||||
import '../helpers/type_test_helper.dart';
|
||||
|
||||
List<FunctionTypeData> signatures = const <FunctionTypeData>[
|
||||
|
@ -34,11 +35,12 @@ main() {
|
|||
""");
|
||||
|
||||
for (FunctionTypeData data in signatures) {
|
||||
FunctionType functionType =
|
||||
env.getElementType('t${data.name}').withoutNullability;
|
||||
DartType functionType = env.getElementType('t${data.name}');
|
||||
Expect.isTrue(functionType is! LegacyType ||
|
||||
(env.options.useLegacySubtyping && isDart2jsNnbd));
|
||||
functionType = functionType.withoutNullability;
|
||||
FunctionEntity method = env.getElement('m${data.name}');
|
||||
FunctionType methodType =
|
||||
env.getElementType('m${data.name}').withoutNullability;
|
||||
FunctionType methodType = env.getElementType('m${data.name}');
|
||||
ParameterStructure parameterStructure = method.parameterStructure;
|
||||
Expect.equals(functionType, methodType, "Type mismatch on $data");
|
||||
Expect.equals(
|
||||
|
|
|
@ -53,14 +53,6 @@ main() {
|
|||
new C().futureOrT();
|
||||
}
|
||||
""");
|
||||
var options = env.compiler.options;
|
||||
|
||||
String typeToString(DartType type) {
|
||||
return type.toStructuredText(
|
||||
printLegacyStars: options.printLegacyStars,
|
||||
useLegacySubtyping: options.useLegacySubtyping);
|
||||
}
|
||||
|
||||
FunctionType getFunctionType(String name, String expectedType,
|
||||
[ClassEntity cls]) {
|
||||
FunctionType type = env.getMemberType(name, cls);
|
||||
|
@ -68,7 +60,7 @@ main() {
|
|||
"Member $name not found${cls != null ? ' in class $cls' : ''}.");
|
||||
Expect.equals(
|
||||
expectedType,
|
||||
typeToString(type),
|
||||
env.printType(type),
|
||||
"Unexpected type for $name"
|
||||
"${cls != null ? ' in class $cls' : ''}.");
|
||||
return type;
|
||||
|
@ -82,7 +74,7 @@ main() {
|
|||
DartType returnType = type.returnType.withoutNullability;
|
||||
Expect.equals(
|
||||
expectedType,
|
||||
typeToString(returnType),
|
||||
env.printType(returnType),
|
||||
"Unexpected return type for $name"
|
||||
"${cls != null ? ' in class $cls' : ''}.");
|
||||
return returnType;
|
||||
|
|
Loading…
Reference in a new issue