Files
sdk/pkg/kernel/test/binary/location_test.dart
T
Jens Johansen e987ab1f54 [kernel] FileUriConstantExpression works with .location
We were missing a `_getLocationInEnclosingFile` implementation on
`FileUriConstantExpression`.

Change-Id: I3e8e65645f8ce4a6d9936aa079340e5853cccacc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355380
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-03-04 14:25:28 +00:00

71 lines
1.5 KiB
Dart

// Copyright (c) 2024, 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.
import 'dart:io';
import 'package:kernel/binary/ast_from_binary.dart';
import 'package:kernel/kernel.dart';
import 'find_sdk_dills.dart';
void main() {
List<File> dills = findSdkDills();
print("Found ${dills.length} dills!");
List<File> errors = [];
for (File dill in dills) {
if (!tryFile(dill)) {
errors.add(dill);
}
}
if (errors.isEmpty) {
print("All OK.");
} else {
print("Errors when reading:");
for (File error in errors) {
print(error);
}
exitCode = 1;
}
}
bool tryFile(File dill) {
print("Reading $dill");
List<int> bytes = dill.readAsBytesSync();
try {
Component component = new Component();
new BinaryBuilderWithMetadata(bytes).readComponent(component);
LocationTester tester = new LocationTester();
component.accept(tester);
return tester.ok;
} catch (e, st) {
print("Error for $dill:");
print(e);
print(st);
print("");
print("--------------------");
print("");
return false;
}
}
class LocationTester extends RecursiveVisitor {
bool ok = true;
@override
void defaultTreeNode(TreeNode node) {
super.defaultTreeNode(node);
try {
node.location;
} catch (e) {
ok = false;
print("Failure on $node: $e");
try {
print(node.parent?.location);
} catch (e) {}
}
}
}