Files
sdk/pkg/vm_service/test/field_script_test.dart
Ben Konyi 7eb95ad901 [ package:vm_service ] Enable recommended_lints for tests
Change-Id: I6e02b29fedcb92a6670665c70f6a9b34a06c5d9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335242
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
2023-11-13 19:54:40 +00:00

63 lines
1.7 KiB
Dart

// Copyright (c) 2023, 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.
library field_script_test;
import 'package:test/test.dart';
import 'package:vm_service/vm_service.dart';
import 'common/service_test_common.dart';
import 'common/test_helper.dart';
part 'field_script_other.dart';
void code() {
print(otherField);
}
final tests = <IsolateTest>[
hasPausedAtStart,
(VmService service, IsolateRef isolateRef) async {
final isolateId = isolateRef.id!;
final isolate = await service.getIsolate(isolateId);
final lib = await service.getObject(
isolateId,
isolate.rootLib!.id!,
) as Library;
final fields = lib.variables!;
expect(fields.length, 2);
for (final fieldRef in fields) {
final field = await service.getObject(isolateId, fieldRef.id!) as Field;
final location = field.location!;
if (field.name == 'tests') {
expect(
location.script!.uri!.endsWith('field_script_test.dart'),
true,
);
expect(location.line, 19);
expect(location.column, 7);
} else if (field.name == 'otherField') {
expect(
location.script!.uri!.endsWith('field_script_other.dart'),
true,
);
expect(location.line, 8);
expect(location.column, 5);
} else {
fail('Unexpected field: ${field.name}');
}
}
}
];
void main([args = const <String>[]]) => runIsolateTestsSynchronous(
args,
tests,
'field_script_test.dart',
testeeConcurrent: code,
pauseOnStart: true,
pauseOnExit: true,
);