34fb48bb8a
Migrates libraries dependent only on already migrated libraries. Change-Id: I0e85ee8dbc2afce031b92e0009e71c206a55af28 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179502 Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Jens Johansen <jensj@google.com>
86 lines
2.7 KiB
Dart
86 lines
2.7 KiB
Dart
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// @dart = 2.9
|
|
|
|
import 'dart:io' show Directory, Platform;
|
|
import 'package:_fe_analyzer_shared/src/testing/id.dart' show ActualData, Id;
|
|
import 'package:_fe_analyzer_shared/src/testing/id_testing.dart'
|
|
show DataInterpreter, StringDataInterpreter, runTests;
|
|
import 'package:_fe_analyzer_shared/src/testing/id_testing.dart';
|
|
import 'package:front_end/src/testing/id_testing_helper.dart'
|
|
show
|
|
CfeDataExtractor,
|
|
InternalCompilerResult,
|
|
DataComputer,
|
|
FormattedMessage,
|
|
TestConfig,
|
|
createUriForFileName,
|
|
defaultCfeConfig,
|
|
onFailure,
|
|
runTestFor;
|
|
import 'package:front_end/src/testing/id_testing_utils.dart';
|
|
import 'package:kernel/ast.dart' show Class, Member, TreeNode;
|
|
import 'package:kernel/ast.dart';
|
|
|
|
main(List<String> args) async {
|
|
Directory dataDir = new Directory.fromUri(Platform.script
|
|
.resolve('../../../_fe_analyzer_shared/test/constants/data'));
|
|
await runTests<String>(dataDir,
|
|
args: args,
|
|
createUriForFileName: createUriForFileName,
|
|
onFailure: onFailure,
|
|
runTest: runTestFor(const ConstantsDataComputer(), [defaultCfeConfig]));
|
|
}
|
|
|
|
class ConstantsDataComputer extends DataComputer<String> {
|
|
const ConstantsDataComputer();
|
|
|
|
@override
|
|
void computeMemberData(
|
|
TestConfig config,
|
|
InternalCompilerResult compilerResult,
|
|
Member member,
|
|
Map<Id, ActualData<String>> actualMap,
|
|
{bool verbose}) {
|
|
member.accept(new ConstantsDataExtractor(compilerResult, actualMap));
|
|
}
|
|
|
|
@override
|
|
void computeClassData(
|
|
TestConfig config,
|
|
InternalCompilerResult compilerResult,
|
|
Class cls,
|
|
Map<Id, ActualData<String>> actualMap,
|
|
{bool verbose}) {
|
|
new ConstantsDataExtractor(compilerResult, actualMap).computeForClass(cls);
|
|
}
|
|
|
|
@override
|
|
bool get supportsErrors => true;
|
|
|
|
/// Returns data corresponding to [error].
|
|
String computeErrorData(TestConfig config, InternalCompilerResult compiler,
|
|
Id id, List<FormattedMessage> errors) {
|
|
return errorsToText(errors);
|
|
}
|
|
|
|
@override
|
|
DataInterpreter<String> get dataValidator => const StringDataInterpreter();
|
|
}
|
|
|
|
class ConstantsDataExtractor extends CfeDataExtractor<String> {
|
|
ConstantsDataExtractor(InternalCompilerResult compilerResult,
|
|
Map<Id, ActualData<String>> actualMap)
|
|
: super(compilerResult, actualMap);
|
|
|
|
@override
|
|
String computeNodeValue(Id id, TreeNode node) {
|
|
if (node is ConstantExpression) {
|
|
return constantToText(node.constant);
|
|
}
|
|
return null;
|
|
}
|
|
}
|