[ package:vm_service ] Enable more lints
Change-Id: I1a7548297fa8562ea81f3d4e32db2aba53661189 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335960 Reviewed-by: Derek Xu <derekx@google.com> Commit-Queue: Ben Konyi <bkonyi@google.com>
This commit is contained in:
@@ -14,16 +14,16 @@ analyzer:
|
||||
|
||||
linter:
|
||||
rules:
|
||||
# always_declare_return_types: true
|
||||
# avoid_escaping_inner_quotes: true
|
||||
# avoid_void_async: true
|
||||
# cancel_subscriptions: true
|
||||
# close_sinks: true
|
||||
always_declare_return_types: true
|
||||
avoid_escaping_inner_quotes: true
|
||||
avoid_void_async: true
|
||||
cancel_subscriptions: true
|
||||
close_sinks: true
|
||||
constant_identifier_names: false # Disabled for LINE_N style constants in tests
|
||||
directives_ordering: true
|
||||
# no_adjacent_strings_in_list: true
|
||||
# prefer_final_locals: true
|
||||
# prefer_void_to_null: true
|
||||
# require_trailing_commas: true
|
||||
# unnecessary_parenthesis: true
|
||||
# unnecessary_raw_strings: true
|
||||
no_adjacent_strings_in_list: true
|
||||
prefer_final_locals: true
|
||||
prefer_void_to_null: true
|
||||
require_trailing_commas: true
|
||||
unnecessary_parenthesis: true
|
||||
unnecessary_raw_strings: true
|
||||
|
||||
@@ -89,7 +89,7 @@ Future testAsync(VmService service, IsolateRef isolateRef) async {
|
||||
unawaited(
|
||||
service.evaluate(isolateId, lib.id!, 'testerReady = true').then(
|
||||
(Response result) async {
|
||||
Obj res =
|
||||
final Obj res =
|
||||
await service.getObject(isolateId, (result as InstanceRef).id!);
|
||||
print(res);
|
||||
expect((res as Instance).valueAsString, equals('true'));
|
||||
@@ -114,7 +114,7 @@ Future testAsync(VmService service, IsolateRef isolateRef) async {
|
||||
|
||||
final tests = <IsolateTest>[testAsync];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'async_generator_breakpoint_test.dart',
|
||||
|
||||
@@ -20,9 +20,9 @@ const LINE_B = 34;
|
||||
const LINE_C = 35;
|
||||
// AUTOGENERATED END
|
||||
|
||||
foo() async {}
|
||||
Future<void> foo() async {}
|
||||
|
||||
doAsync(stop) async {
|
||||
Future<void> doAsync(stop) async {
|
||||
// Flutter issue 18877:
|
||||
// If a closure is defined in the context of an async method, stepping over
|
||||
// an await causes the implicit breakpoint to be set for that closure instead
|
||||
@@ -34,10 +34,9 @@ doAsync(stop) async {
|
||||
await foo(); // LINE_B
|
||||
await foo(); // LINE_C
|
||||
baz();
|
||||
return null;
|
||||
}
|
||||
|
||||
testMain() {
|
||||
void testMain() {
|
||||
// With two runs of doAsync floating around, async step should only cause
|
||||
// us to stop in the run we started in.
|
||||
doAsync(false);
|
||||
|
||||
@@ -7,29 +7,36 @@ import 'dart:developer';
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const int LINE_D = 18;
|
||||
const int LINE_A = 19;
|
||||
const int LINE_B = 20;
|
||||
const int LINE_C = 21;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_D = 25;
|
||||
const LINE_A = 26;
|
||||
const LINE_B = 27;
|
||||
const LINE_C = 28;
|
||||
// AUTOGENERATED END
|
||||
|
||||
foo() async {}
|
||||
Future<void> foo() async {}
|
||||
|
||||
doAsync(stop) async {
|
||||
if (stop) debugger();
|
||||
await foo(); // Line A.
|
||||
await foo(); // Line B.
|
||||
await foo(); // Line C.
|
||||
return null;
|
||||
Future<void> doAsync(bool stop) async {
|
||||
if (stop) debugger(); // LINE_D
|
||||
await foo(); // LINE_A
|
||||
await foo(); // LINE_B
|
||||
await foo(); // LINE_C
|
||||
return;
|
||||
}
|
||||
|
||||
testMain() {
|
||||
void testMain() {
|
||||
// With two runs of doAsync floating around, async step should only cause
|
||||
// us to stop in the run we started in.
|
||||
doAsync(false);
|
||||
doAsync(true);
|
||||
}
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_D),
|
||||
stepOver, // foo()
|
||||
@@ -45,7 +52,7 @@ var tests = <IsolateTest>[
|
||||
resumeIsolate,
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'async_next_test.dart',
|
||||
|
||||
@@ -10,25 +10,34 @@ import 'package:vm_service/vm_service.dart';
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const int LINE_A = 20;
|
||||
const int LINE_B = 26;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_A = 28;
|
||||
const LINE_B = 35;
|
||||
const LINE_C = 40;
|
||||
// AUTOGENERATED END
|
||||
|
||||
foo() {}
|
||||
void foo() {}
|
||||
|
||||
doAsync(param1) async {
|
||||
var local1 = param1 + 1;
|
||||
foo(); // Line A.
|
||||
Future<void> doAsync(int param1) async {
|
||||
final local1 = param1 + 1;
|
||||
foo(); // LINE_A
|
||||
// ignore: await_only_futures
|
||||
await local1;
|
||||
}
|
||||
|
||||
doAsyncStar(param2) async* {
|
||||
var local2 = param2 + 1;
|
||||
foo(); // Line B.
|
||||
Stream<int> doAsyncStar(int param2) async* {
|
||||
final local2 = param2 + 1;
|
||||
foo(); // LINE_B
|
||||
yield local2;
|
||||
}
|
||||
|
||||
testeeDo() {
|
||||
debugger();
|
||||
void testeeDo() {
|
||||
debugger(); // LINE_C
|
||||
|
||||
doAsync(1).then((_) {
|
||||
doAsyncStar(1).listen((_) {});
|
||||
@@ -36,9 +45,11 @@ testeeDo() {
|
||||
}
|
||||
|
||||
Future<void> checkAsyncVarDescriptors(
|
||||
VmService? service, IsolateRef? isolateRef) async {
|
||||
final isolateId = isolateRef!.id!;
|
||||
final stack = await service!.getStack(isolateId);
|
||||
VmService service,
|
||||
IsolateRef isolateRef,
|
||||
) async {
|
||||
final isolateId = isolateRef.id!;
|
||||
final stack = await service.getStack(isolateId);
|
||||
expect(stack.frames!.length, greaterThanOrEqualTo(1));
|
||||
final frame = stack.frames![0];
|
||||
final vars = frame.vars!.map((v) => v.name).join(' ');
|
||||
@@ -46,33 +57,34 @@ Future<void> checkAsyncVarDescriptors(
|
||||
}
|
||||
|
||||
Future checkAsyncStarVarDescriptors(
|
||||
VmService? service, IsolateRef? isolateRef) async {
|
||||
final isolateId = isolateRef!.id!;
|
||||
final stack = await service!.getStack(isolateId);
|
||||
VmService service,
|
||||
IsolateRef isolateRef,
|
||||
) async {
|
||||
final isolateId = isolateRef.id!;
|
||||
final stack = await service.getStack(isolateId);
|
||||
expect(stack.frames!.length, greaterThanOrEqualTo(1));
|
||||
final frame = stack.frames![0];
|
||||
final vars = frame.vars!.map((v) => v.name).join(' ');
|
||||
expect(vars, 'param2 local2'); // no :async_op et al
|
||||
}
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint, // debugger()
|
||||
final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_C),
|
||||
setBreakpointAtLine(LINE_A),
|
||||
setBreakpointAtLine(LINE_B),
|
||||
resumeIsolate,
|
||||
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_A),
|
||||
checkAsyncVarDescriptors,
|
||||
resumeIsolate,
|
||||
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_B),
|
||||
checkAsyncStarVarDescriptors,
|
||||
resumeIsolate,
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
Future<void> main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'async_scope_test.dart',
|
||||
|
||||
@@ -6,21 +6,28 @@ import 'dart:developer';
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const LINE_A = 19;
|
||||
const LINE_B = 20;
|
||||
const LINE_0 = 24;
|
||||
const LINE_C = 25;
|
||||
const LINE_D = 27;
|
||||
const LINE_E = 30;
|
||||
const LINE_F = 33;
|
||||
const LINE_G = 35;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_A = 26;
|
||||
const LINE_B = 27;
|
||||
const LINE_0 = 31;
|
||||
const LINE_C = 32;
|
||||
const LINE_D = 34;
|
||||
const LINE_E = 37;
|
||||
const LINE_F = 40;
|
||||
const LINE_G = 42;
|
||||
// AUTOGENERATED END
|
||||
|
||||
helper() async {
|
||||
Future<Never> helper() async {
|
||||
print('helper'); // LINE_A.
|
||||
throw 'a'; // LINE_B.
|
||||
}
|
||||
|
||||
testMain() async {
|
||||
Future<void> testMain() async {
|
||||
debugger(); // LINE_0.
|
||||
print('mmmmm'); // LINE_C.
|
||||
try {
|
||||
@@ -35,7 +42,7 @@ testMain() async {
|
||||
print('z'); // LINE_G.
|
||||
}
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_0), // debugger
|
||||
stepOver,
|
||||
@@ -73,10 +80,10 @@ var tests = <IsolateTest>[
|
||||
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_G), // print(z)
|
||||
resumeIsolate
|
||||
resumeIsolate,
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'async_single_step_exception_test.dart',
|
||||
|
||||
@@ -6,21 +6,28 @@ import 'dart:developer';
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const LINE_A = 16;
|
||||
const LINE_B = 17;
|
||||
const LINE_0 = 21;
|
||||
const LINE_C = 22;
|
||||
const LINE_D = 23;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_A = 23;
|
||||
const LINE_B = 24;
|
||||
const LINE_0 = 28;
|
||||
const LINE_C = 29;
|
||||
const LINE_D = 30;
|
||||
// AUTOGENERATED END
|
||||
|
||||
helper() async {
|
||||
Future<void> helper() async {
|
||||
print('helper'); // LINE_A.
|
||||
print('foobar'); // LINE_B.
|
||||
}
|
||||
|
||||
testMain() {
|
||||
Future<void> testMain() async {
|
||||
debugger(); // LINE_0.
|
||||
print('mmmmm'); // LINE_C.
|
||||
helper(); // LINE_D.
|
||||
await helper(); // LINE_D.
|
||||
print('z');
|
||||
}
|
||||
|
||||
@@ -42,10 +49,10 @@ var tests = <IsolateTest>[
|
||||
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_B),
|
||||
resumeIsolate
|
||||
resumeIsolate,
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTestsSynchronous(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'async_single_step_into_test.dart',
|
||||
|
||||
@@ -6,26 +6,33 @@ import 'dart:developer';
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const LINE_A = 17;
|
||||
const LINE_B = 18;
|
||||
const LINE_0 = 22;
|
||||
const LINE_C = 23;
|
||||
const LINE_D = 24;
|
||||
const LINE_E = 25;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_A = 24;
|
||||
const LINE_B = 25;
|
||||
const LINE_0 = 29;
|
||||
const LINE_C = 30;
|
||||
const LINE_D = 31;
|
||||
const LINE_E = 32;
|
||||
// AUTOGENERATED END
|
||||
|
||||
helper() async {
|
||||
Future<void> helper() async {
|
||||
print('helper'); // LINE_A.
|
||||
return null; // LINE_B.
|
||||
return; // LINE_B.
|
||||
}
|
||||
|
||||
testMain() async {
|
||||
Future<void> testMain() async {
|
||||
debugger(); // LINE_0.
|
||||
print('mmmmm'); // LINE_C.
|
||||
await helper(); // LINE_D.
|
||||
print('z'); // LINE_E.
|
||||
}
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_0), // debugger
|
||||
stepOver,
|
||||
@@ -51,10 +58,10 @@ var tests = <IsolateTest>[
|
||||
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_E), // arrive after the await.
|
||||
resumeIsolate
|
||||
resumeIsolate,
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'async_single_step_out_test.dart',
|
||||
|
||||
@@ -6,39 +6,45 @@ import 'dart:developer';
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const LINE_A = 21;
|
||||
const LINE_B = 22;
|
||||
const LINE_C = 26;
|
||||
const LINE_D = 30;
|
||||
const LINE_E = 36;
|
||||
const LINE_F = 37;
|
||||
const LINE_G = 28;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_A = 27;
|
||||
const LINE_B = 28;
|
||||
const LINE_C = 32;
|
||||
const LINE_G = 34;
|
||||
const LINE_0 = 35;
|
||||
const LINE_D = 36;
|
||||
const LINE_1 = 41;
|
||||
const LINE_E = 42;
|
||||
const LINE_F = 43;
|
||||
// AUTOGENERATED END
|
||||
|
||||
const LINE_0 = 29;
|
||||
const LINE_1 = 35;
|
||||
|
||||
foobar() async* {
|
||||
yield 1; // LINE_A.
|
||||
yield 2; // LINE_B.
|
||||
Stream<int> foobar() async* {
|
||||
yield 1; // LINE_A
|
||||
yield 2; // LINE_B
|
||||
}
|
||||
|
||||
helper() async {
|
||||
print('helper'); // LINE_C.
|
||||
Future<void> helper() async {
|
||||
print('helper'); // LINE_C
|
||||
// ignore: unused_local_variable
|
||||
await for (var i in foobar()) /* LINE_G. */ {
|
||||
debugger(); // LINE_0.
|
||||
print('loop'); // LINE_D.
|
||||
await for (var i in foobar()) /* LINE_G */ {
|
||||
debugger(); // LINE_0
|
||||
print('loop'); // LINE_D
|
||||
}
|
||||
}
|
||||
|
||||
testMain() {
|
||||
debugger(); // LINE_1.
|
||||
print('mmmmm'); // LINE_E.
|
||||
helper(); // LINE_F.
|
||||
Future<void> testMain() async {
|
||||
debugger(); // LINE_1
|
||||
print('mmmmm'); // LINE_E
|
||||
await helper(); // LINE_F
|
||||
print('z');
|
||||
}
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_1),
|
||||
stepOver, // debugger.
|
||||
@@ -86,7 +92,7 @@ var tests = <IsolateTest>[
|
||||
resumeIsolate,
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTestsSynchronous(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'async_star_single_step_into_test.dart',
|
||||
|
||||
@@ -6,42 +6,48 @@ import 'dart:developer';
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const LINE_A = 23;
|
||||
const LINE_B = 24;
|
||||
const LINE_C = 28;
|
||||
const LINE_D = 32;
|
||||
const LINE_E = 39;
|
||||
const LINE_F = 40;
|
||||
const LINE_G = 41;
|
||||
const LINE_H = 30;
|
||||
const LINE_I = 34;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_A = 29;
|
||||
const LINE_B = 30;
|
||||
const LINE_C = 34;
|
||||
const LINE_H = 36;
|
||||
const LINE_0 = 37;
|
||||
const LINE_D = 38;
|
||||
const LINE_I = 40;
|
||||
const LINE_1 = 44;
|
||||
const LINE_E = 45;
|
||||
const LINE_F = 46;
|
||||
const LINE_G = 47;
|
||||
// AUTOGENERATED END
|
||||
|
||||
const LINE_0 = 30;
|
||||
const LINE_1 = 38;
|
||||
|
||||
foobar() async* {
|
||||
Stream<int> foobar() async* {
|
||||
yield 1; // LINE_A.
|
||||
yield 2; // LINE_B.
|
||||
}
|
||||
|
||||
helper() async {
|
||||
Future<void> helper() async {
|
||||
print('helper'); // LINE_C.
|
||||
// ignore: unused_local_variable
|
||||
await for (var i in foobar()) /* LINE_H */ {
|
||||
debugger(); // LINE_0
|
||||
print('loop'); // LINE_D.
|
||||
}
|
||||
return null; // LINE_I.
|
||||
return; // LINE_I.
|
||||
}
|
||||
|
||||
testMain() {
|
||||
Future<void> testMain() async {
|
||||
debugger(); // LINE_1
|
||||
print('mmmmm'); // LINE_E.
|
||||
helper(); // LINE_F.
|
||||
await helper(); // LINE_F.
|
||||
print('z'); // LINE_G.
|
||||
}
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_1),
|
||||
stepOver, // debugger.
|
||||
@@ -110,7 +116,7 @@ var tests = <IsolateTest>[
|
||||
stoppedAtLine(LINE_I), // return null.
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTestsSynchronous(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'async_star_step_out_test.dart',
|
||||
|
||||
@@ -6,29 +6,35 @@ import 'dart:developer';
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const LINE_A = 19;
|
||||
const LINE_B = 20;
|
||||
const LINE_C = 21;
|
||||
const LINE_D = 26;
|
||||
const LINE_E = 27;
|
||||
const LINE_F = 28;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_A = 25;
|
||||
const LINE_B = 26;
|
||||
const LINE_C = 27;
|
||||
const LINE_0 = 31;
|
||||
const LINE_D = 32;
|
||||
const LINE_E = 33;
|
||||
const LINE_F = 34;
|
||||
// AUTOGENERATED END
|
||||
|
||||
const LINE_0 = 25;
|
||||
|
||||
helper() async {
|
||||
Future<void> helper() async {
|
||||
await null; // LINE_A.
|
||||
print('helper'); // LINE_B.
|
||||
print('foobar'); // LINE_C.
|
||||
}
|
||||
|
||||
testMain() async {
|
||||
Future<void> testMain() async {
|
||||
debugger(); // LINE_0.
|
||||
print('mmmmm'); // LINE_D.
|
||||
await helper(); // LINE_E.
|
||||
print('z'); // LINE_F.
|
||||
}
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_0),
|
||||
stepOver, // debugger.
|
||||
@@ -57,7 +63,7 @@ var tests = <IsolateTest>[
|
||||
stoppedAtLine(LINE_F),
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'async_step_out_test.dart',
|
||||
|
||||
@@ -11,36 +11,42 @@ import 'package:vm_service/vm_service.dart';
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const LINE_A = 30;
|
||||
const LINE_B = 36;
|
||||
const LINE_C = 40;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_0 = 35;
|
||||
const LINE_A = 36;
|
||||
const LINE_B = 42;
|
||||
const LINE_C = 46;
|
||||
// AUTOGENERATED END
|
||||
|
||||
const LINE_0 = 29;
|
||||
|
||||
notCalled() async {
|
||||
Future<void> notCalled() async {
|
||||
await null;
|
||||
await null;
|
||||
await null;
|
||||
await null;
|
||||
}
|
||||
|
||||
foobar() async {
|
||||
Future<void> foobar() async {
|
||||
await null;
|
||||
debugger(); // LINE_0.
|
||||
print('foobar'); // LINE_A.
|
||||
}
|
||||
|
||||
helper() async {
|
||||
Future<void> helper() async {
|
||||
await null;
|
||||
print('helper');
|
||||
await foobar(); // LINE_B.
|
||||
}
|
||||
|
||||
testMain() async {
|
||||
helper(); // LINE_C.
|
||||
Future<void> testMain() async {
|
||||
await helper(); // LINE_C.
|
||||
}
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_0),
|
||||
stepOver,
|
||||
@@ -49,9 +55,9 @@ var tests = <IsolateTest>[
|
||||
(VmService service, IsolateRef isolate) async {
|
||||
final isolateId = isolate.id!;
|
||||
// Verify awaiter stack trace is the current frame + the awaiter.
|
||||
Stack stack = await service.getStack(isolateId);
|
||||
final Stack stack = await service.getStack(isolateId);
|
||||
expect(stack.asyncCausalFrames, isNotNull);
|
||||
List<Frame> asyncCausalFrames = stack.asyncCausalFrames!;
|
||||
final List<Frame> asyncCausalFrames = stack.asyncCausalFrames!;
|
||||
expect(asyncCausalFrames.length, greaterThanOrEqualTo(4));
|
||||
expect(asyncCausalFrames[0].function!.name, 'foobar');
|
||||
expect(asyncCausalFrames[1].kind, FrameKind.kAsyncSuspensionMarker);
|
||||
@@ -60,7 +66,7 @@ var tests = <IsolateTest>[
|
||||
},
|
||||
];
|
||||
|
||||
main(args) => runIsolateTestsSynchronous(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'awaiter_async_stack_contents_2_test.dart',
|
||||
|
||||
@@ -11,41 +11,47 @@ import 'package:vm_service/vm_service.dart';
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const LINE_C = 26;
|
||||
const LINE_A = 32;
|
||||
const LINE_B = 38;
|
||||
const LINE_D = 33;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_0 = 31;
|
||||
const LINE_C = 32;
|
||||
const LINE_1 = 37;
|
||||
const LINE_A = 38;
|
||||
const LINE_D = 39;
|
||||
const LINE_2 = 43;
|
||||
const LINE_B = 44;
|
||||
// AUTOGENERATED END
|
||||
|
||||
const LINE_0 = 25;
|
||||
const LINE_1 = 31;
|
||||
const LINE_2 = 37;
|
||||
|
||||
foobar() async {
|
||||
Future<void> foobar() async {
|
||||
await null;
|
||||
debugger(); // LINE_0.
|
||||
print('foobar'); // LINE_C.
|
||||
}
|
||||
|
||||
helper() async {
|
||||
Future<void> helper() async {
|
||||
await null;
|
||||
debugger(); // LINE_1.
|
||||
print('helper'); // LINE_A.
|
||||
await foobar(); // LINE_D
|
||||
}
|
||||
|
||||
testMain() {
|
||||
Future<void> testMain() async {
|
||||
debugger(); // LINE_2.
|
||||
helper(); // LINE_B.
|
||||
await helper(); // LINE_B.
|
||||
}
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_2),
|
||||
stepOver,
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_B),
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
Stack stack = await service.getStack(isolateRef.id!);
|
||||
final Stack stack = await service.getStack(isolateRef.id!);
|
||||
// No awaiter frames because we are in a completely synchronous stack.
|
||||
expect(stack.asyncCausalFrames, isNull);
|
||||
},
|
||||
@@ -63,9 +69,9 @@ var tests = <IsolateTest>[
|
||||
stoppedAtLine(LINE_C),
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
// Verify awaiter stack trace is the current frame + the awaiter.
|
||||
Stack stack = await service.getStack(isolateRef.id!);
|
||||
final Stack stack = await service.getStack(isolateRef.id!);
|
||||
expect(stack.asyncCausalFrames, isNotNull);
|
||||
List<Frame> asyncCausalFrames = stack.asyncCausalFrames!;
|
||||
final List<Frame> asyncCausalFrames = stack.asyncCausalFrames!;
|
||||
|
||||
expect(asyncCausalFrames.length, greaterThanOrEqualTo(4));
|
||||
expect(asyncCausalFrames[0].function!.name, 'foobar');
|
||||
@@ -76,7 +82,7 @@ var tests = <IsolateTest>[
|
||||
},
|
||||
];
|
||||
|
||||
main(args) => runIsolateTestsSynchronous(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'awaiter_async_stack_contents_test.dart',
|
||||
|
||||
@@ -83,8 +83,8 @@ var tests = <IsolateTest>[
|
||||
'compiled': true,
|
||||
'branchCoverage': {
|
||||
'hits': [],
|
||||
'misses': [397, 426, 444, 474, 507]
|
||||
}
|
||||
'misses': [397, 426, 444, 474, 507],
|
||||
},
|
||||
},
|
||||
reportLines: false,
|
||||
),
|
||||
@@ -96,8 +96,8 @@ var tests = <IsolateTest>[
|
||||
'compiled': true,
|
||||
'branchCoverage': {
|
||||
'hits': [],
|
||||
'misses': [11, 12, 13, 15, 18]
|
||||
}
|
||||
'misses': [11, 12, 13, 15, 18],
|
||||
},
|
||||
},
|
||||
reportLines: true,
|
||||
),
|
||||
@@ -111,8 +111,8 @@ var tests = <IsolateTest>[
|
||||
'compiled': true,
|
||||
'branchCoverage': {
|
||||
'hits': [397, 426, 474],
|
||||
'misses': [444, 507]
|
||||
}
|
||||
'misses': [444, 507],
|
||||
},
|
||||
},
|
||||
reportLines: false,
|
||||
),
|
||||
@@ -124,14 +124,14 @@ var tests = <IsolateTest>[
|
||||
'compiled': true,
|
||||
'branchCoverage': {
|
||||
'hits': [11, 12, 15],
|
||||
'misses': [13, 18]
|
||||
}
|
||||
'misses': [13, 18],
|
||||
},
|
||||
},
|
||||
reportLines: true,
|
||||
),
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
Future<void> main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'branch_coverage_test.dart',
|
||||
|
||||
@@ -13,7 +13,7 @@ import 'common/test_helper.dart';
|
||||
// Line in core/print.dart
|
||||
const int LINE_A = 19;
|
||||
|
||||
testMain() {
|
||||
void testMain() {
|
||||
debugger();
|
||||
print('1');
|
||||
print('2');
|
||||
@@ -46,7 +46,7 @@ final tests = <IsolateTest>[
|
||||
resumeIsolate,
|
||||
];
|
||||
|
||||
main(args) => runIsolateTests(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'break_on_dart_colon_test.dart',
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'common/test_helper.dart';
|
||||
|
||||
class Foo {}
|
||||
|
||||
code() {
|
||||
void code() {
|
||||
Foo();
|
||||
}
|
||||
|
||||
@@ -53,8 +53,7 @@ final tests = <IsolateTest>[
|
||||
await service.addBreakpointAtEntry(isolateId, fooFunc.id!);
|
||||
fail('Successfully added breakpoint at an invalid location!');
|
||||
} on RPCError catch (e) {
|
||||
// TODO(bkonyi): add this error code to package:vm_service
|
||||
expect(e.code, 102);
|
||||
expect(e.code, RPCErrorKind.kCannotAddBreakpoint.code);
|
||||
expect(e.message, 'Cannot add breakpoint');
|
||||
expect(e.details, contains('Cannot add breakpoint at function'));
|
||||
}
|
||||
@@ -63,13 +62,11 @@ final tests = <IsolateTest>[
|
||||
},
|
||||
];
|
||||
|
||||
void main(List<String> args) {
|
||||
runIsolateTestsSynchronous(
|
||||
args,
|
||||
tests,
|
||||
'break_on_default_constructor_test.dart',
|
||||
testeeConcurrent: code,
|
||||
pauseOnStart: true,
|
||||
pauseOnExit: true,
|
||||
);
|
||||
}
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'break_on_default_constructor_test.dart',
|
||||
testeeConcurrent: code,
|
||||
pauseOnStart: true,
|
||||
pauseOnExit: true,
|
||||
);
|
||||
|
||||
@@ -17,9 +17,16 @@ import 'package:vm_service/vm_service.dart';
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const int LINE_A = 24;
|
||||
const int LINE_B = 36;
|
||||
const int LINE_C = 42;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_A = 31;
|
||||
const LINE_B = 45;
|
||||
const LINE_C = 54;
|
||||
// AUTOGENERATED END
|
||||
|
||||
/* LINE_A */ void foo(args) {
|
||||
print('${dart_isolate.Isolate.current.debugName}: $args');
|
||||
@@ -30,13 +37,18 @@ const int LINE_C = 42;
|
||||
|
||||
Future<void> testMain() async {
|
||||
final rps = List<dart_isolate.ReceivePort>.generate(
|
||||
nIsolates, (i) => dart_isolate.ReceivePort());
|
||||
nIsolates,
|
||||
(i) => dart_isolate.ReceivePort(),
|
||||
);
|
||||
|
||||
print('Isolate count: $nIsolates\n\n\n\n');
|
||||
debugger(); // LINE_B
|
||||
for (int i = 0; i < nIsolates; i++) {
|
||||
await dart_isolate.Isolate.spawn(foo, [rps[i].sendPort, i],
|
||||
debugName: 'foo$i');
|
||||
await dart_isolate.Isolate.spawn(
|
||||
foo,
|
||||
[rps[i].sendPort, i],
|
||||
debugName: 'foo$i',
|
||||
);
|
||||
}
|
||||
print(await Future.wait(rps.map((rp) => rp.first)));
|
||||
debugger(); // LINE_C
|
||||
@@ -105,7 +117,9 @@ final tests = <IsolateTest>[
|
||||
final stack = await service.getStack(isolateId);
|
||||
final top = stack.frames![0];
|
||||
final script = await service.getObject(
|
||||
isolateId, top.location!.script!.id!) as Script;
|
||||
isolateId,
|
||||
top.location!.script!.id!,
|
||||
) as Script;
|
||||
expect(
|
||||
script.getLineNumberFromTokenPos(top.location!.tokenPos!),
|
||||
LINE_A,
|
||||
|
||||
@@ -26,11 +26,12 @@ const String file = 'break_on_unhandled_exception_test.dart';
|
||||
|
||||
Future<int> testFunction() async {
|
||||
try {
|
||||
var client = HttpClient();
|
||||
final client = HttpClient();
|
||||
final urlstr = 'https://www.bbc.co.uk/';
|
||||
final uri = Uri.parse(urlstr);
|
||||
var response = await client.getUrl(uri);
|
||||
final response = await client.getUrl(uri);
|
||||
Expect.equals(urlstr, response.uri.toString());
|
||||
await response.close();
|
||||
return 0;
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
@@ -38,7 +39,7 @@ Future<int> testFunction() async {
|
||||
}
|
||||
}
|
||||
|
||||
void testMain() async {
|
||||
Future<void> testMain() async {
|
||||
debugger();
|
||||
final ret = await testFunction();
|
||||
Expect.equals(ret, 0);
|
||||
|
||||
@@ -62,19 +62,25 @@ var tests = <IsolateTest>[
|
||||
futureBpt = await service.getObject(isolateId, futureBpt.id!) as Breakpoint;
|
||||
expect(futureBpt.resolved, isTrue);
|
||||
expect(
|
||||
script.getLineNumberFromTokenPos(futureBpt.location!.tokenPos), LINE);
|
||||
script.getLineNumberFromTokenPos(futureBpt.location!.tokenPos),
|
||||
LINE,
|
||||
);
|
||||
expect(futureBpt.location!.line, LINE);
|
||||
expect(
|
||||
script.getColumnNumberFromTokenPos(futureBpt.location!.tokenPos), COL);
|
||||
script.getColumnNumberFromTokenPos(futureBpt.location!.tokenPos),
|
||||
COL,
|
||||
);
|
||||
expect(futureBpt.location!.column, COL);
|
||||
|
||||
// Remove the breakpoints.
|
||||
expect((await service.removeBreakpoint(isolateId, futureBpt.id!)).type,
|
||||
'Success');
|
||||
expect(
|
||||
(await service.removeBreakpoint(isolateId, futureBpt.id!)).type,
|
||||
'Success',
|
||||
);
|
||||
},
|
||||
];
|
||||
|
||||
main(args) => runIsolateTests(
|
||||
Future<void> main(args) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'breakpoint_async_break_test.dart',
|
||||
|
||||
@@ -105,7 +105,7 @@ final tests = <IsolateTest>[
|
||||
checkRecordedStops(stops, expected),
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
Future<void> main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
fileName,
|
||||
|
||||
@@ -25,14 +25,14 @@ void code() {
|
||||
final stops = <String>[];
|
||||
const expected = <String>[
|
||||
'$shortFile:${LINE + 0}:5', // on 'print'
|
||||
'$shortFile:${LINE + 1}:3' // on class ending '}'
|
||||
'$shortFile:${LINE + 1}:3', // on class ending '}'
|
||||
];
|
||||
|
||||
final tests = <IsolateTest>[
|
||||
hasPausedAtStart,
|
||||
setBreakpointAtUriAndLine(breakpointFile.toString(), LINE),
|
||||
runStepThroughProgramRecordingStops(stops),
|
||||
checkRecordedStops(stops, expected)
|
||||
checkRecordedStops(stops, expected),
|
||||
];
|
||||
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
|
||||
@@ -19,14 +19,14 @@ void code() {
|
||||
final stops = <String>[];
|
||||
const expected = <String>[
|
||||
'$shortFile:${LINE + 0}:5', // on 'print'
|
||||
'$shortFile:${LINE + 1}:3' // on class ending '}'
|
||||
'$shortFile:${LINE + 1}:3', // on class ending '}'
|
||||
];
|
||||
|
||||
final tests = <IsolateTest>[
|
||||
hasPausedAtStart,
|
||||
setBreakpointAtUriAndLine(breakpointFile, LINE),
|
||||
runStepThroughProgramRecordingStops(stops),
|
||||
checkRecordedStops(stops, expected)
|
||||
checkRecordedStops(stops, expected),
|
||||
];
|
||||
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
|
||||
@@ -12,7 +12,7 @@ part 'breakpoint_in_parts_class_part.dart';
|
||||
const int LINE = 88;
|
||||
const String file = 'breakpoint_in_parts_class_part.dart';
|
||||
|
||||
code() {
|
||||
void code() {
|
||||
final foo = Foo10('Foo!');
|
||||
print(foo);
|
||||
}
|
||||
@@ -21,14 +21,14 @@ final stops = <String>[];
|
||||
|
||||
const expected = <String>[
|
||||
'$file:${LINE + 0}:5', // on 'print'
|
||||
'$file:${LINE + 1}:3' // on class ending '}'
|
||||
'$file:${LINE + 1}:3', // on class ending '}'
|
||||
];
|
||||
|
||||
final tests = <IsolateTest>[
|
||||
hasPausedAtStart,
|
||||
setBreakpointAtUriAndLine(file, LINE),
|
||||
runStepThroughProgramRecordingStops(stops),
|
||||
checkRecordedStops(stops, expected)
|
||||
checkRecordedStops(stops, expected),
|
||||
];
|
||||
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
|
||||
@@ -15,7 +15,7 @@ const int LINE_A = 15;
|
||||
// print() within barz()
|
||||
const int LINE_B = 11;
|
||||
|
||||
testMain() {
|
||||
void testMain() {
|
||||
test_pkg.fooz();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ var tests = <IsolateTest>[
|
||||
final isolateId = isolateRef.id!;
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
|
||||
LibraryRef hasPartRef = isolate.libraries!.firstWhere(
|
||||
final LibraryRef hasPartRef = isolate.libraries!.firstWhere(
|
||||
(LibraryRef library) => library.uri == file,
|
||||
);
|
||||
|
||||
@@ -37,7 +37,7 @@ var tests = <IsolateTest>[
|
||||
// Breakpoints are allowed to be set (before marking library as
|
||||
// non-debuggable) but are not hit when running (after marking library
|
||||
// as non-debuggable).
|
||||
ScriptRef script = hasPart.scripts!.firstWhere(
|
||||
final ScriptRef script = hasPart.scripts!.firstWhere(
|
||||
(ScriptRef script) => script.uri == file,
|
||||
);
|
||||
Breakpoint bpt = await service.addBreakpoint(isolateId, script.id!, LINE_A);
|
||||
@@ -73,7 +73,7 @@ var tests = <IsolateTest>[
|
||||
hasStoppedAtExit,
|
||||
];
|
||||
|
||||
main(args) => runIsolateTests(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'breakpoint_non_debuggable_library_test.dart',
|
||||
|
||||
@@ -10,11 +10,11 @@ import 'common/test_helper.dart';
|
||||
const int LINE = 18;
|
||||
const String file = 'breakpoint_on_if_null_1_test.dart';
|
||||
|
||||
code() {
|
||||
void code() {
|
||||
foo(42);
|
||||
}
|
||||
|
||||
foo(dynamic args) {
|
||||
void foo(dynamic args) {
|
||||
if (args == null) {
|
||||
print('was null');
|
||||
}
|
||||
@@ -26,9 +26,9 @@ foo(dynamic args) {
|
||||
}
|
||||
}
|
||||
|
||||
List<String> stops = [];
|
||||
final stops = <String>[];
|
||||
|
||||
List<String> expected = [
|
||||
const expected = <String>[
|
||||
'$file:${LINE + 0}:12', // on '=='
|
||||
'$file:${LINE + 3}:12', // on '!='
|
||||
'$file:${LINE + 4}:5', // on 'print'
|
||||
@@ -37,20 +37,18 @@ List<String> expected = [
|
||||
'$file:${LINE + 9}:1', // on ending '}'
|
||||
];
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
final tests = <IsolateTest>[
|
||||
hasPausedAtStart,
|
||||
setBreakpointAtUriAndLine(file, LINE),
|
||||
runStepThroughProgramRecordingStops(stops),
|
||||
checkRecordedStops(stops, expected)
|
||||
checkRecordedStops(stops, expected),
|
||||
];
|
||||
|
||||
main(args) {
|
||||
runIsolateTestsSynchronous(
|
||||
args,
|
||||
tests,
|
||||
'breakpoint_on_if_null_1_test.dart',
|
||||
testeeConcurrent: code,
|
||||
pauseOnStart: true,
|
||||
pauseOnExit: true,
|
||||
);
|
||||
}
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'breakpoint_on_if_null_1_test.dart',
|
||||
testeeConcurrent: code,
|
||||
pauseOnStart: true,
|
||||
pauseOnExit: true,
|
||||
);
|
||||
|
||||
@@ -12,12 +12,12 @@ const String file = 'breakpoint_on_if_null_2_test.dart';
|
||||
|
||||
dynamic compareWithMe = 43;
|
||||
|
||||
code() {
|
||||
void code() {
|
||||
compareWithMe = null;
|
||||
foo(42);
|
||||
}
|
||||
|
||||
foo(dynamic args) {
|
||||
void foo(dynamic args) {
|
||||
if (args == compareWithMe) {
|
||||
print('was null');
|
||||
}
|
||||
@@ -29,9 +29,9 @@ foo(dynamic args) {
|
||||
}
|
||||
}
|
||||
|
||||
List<String> stops = [];
|
||||
final stops = <String>[];
|
||||
|
||||
List<String> expected = [
|
||||
const expected = <String>[
|
||||
'$file:${LINE + 0}:12', // on '=='
|
||||
'$file:${LINE + 3}:12', // on '!='
|
||||
'$file:${LINE + 4}:5', // on 'print'
|
||||
@@ -40,20 +40,18 @@ List<String> expected = [
|
||||
'$file:${LINE + 9}:1', // on ending '}'
|
||||
];
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
final tests = <IsolateTest>[
|
||||
hasPausedAtStart,
|
||||
setBreakpointAtUriAndLine(file, LINE),
|
||||
runStepThroughProgramRecordingStops(stops),
|
||||
checkRecordedStops(stops, expected)
|
||||
checkRecordedStops(stops, expected),
|
||||
];
|
||||
|
||||
main(args) {
|
||||
runIsolateTestsSynchronous(
|
||||
args,
|
||||
tests,
|
||||
'breakpoint_on_if_null_2_test.dart',
|
||||
testeeConcurrent: code,
|
||||
pauseOnStart: true,
|
||||
pauseOnExit: true,
|
||||
);
|
||||
}
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'breakpoint_on_if_null_2_test.dart',
|
||||
testeeConcurrent: code,
|
||||
pauseOnStart: true,
|
||||
pauseOnExit: true,
|
||||
);
|
||||
|
||||
@@ -10,11 +10,11 @@ import 'common/test_helper.dart';
|
||||
const int LINE = 17;
|
||||
const String file = 'breakpoint_on_if_null_3_test.dart';
|
||||
|
||||
code() {
|
||||
void code() {
|
||||
foo(42);
|
||||
}
|
||||
|
||||
foo(dynamic args) {
|
||||
void foo(dynamic args) {
|
||||
if (args == null) {
|
||||
print('was null');
|
||||
}
|
||||
@@ -26,10 +26,10 @@ foo(dynamic args) {
|
||||
}
|
||||
}
|
||||
|
||||
List<String> stops = [];
|
||||
final stops = <String>[];
|
||||
|
||||
List<String> expected = [
|
||||
'$file:${LINE + 0}:13', // on 'args'
|
||||
const expected = <String>[
|
||||
'$file:${LINE + 0}:18', // on 'args'
|
||||
'$file:${LINE + 1}:12', // on '=='
|
||||
'$file:${LINE + 4}:12', // on '!='
|
||||
'$file:${LINE + 5}:5', // on 'print'
|
||||
@@ -38,20 +38,18 @@ List<String> expected = [
|
||||
'$file:${LINE + 10}:1', // on ending '}'
|
||||
];
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
final tests = <IsolateTest>[
|
||||
hasPausedAtStart,
|
||||
setBreakpointAtUriAndLine(file, LINE),
|
||||
runStepThroughProgramRecordingStops(stops),
|
||||
checkRecordedStops(stops, expected)
|
||||
checkRecordedStops(stops, expected),
|
||||
];
|
||||
|
||||
main(args) {
|
||||
runIsolateTestsSynchronous(
|
||||
args,
|
||||
tests,
|
||||
'breakpoint_on_if_null_3_test.dart',
|
||||
testeeConcurrent: code,
|
||||
pauseOnStart: true,
|
||||
pauseOnExit: true,
|
||||
);
|
||||
}
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'breakpoint_on_if_null_3_test.dart',
|
||||
testeeConcurrent: code,
|
||||
pauseOnStart: true,
|
||||
pauseOnExit: true,
|
||||
);
|
||||
|
||||
@@ -12,12 +12,12 @@ const String file = 'breakpoint_on_if_null_4_test.dart';
|
||||
|
||||
dynamic compareWithMe = 43;
|
||||
|
||||
code() {
|
||||
void code() {
|
||||
compareWithMe = null;
|
||||
foo(42);
|
||||
}
|
||||
|
||||
foo(dynamic args) {
|
||||
void foo(dynamic args) {
|
||||
if (args == compareWithMe) {
|
||||
print('was null');
|
||||
}
|
||||
@@ -29,10 +29,10 @@ foo(dynamic args) {
|
||||
}
|
||||
}
|
||||
|
||||
List<String> stops = [];
|
||||
final stops = <String>[];
|
||||
|
||||
List<String> expected = [
|
||||
'$file:${LINE + 0}:13', // on 'args'
|
||||
const expected = <String>[
|
||||
'$file:${LINE + 0}:18', // on 'args'
|
||||
'$file:${LINE + 1}:12', // on '=='
|
||||
'$file:${LINE + 4}:12', // on '!='
|
||||
'$file:${LINE + 5}:5', // on 'print'
|
||||
@@ -41,20 +41,18 @@ List<String> expected = [
|
||||
'$file:${LINE + 10}:1', // on ending '}'
|
||||
];
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
final tests = <IsolateTest>[
|
||||
hasPausedAtStart,
|
||||
setBreakpointAtUriAndLine(file, LINE),
|
||||
runStepThroughProgramRecordingStops(stops),
|
||||
checkRecordedStops(stops, expected)
|
||||
checkRecordedStops(stops, expected),
|
||||
];
|
||||
|
||||
main(args) {
|
||||
runIsolateTestsSynchronous(
|
||||
args,
|
||||
tests,
|
||||
'breakpoint_on_if_null_4_test.dart',
|
||||
testeeConcurrent: code,
|
||||
pauseOnStart: true,
|
||||
pauseOnExit: true,
|
||||
);
|
||||
}
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'breakpoint_on_if_null_4_test.dart',
|
||||
testeeConcurrent: code,
|
||||
pauseOnStart: true,
|
||||
pauseOnExit: true,
|
||||
);
|
||||
|
||||
@@ -7,43 +7,49 @@
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const int LINE = 14;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_A = 22;
|
||||
// AUTOGENERATED END
|
||||
|
||||
const String file = 'breakpoint_on_record_assignment_test.dart';
|
||||
|
||||
testMain() {
|
||||
(int, String name, bool) triple = (3, 'f', true);
|
||||
({int n, String s}) pair = (n: 2, s: 's');
|
||||
(bool, num, {int n, String s}) quad = (false, 3.14, n: 7, s: 'd');
|
||||
void testMain() {
|
||||
final (int, String name, bool) triple = (3, 'f', true); // LINE_A
|
||||
final ({int n, String s}) pair = (n: 2, s: 's');
|
||||
final (bool, num, {int n, String s}) quad = (false, 3.14, n: 7, s: 'd');
|
||||
print('$pair $triple $quad');
|
||||
}
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
final tests = <IsolateTest>[
|
||||
hasPausedAtStart,
|
||||
setBreakpointAtUriAndLine(file, LINE),
|
||||
setBreakpointAtUriAndLine(file, LINE_A),
|
||||
resumeIsolate,
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE),
|
||||
setBreakpointAtUriAndLine(file, LINE + 1),
|
||||
stoppedAtLine(LINE_A),
|
||||
setBreakpointAtUriAndLine(file, LINE_A + 1),
|
||||
resumeIsolate,
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE + 1),
|
||||
setBreakpointAtUriAndLine(file, LINE + 2),
|
||||
stoppedAtLine(LINE_A + 1),
|
||||
setBreakpointAtUriAndLine(file, LINE_A + 2),
|
||||
resumeIsolate,
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE + 2),
|
||||
setBreakpointAtUriAndLine(file, LINE + 3),
|
||||
stoppedAtLine(LINE_A + 2),
|
||||
setBreakpointAtUriAndLine(file, LINE_A + 3),
|
||||
resumeIsolate,
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE + 3),
|
||||
stoppedAtLine(LINE_A + 3),
|
||||
];
|
||||
|
||||
main(args) {
|
||||
runIsolateTestsSynchronous(
|
||||
args,
|
||||
tests,
|
||||
'breakpoint_on_record_assignment_test.dart',
|
||||
testeeConcurrent: testMain,
|
||||
pauseOnStart: true,
|
||||
pauseOnExit: true,
|
||||
);
|
||||
}
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'breakpoint_on_record_assignment_test.dart',
|
||||
testeeConcurrent: testMain,
|
||||
pauseOnStart: true,
|
||||
pauseOnExit: true,
|
||||
);
|
||||
|
||||
@@ -13,7 +13,7 @@ const int LINE_C = 22;
|
||||
const int LINE_D = 24;
|
||||
|
||||
void testMain() {
|
||||
bool foo = false;
|
||||
final bool foo = false;
|
||||
if (foo) {} // LINE_A
|
||||
|
||||
const bar = false;
|
||||
|
||||
@@ -12,7 +12,7 @@ const int LINE = 9;
|
||||
const String breakpointFile = 'package:test_package/the_part_2.dart';
|
||||
const String shortFile = 'the_part_2.dart';
|
||||
|
||||
code() {
|
||||
void code() {
|
||||
has_part.bar();
|
||||
}
|
||||
|
||||
@@ -20,14 +20,14 @@ final stops = <String>[];
|
||||
|
||||
const expected = <String>[
|
||||
'$shortFile:${LINE + 0}:3', // on 'print'
|
||||
'$shortFile:${LINE + 1}:1' // on class ending '}'
|
||||
'$shortFile:${LINE + 1}:1', // on class ending '}'
|
||||
];
|
||||
|
||||
final tests = <IsolateTest>[
|
||||
hasPausedAtStart,
|
||||
setBreakpointAtUriAndLine(breakpointFile, LINE),
|
||||
runStepThroughProgramRecordingStops(stops),
|
||||
checkRecordedStops(stops, expected)
|
||||
checkRecordedStops(stops, expected),
|
||||
];
|
||||
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
|
||||
@@ -15,61 +15,72 @@ import 'package:vm_service/vm_service.dart';
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const int LINE_A = 29;
|
||||
const int LINE_B = 30;
|
||||
const int LINE_C = 31;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_A = 35;
|
||||
const LINE_B = 37;
|
||||
const LINE_C = 38;
|
||||
const LINE_D = 39;
|
||||
// AUTOGENERATED END
|
||||
|
||||
class NotGeneric {}
|
||||
|
||||
testeeMain() {
|
||||
void testeeMain() {
|
||||
final x = List<dynamic>.filled(1, null);
|
||||
final y = 7;
|
||||
debugger();
|
||||
debugger(); // LINE_A
|
||||
print('Statement');
|
||||
x[0] = 3; // Line A.
|
||||
x is NotGeneric; // Line B.
|
||||
y & 4; // Line C.
|
||||
x[0] = 3; // LINE_B
|
||||
x is NotGeneric; // LINE_C
|
||||
y & 4; // LINE_D
|
||||
}
|
||||
|
||||
final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_A),
|
||||
|
||||
// Add breakpoints.
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
final isolateId = isolateRef.id!;
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
Library rootLib =
|
||||
final Library rootLib =
|
||||
await service.getObject(isolateId, isolate.rootLib!.id!) as Library;
|
||||
|
||||
final script =
|
||||
await service.getObject(isolateId, rootLib.scripts![0].id!) as Script;
|
||||
final scriptId = script.id!;
|
||||
|
||||
final bpt1 = await service.addBreakpoint(isolateId, scriptId, LINE_A);
|
||||
final bpt1 = await service.addBreakpoint(isolateId, scriptId, LINE_B);
|
||||
print(bpt1);
|
||||
expect(bpt1.resolved, isTrue);
|
||||
expect(script.getLineNumberFromTokenPos(bpt1.location!.tokenPos),
|
||||
equals(LINE_A));
|
||||
expect(
|
||||
script.getLineNumberFromTokenPos(bpt1.location!.tokenPos),
|
||||
equals(LINE_B),
|
||||
);
|
||||
|
||||
final bpt2 = await service.addBreakpoint(isolateId, scriptId, LINE_B);
|
||||
final bpt2 = await service.addBreakpoint(isolateId, scriptId, LINE_C);
|
||||
print(bpt2);
|
||||
expect(bpt2.resolved, isTrue);
|
||||
expect(script.getLineNumberFromTokenPos(bpt2.location!.tokenPos),
|
||||
equals(LINE_B));
|
||||
expect(
|
||||
script.getLineNumberFromTokenPos(bpt2.location!.tokenPos),
|
||||
equals(LINE_C),
|
||||
);
|
||||
|
||||
final bpt3 = await service.addBreakpoint(isolateId, scriptId, LINE_C);
|
||||
final bpt3 = await service.addBreakpoint(isolateId, scriptId, LINE_D);
|
||||
print(bpt3);
|
||||
expect(bpt3.resolved, isTrue);
|
||||
expect(script.getLineNumberFromTokenPos(bpt3.location!.tokenPos),
|
||||
equals(LINE_C));
|
||||
expect(
|
||||
script.getLineNumberFromTokenPos(bpt3.location!.tokenPos),
|
||||
equals(LINE_D),
|
||||
);
|
||||
},
|
||||
|
||||
resumeIsolate,
|
||||
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_A),
|
||||
resumeIsolate,
|
||||
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_B),
|
||||
resumeIsolate,
|
||||
@@ -77,9 +88,13 @@ final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_C),
|
||||
resumeIsolate,
|
||||
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_D),
|
||||
resumeIsolate,
|
||||
];
|
||||
|
||||
main(args) => runIsolateTests(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'breakpoint_two_args_checked_test.dart',
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
mixin class Foo {
|
||||
foo() {
|
||||
void foo() {
|
||||
print('I should be breakable!');
|
||||
}
|
||||
}
|
||||
|
||||
class Bar {
|
||||
bar() {
|
||||
void bar() {
|
||||
print('I should be breakable too!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,13 @@ const int lib3Bp1 = 7;
|
||||
const int lib3Bp2 = 13;
|
||||
|
||||
void code() {
|
||||
Test1 test1 = Test1();
|
||||
final Test1 test1 = Test1();
|
||||
test1.foo();
|
||||
Test2 test2 = Test2();
|
||||
final Test2 test2 = Test2();
|
||||
test2.foo();
|
||||
Foo foo = Foo();
|
||||
final Foo foo = Foo();
|
||||
foo.foo();
|
||||
Bar bar = Bar();
|
||||
final Bar bar = Bar();
|
||||
bar.bar();
|
||||
test1.foo();
|
||||
test2.foo();
|
||||
@@ -29,9 +29,9 @@ void code() {
|
||||
bar.bar();
|
||||
}
|
||||
|
||||
List<String> stops = [];
|
||||
final stops = <String>[];
|
||||
|
||||
List<String> expected = [
|
||||
const expected = <String>[
|
||||
'$lib3Filename:$lib3Bp1:5 ($testFilename:${testCodeLineStart + 2}:9)',
|
||||
'$lib3Filename:$lib3Bp1:5 ($testFilename:${testCodeLineStart + 4}:9)',
|
||||
'$lib3Filename:$lib3Bp1:5 ($testFilename:${testCodeLineStart + 6}:7)',
|
||||
@@ -42,21 +42,19 @@ List<String> expected = [
|
||||
'$lib3Filename:$lib3Bp2:5 ($testFilename:${testCodeLineStart + 12}:7)',
|
||||
];
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
final tests = <IsolateTest>[
|
||||
hasPausedAtStart,
|
||||
setBreakpointAtUriAndLine(lib3Filename, lib3Bp1),
|
||||
setBreakpointAtUriAndLine(lib3Filename, lib3Bp2),
|
||||
resumeProgramRecordingStops(stops, true),
|
||||
checkRecordedStops(stops, expected)
|
||||
checkRecordedStops(stops, expected),
|
||||
];
|
||||
|
||||
main(args) {
|
||||
runIsolateTestsSynchronous(
|
||||
args,
|
||||
tests,
|
||||
'breakpoints_with_mixin_test.dart',
|
||||
testeeConcurrent: code,
|
||||
pauseOnStart: true,
|
||||
pauseOnExit: true,
|
||||
);
|
||||
}
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'breakpoints_with_mixin_test.dart',
|
||||
testeeConcurrent: code,
|
||||
pauseOnStart: true,
|
||||
pauseOnExit: true,
|
||||
);
|
||||
|
||||
@@ -90,7 +90,7 @@ var tests = <IsolateTest>[
|
||||
},
|
||||
];
|
||||
|
||||
main(args) => runIsolateTests(
|
||||
Future<void> main(args) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'capture_stdio_test.dart',
|
||||
|
||||
@@ -50,7 +50,7 @@ final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_B),
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
Stack stack = await service.getStack(isolateRef.id!);
|
||||
final Stack stack = await service.getStack(isolateRef.id!);
|
||||
// No causal frames because we are in a completely synchronous stack.
|
||||
expect(stack.asyncCausalFrames, isNull);
|
||||
},
|
||||
@@ -61,7 +61,7 @@ final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_A),
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
Stack stack = await service.getStack(isolateRef.id!);
|
||||
final Stack stack = await service.getStack(isolateRef.id!);
|
||||
// Has causal frames (we are inside an async function)
|
||||
expect(stack.asyncCausalFrames, isNotNull);
|
||||
expect(
|
||||
@@ -77,7 +77,7 @@ final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_C),
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
Stack stack = await service.getStack(isolateRef.id!);
|
||||
final Stack stack = await service.getStack(isolateRef.id!);
|
||||
// Has causal frames (we are inside a function called by an async function)
|
||||
expect(stack.asyncCausalFrames, isNotNull);
|
||||
final asyncStack = stack.asyncCausalFrames!;
|
||||
|
||||
@@ -49,7 +49,7 @@ final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_B),
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
Stack stack = await service.getStack(isolateRef.id!);
|
||||
final Stack stack = await service.getStack(isolateRef.id!);
|
||||
// No causal frames because we are in a completely synchronous stack.
|
||||
// Async function hasn't yielded yet.
|
||||
expect(stack.asyncCausalFrames, isNull);
|
||||
@@ -61,7 +61,7 @@ final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_A),
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
Stack stack = await service.getStack(isolateRef.id!);
|
||||
final Stack stack = await service.getStack(isolateRef.id!);
|
||||
// Async function has yielded once, so it's now running async.
|
||||
expect(stack.asyncCausalFrames, isNotNull);
|
||||
},
|
||||
@@ -72,7 +72,7 @@ final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_C),
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
Stack stack = await service.getStack(isolateRef.id!);
|
||||
final Stack stack = await service.getStack(isolateRef.id!);
|
||||
// Has causal frames (we are inside a function called by an async function)
|
||||
expect(stack.asyncCausalFrames, isNotNull);
|
||||
},
|
||||
|
||||
@@ -56,7 +56,7 @@ final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_A),
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
Stack stack = await service.getStack(isolateRef.id!);
|
||||
final Stack stack = await service.getStack(isolateRef.id!);
|
||||
// No causal frames because we are in a completely synchronous stack.
|
||||
expect(stack.asyncCausalFrames, isNotNull);
|
||||
final asyncStack = stack.asyncCausalFrames!;
|
||||
@@ -71,7 +71,7 @@ final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_B),
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
Stack stack = await service.getStack(isolateRef.id!);
|
||||
final Stack stack = await service.getStack(isolateRef.id!);
|
||||
// Has causal frames (we are inside an async function)
|
||||
expect(stack.asyncCausalFrames, isNotNull);
|
||||
final asyncStack = stack.asyncCausalFrames!;
|
||||
@@ -88,13 +88,15 @@ final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_C),
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
Stack stack = await service.getStack(isolateRef.id!);
|
||||
final Stack stack = await service.getStack(isolateRef.id!);
|
||||
// Has causal frames (we are inside a function called by an async function)
|
||||
expect(stack.asyncCausalFrames, isNotNull);
|
||||
final asyncStack = stack.asyncCausalFrames!;
|
||||
expect(asyncStack.length, greaterThanOrEqualTo(4));
|
||||
final script = await service.getObject(
|
||||
isolateRef.id!, asyncStack[0].location!.script!.id!) as Script;
|
||||
isolateRef.id!,
|
||||
asyncStack[0].location!.script!.id!,
|
||||
) as Script;
|
||||
expect(asyncStack[0].function!.name, contains('foobar'));
|
||||
expect(
|
||||
script.getLineNumberFromTokenPos(asyncStack[0].location!.tokenPos!),
|
||||
|
||||
@@ -10,22 +10,28 @@ import 'package:vm_service/vm_service.dart';
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const LINE_A = 30;
|
||||
const LINE_B = 23;
|
||||
const LINE_C = 25;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_0 = 28;
|
||||
const LINE_B = 29;
|
||||
const LINE_1 = 30;
|
||||
const LINE_C = 31;
|
||||
const LINE_2 = 35;
|
||||
const LINE_A = 36;
|
||||
// AUTOGENERATED END
|
||||
|
||||
const LINE_0 = 22;
|
||||
const LINE_1 = 24;
|
||||
const LINE_2 = 29;
|
||||
|
||||
foobar() async* {
|
||||
Stream<int> foobar() async* {
|
||||
debugger(); // LINE_0.
|
||||
yield 1; // LINE_B.
|
||||
debugger(); // LINE_1.
|
||||
yield 2; // LINE_C.
|
||||
}
|
||||
|
||||
helper() async {
|
||||
Future<void> helper() async {
|
||||
debugger(); // LINE_2.
|
||||
print('helper'); // LINE_A.
|
||||
await for (var i in foobar()) {
|
||||
@@ -33,18 +39,18 @@ helper() async {
|
||||
}
|
||||
}
|
||||
|
||||
testMain() {
|
||||
void testMain() {
|
||||
helper();
|
||||
}
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_2),
|
||||
stepOver,
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_A),
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
Stack stack = await service.getStack(isolateRef.id!);
|
||||
final Stack stack = await service.getStack(isolateRef.id!);
|
||||
// No causal frames because we are in a completely synchronous stack.
|
||||
expect(stack.asyncCausalFrames, isNull);
|
||||
},
|
||||
@@ -55,7 +61,7 @@ var tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_B),
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
Stack stack = await service.getStack(isolateRef.id!);
|
||||
final Stack stack = await service.getStack(isolateRef.id!);
|
||||
// Has causal frames (we are inside an async function)
|
||||
expect(stack.asyncCausalFrames, isNotNull);
|
||||
},
|
||||
@@ -66,13 +72,13 @@ var tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_C),
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
Stack stack = await service.getStack(isolateRef.id!);
|
||||
final Stack stack = await service.getStack(isolateRef.id!);
|
||||
// Has causal frames (we are inside a function called by an async function)
|
||||
expect(stack.asyncCausalFrames, isNotNull);
|
||||
},
|
||||
];
|
||||
|
||||
main(args) => runIsolateTestsSynchronous(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'causal_async_star_stack_presence_test.dart',
|
||||
|
||||
@@ -57,7 +57,7 @@ var tests = <IsolateTest>[
|
||||
// Inspect code objects for top two frames.
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
final isolateId = isolateRef.id!;
|
||||
Stack stack = await service.getStack(isolateId);
|
||||
final Stack stack = await service.getStack(isolateId);
|
||||
// Make sure we are in the right place.
|
||||
expect(stack.frames!.length, greaterThanOrEqualTo(3));
|
||||
final frame0 = stack.frames![0];
|
||||
@@ -82,7 +82,7 @@ var tests = <IsolateTest>[
|
||||
},
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
Future<void> main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'code_test.dart',
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
void testMain() {
|
||||
var b = [1, 2].map((i) => i == 0).toList();
|
||||
final b = [1, 2].map((i) => i == 0).toList();
|
||||
print(b.length);
|
||||
}
|
||||
|
||||
@@ -14,12 +14,12 @@ const int LINE = 9;
|
||||
const int COLUMN = 29;
|
||||
const String shortFile = 'column_breakpoint_test.dart';
|
||||
|
||||
List<String> stops = [];
|
||||
final stops = <String>[];
|
||||
|
||||
const List<String> expected = [
|
||||
'$shortFile:${LINE + 0}:29', // on 'i == 0'
|
||||
'$shortFile:${LINE + 0}:29', // iterate twice
|
||||
'$shortFile:${LINE + 1}:11' //on 'b.length'
|
||||
const expected = <String>[
|
||||
'$shortFile:${LINE + 0}:33', // on 'i == 0'
|
||||
'$shortFile:${LINE + 0}:33', // iterate twice
|
||||
'$shortFile:${LINE + 1}:11', //on 'b.length'
|
||||
];
|
||||
|
||||
final tests = <IsolateTest>[
|
||||
@@ -30,13 +30,11 @@ final tests = <IsolateTest>[
|
||||
checkRecordedStops(stops, expected),
|
||||
];
|
||||
|
||||
main(args) {
|
||||
runIsolateTestsSynchronous(
|
||||
args,
|
||||
tests,
|
||||
'column_breakpoint_test.dart',
|
||||
testeeConcurrent: testMain,
|
||||
pauseOnStart: true,
|
||||
pauseOnExit: true,
|
||||
);
|
||||
}
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'column_breakpoint_test.dart',
|
||||
testeeConcurrent: testMain,
|
||||
pauseOnStart: true,
|
||||
pauseOnExit: true,
|
||||
);
|
||||
|
||||
@@ -36,7 +36,7 @@ class Expect {
|
||||
if (start < 0) start = 0;
|
||||
if (end > string.length) end = string.length;
|
||||
}
|
||||
StringBuffer buf = StringBuffer();
|
||||
final StringBuffer buf = StringBuffer();
|
||||
if (start > 0) buf.write('...');
|
||||
_escapeSubstring(buf, string, 0, string.length);
|
||||
if (end < string.length) buf.write('...');
|
||||
@@ -46,15 +46,20 @@ class Expect {
|
||||
/// Return the string with characters that are not printable ASCII characters
|
||||
/// escaped as either "\xXX" codes or "\uXXXX" codes.
|
||||
static String _escapeString(String string) {
|
||||
StringBuffer buf = StringBuffer();
|
||||
final StringBuffer buf = StringBuffer();
|
||||
_escapeSubstring(buf, string, 0, string.length);
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
static _escapeSubstring(StringBuffer buf, String string, int start, int end) {
|
||||
static void _escapeSubstring(
|
||||
StringBuffer buf,
|
||||
String string,
|
||||
int start,
|
||||
int end,
|
||||
) {
|
||||
const hexDigits = '0123456789ABCDEF';
|
||||
for (int i = start; i < end; i++) {
|
||||
int code = string.codeUnitAt(i);
|
||||
final int code = string.codeUnitAt(i);
|
||||
if (0x20 <= code && code < 0x7F) {
|
||||
if (code == 0x5C) {
|
||||
buf.write(r'\\');
|
||||
@@ -68,7 +73,7 @@ class Expect {
|
||||
} else {
|
||||
buf.write(r'\u{');
|
||||
buf.write(code.toRadixString(16).toUpperCase());
|
||||
buf.write(r'}');
|
||||
buf.write('}');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,15 +90,15 @@ class Expect {
|
||||
if (expected.length < 20 && actual.length < 20) return '';
|
||||
for (int i = 0; i < expected.length && i < actual.length; i++) {
|
||||
if (expected.codeUnitAt(i) != actual.codeUnitAt(i)) {
|
||||
int start = i;
|
||||
final int start = i;
|
||||
i++;
|
||||
while (i < expected.length && i < actual.length) {
|
||||
if (expected.codeUnitAt(i) == actual.codeUnitAt(i)) break;
|
||||
i++;
|
||||
}
|
||||
int end = i;
|
||||
var truncExpected = _truncateString(expected, start, end, 20);
|
||||
var truncActual = _truncateString(actual, start, end, 20);
|
||||
final int end = i;
|
||||
final truncExpected = _truncateString(expected, start, end, 20);
|
||||
final truncActual = _truncateString(actual, start, end, 20);
|
||||
return 'at index $start: Expected <$truncExpected>, '
|
||||
'Found: <$truncActual>';
|
||||
}
|
||||
@@ -104,9 +109,9 @@ class Expect {
|
||||
/// Checks whether the expected and actual values are equal (using `==`).
|
||||
static void equals(dynamic expected, dynamic actual, [String reason = '']) {
|
||||
if (expected == actual) return;
|
||||
String msg = _getMessage(reason);
|
||||
final String msg = _getMessage(reason);
|
||||
if (expected is String && actual is String) {
|
||||
String stringDifference = _stringDifference(expected, actual);
|
||||
final String stringDifference = _stringDifference(expected, actual);
|
||||
if (stringDifference.isNotEmpty) {
|
||||
fail('Expect.equals($stringDifference$msg) fails.');
|
||||
}
|
||||
@@ -119,28 +124,28 @@ class Expect {
|
||||
/// Checks whether the actual value is a bool and its value is true.
|
||||
static void isTrue(dynamic actual, [String reason = '']) {
|
||||
if (_identical(actual, true)) return;
|
||||
String msg = _getMessage(reason);
|
||||
final String msg = _getMessage(reason);
|
||||
fail('Expect.isTrue($actual$msg) fails.');
|
||||
}
|
||||
|
||||
/// Checks whether the actual value is a bool and its value is false.
|
||||
static void isFalse(dynamic actual, [String reason = '']) {
|
||||
if (_identical(actual, false)) return;
|
||||
String msg = _getMessage(reason);
|
||||
final String msg = _getMessage(reason);
|
||||
fail('Expect.isFalse($actual$msg) fails.');
|
||||
}
|
||||
|
||||
/// Checks whether [actual] is null.
|
||||
static void isNull(dynamic actual, [String reason = '']) {
|
||||
if (null == actual) return;
|
||||
String msg = _getMessage(reason);
|
||||
final String msg = _getMessage(reason);
|
||||
fail('Expect.isNull(actual: <$actual>$msg) fails.');
|
||||
}
|
||||
|
||||
/// Checks whether [actual] is not null.
|
||||
static void isNotNull(dynamic actual, [String reason = '']) {
|
||||
if (null != actual) return;
|
||||
String msg = _getMessage(reason);
|
||||
final String msg = _getMessage(reason);
|
||||
fail('Expect.isNotNull(actual: <$actual>$msg) fails.');
|
||||
}
|
||||
|
||||
|
||||
@@ -12,14 +12,16 @@ import 'package:test/test.dart';
|
||||
import 'package:vm_service/vm_service.dart';
|
||||
|
||||
typedef IsolateTest = Future<void> Function(
|
||||
VmService service, IsolateRef isolate);
|
||||
VmService service,
|
||||
IsolateRef isolate,
|
||||
);
|
||||
typedef VMTest = Future<void> Function(VmService service);
|
||||
|
||||
Future<void> smartNext(VmService service, IsolateRef isolateRef) async {
|
||||
print('smartNext');
|
||||
final isolate = await service.getIsolate(isolateRef.id!);
|
||||
Event event = isolate.pauseEvent!;
|
||||
if ((event.kind == EventKind.kPauseBreakpoint)) {
|
||||
final Event event = isolate.pauseEvent!;
|
||||
if (event.kind == EventKind.kPauseBreakpoint) {
|
||||
// TODO(bkonyi): remove needless refetching of isolate object.
|
||||
if (event.atAsyncSuspension ?? false) {
|
||||
return asyncNext(service, isolateRef);
|
||||
@@ -36,8 +38,8 @@ Future<void> asyncNext(VmService service, IsolateRef isolateRef) async {
|
||||
final id = isolateRef.id!;
|
||||
final isolate = await service.getIsolate(id);
|
||||
final event = isolate.pauseEvent!;
|
||||
if ((event.kind == EventKind.kPauseBreakpoint)) {
|
||||
dynamic event = isolate.pauseEvent;
|
||||
if (event.kind == EventKind.kPauseBreakpoint) {
|
||||
final dynamic event = isolate.pauseEvent;
|
||||
if (!event.atAsyncSuspension) {
|
||||
throw 'No async continuation at this location';
|
||||
} else {
|
||||
@@ -53,7 +55,7 @@ Future<void> syncNext(VmService service, IsolateRef isolateRef) async {
|
||||
final id = isolateRef.id!;
|
||||
final isolate = await service.getIsolate(id);
|
||||
final event = isolate.pauseEvent!;
|
||||
if ((event.kind == EventKind.kPauseBreakpoint)) {
|
||||
if (event.kind == EventKind.kPauseBreakpoint) {
|
||||
await service.resume(id, step: 'Over');
|
||||
} else {
|
||||
throw 'The program is already running';
|
||||
@@ -65,7 +67,10 @@ Future<void> syncNext(VmService service, IsolateRef isolateRef) async {
|
||||
// If another check is waiting on an event, it will no longer be notified of
|
||||
// the event, causing the test to hang.
|
||||
Future<void> hasPausedFor(
|
||||
VmService service, IsolateRef isolateRef, String kind) async {
|
||||
VmService service,
|
||||
IsolateRef isolateRef,
|
||||
String kind,
|
||||
) async {
|
||||
Completer<dynamic>? completer = Completer();
|
||||
late StreamSubscription<Event> subscription;
|
||||
subscription = service.onDebugEvent.listen((event) async {
|
||||
@@ -88,7 +93,7 @@ Future<void> hasPausedFor(
|
||||
final id = isolateRef.id!;
|
||||
final isolate = await service.getIsolate(id);
|
||||
final event = isolate.pauseEvent!;
|
||||
if ((event.kind == kind)) {
|
||||
if (event.kind == kind) {
|
||||
if (completer != null) {
|
||||
try {
|
||||
await service.streamCancel(EventStreams.kDebug);
|
||||
@@ -122,7 +127,9 @@ Future<void> hasStoppedPostRequest(VmService service, IsolateRef isolate) {
|
||||
// If another check is waiting on an event, it will no longer be notified of
|
||||
// the event, causing the test to hang.
|
||||
Future<void> hasStoppedWithUnhandledException(
|
||||
VmService service, IsolateRef isolate) {
|
||||
VmService service,
|
||||
IsolateRef isolate,
|
||||
) {
|
||||
return hasPausedFor(service, isolate, EventKind.kPauseException);
|
||||
}
|
||||
|
||||
@@ -143,7 +150,9 @@ Future<void> hasPausedAtStart(VmService service, IsolateRef isolate) {
|
||||
}
|
||||
|
||||
Future<void> markDartColonLibrariesDebuggable(
|
||||
VmService service, IsolateRef isolateRef) async {
|
||||
VmService service,
|
||||
IsolateRef isolateRef,
|
||||
) async {
|
||||
final isolateId = isolateRef.id!;
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
final requests = <Future>[];
|
||||
@@ -166,7 +175,8 @@ IsolateTest setBreakpointAtLine(int line) {
|
||||
(await service.getObject(isolateId, isolate.rootLib!.id!)) as Library;
|
||||
final script = lib.scripts!.first;
|
||||
|
||||
Breakpoint bpt = await service.addBreakpoint(isolateId, script.id!, line);
|
||||
final Breakpoint bpt =
|
||||
await service.addBreakpoint(isolateId, script.id!, line);
|
||||
print('Breakpoint is $bpt');
|
||||
};
|
||||
}
|
||||
@@ -174,7 +184,7 @@ IsolateTest setBreakpointAtLine(int line) {
|
||||
IsolateTest setBreakpointAtUriAndLine(String uri, int line) {
|
||||
return (VmService service, IsolateRef isolateRef) async {
|
||||
print('Setting breakpoint for line $line in $uri');
|
||||
Breakpoint bpt =
|
||||
final Breakpoint bpt =
|
||||
await service.addBreakpointWithScriptUri(isolateRef.id!, uri, line);
|
||||
print('Breakpoint is $bpt');
|
||||
expect(bpt, isNotNull);
|
||||
@@ -188,8 +198,8 @@ IsolateTest setBreakpointAtLineColumn(int line, int column) {
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
final lib =
|
||||
await service.getObject(isolateId, isolate.rootLib!.id!) as Library;
|
||||
ScriptRef script = lib.scripts!.firstWhere((s) => s.uri == lib.uri);
|
||||
Breakpoint bpt = await service.addBreakpoint(
|
||||
final ScriptRef script = lib.scripts!.firstWhere((s) => s.uri == lib.uri);
|
||||
final Breakpoint bpt = await service.addBreakpoint(
|
||||
isolateId,
|
||||
script.id!,
|
||||
line,
|
||||
@@ -218,7 +228,8 @@ IsolateTest stoppedAtLine(int line) {
|
||||
final top = frames[0];
|
||||
final Script script =
|
||||
(await service.getObject(id, top.location!.script!.id!)) as Script;
|
||||
int actualLine = script.getLineNumberFromTokenPos(top.location!.tokenPos!)!;
|
||||
final int actualLine =
|
||||
script.getLineNumberFromTokenPos(top.location!.tokenPos!)!;
|
||||
if (actualLine != line) {
|
||||
print('Actual: $actualLine Line: $line');
|
||||
final sb = StringBuffer();
|
||||
@@ -226,7 +237,8 @@ IsolateTest stoppedAtLine(int line) {
|
||||
sb.write('\nFull stack trace:\n');
|
||||
for (Frame f in frames) {
|
||||
sb.write(
|
||||
' $f [${script.getLineNumberFromTokenPos(f.location!.tokenPos!)}]\n');
|
||||
' $f [${script.getLineNumberFromTokenPos(f.location!.tokenPos!)}]\n',
|
||||
);
|
||||
}
|
||||
throw sb.toString();
|
||||
} else {
|
||||
@@ -236,7 +248,7 @@ IsolateTest stoppedAtLine(int line) {
|
||||
}
|
||||
|
||||
Future<void> resumeIsolate(VmService service, IsolateRef isolate) async {
|
||||
Completer completer = Completer();
|
||||
final Completer completer = Completer();
|
||||
late StreamSubscription<Event> subscription;
|
||||
bool cancelStreamAfterResume = false;
|
||||
subscription = service.onDebugEvent.listen((event) async {
|
||||
@@ -324,7 +336,9 @@ Future<void> stepOut(VmService service, IsolateRef isolateRef) async {
|
||||
}
|
||||
|
||||
IsolateTest resumeProgramRecordingStops(
|
||||
List<String> recordStops, bool includeCaller) {
|
||||
List<String> recordStops,
|
||||
bool includeCaller,
|
||||
) {
|
||||
return (VmService service, IsolateRef isolateRef) async {
|
||||
final completer = Completer<void>();
|
||||
|
||||
@@ -361,7 +375,7 @@ Future<String> _locationToString(
|
||||
Frame frame,
|
||||
) async {
|
||||
final location = frame.location!;
|
||||
Script script =
|
||||
final Script script =
|
||||
await service.getObject(isolateRef.id!, location.script!.id!) as Script;
|
||||
final scriptName = basename(script.uri!);
|
||||
final tokenPos = location.tokenPos!;
|
||||
@@ -381,8 +395,10 @@ IsolateTest runStepThroughProgramRecordingStops(List<String> recordStops) {
|
||||
final frame = isolate.pauseEvent!.topFrame!;
|
||||
recordStops.add(await _locationToString(service, isolateRef, frame));
|
||||
if (event.atAsyncSuspension ?? false) {
|
||||
await service.resume(isolateRef.id!,
|
||||
step: StepOption.kOverAsyncSuspension);
|
||||
await service.resume(
|
||||
isolateRef.id!,
|
||||
step: StepOption.kOverAsyncSuspension,
|
||||
);
|
||||
} else {
|
||||
await service.resume(isolateRef.id!, step: StepOption.kOver);
|
||||
}
|
||||
@@ -422,31 +438,34 @@ IsolateTest runStepIntoThroughProgramRecordingStops(List<String> recordStops) {
|
||||
}
|
||||
|
||||
IsolateTest checkRecordedStops(
|
||||
List<String> recordStops, List<String> expectedStops,
|
||||
{bool removeDuplicates = false,
|
||||
bool debugPrint = false,
|
||||
String? debugPrintFile,
|
||||
int? debugPrintLine}) {
|
||||
List<String> recordStops,
|
||||
List<String> expectedStops, {
|
||||
bool removeDuplicates = false,
|
||||
bool debugPrint = false,
|
||||
String? debugPrintFile,
|
||||
int? debugPrintLine,
|
||||
}) {
|
||||
return (VmService service, IsolateRef isolate) async {
|
||||
if (debugPrint) {
|
||||
for (int i = 0; i < recordStops.length; i++) {
|
||||
String line = recordStops[i];
|
||||
final String line = recordStops[i];
|
||||
String output = line;
|
||||
int firstColon = line.indexOf(':');
|
||||
int lastColon = line.lastIndexOf(':');
|
||||
final int firstColon = line.indexOf(':');
|
||||
final int lastColon = line.lastIndexOf(':');
|
||||
if (debugPrintFile != null &&
|
||||
debugPrintLine != null &&
|
||||
firstColon > 0 &&
|
||||
lastColon > 0) {
|
||||
int lineNumber = int.parse(line.substring(firstColon + 1, lastColon));
|
||||
int relativeLineNumber = lineNumber - debugPrintLine;
|
||||
var columnNumber = line.substring(lastColon + 1);
|
||||
var file = line.substring(0, firstColon);
|
||||
final int lineNumber =
|
||||
int.parse(line.substring(firstColon + 1, lastColon));
|
||||
final int relativeLineNumber = lineNumber - debugPrintLine;
|
||||
final columnNumber = line.substring(lastColon + 1);
|
||||
final file = line.substring(0, firstColon);
|
||||
if (file == debugPrintFile) {
|
||||
output = '\$file:\${LINE+$relativeLineNumber}:$columnNumber';
|
||||
}
|
||||
}
|
||||
String comma = i == recordStops.length - 1 ? '' : ',';
|
||||
final String comma = i == recordStops.length - 1 ? '' : ',';
|
||||
print("'$output'$comma");
|
||||
}
|
||||
}
|
||||
@@ -478,14 +497,17 @@ IsolateTest checkRecordedStops(
|
||||
j++;
|
||||
}
|
||||
|
||||
expect(recordStops.length >= expectedStops.length, true,
|
||||
reason: 'Expects at least ${expectedStops.length} breaks, '
|
||||
'got ${recordStops.length}.');
|
||||
expect(
|
||||
recordStops.length >= expectedStops.length,
|
||||
true,
|
||||
reason: 'Expects at least ${expectedStops.length} breaks, '
|
||||
'got ${recordStops.length}.',
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
List<String> removeAdjacentDuplicates(List<String> fromList) {
|
||||
List<String> result = <String>[];
|
||||
final List<String> result = <String>[];
|
||||
String? latestLine;
|
||||
for (String s in fromList) {
|
||||
if (s == latestLine) continue;
|
||||
|
||||
@@ -43,14 +43,15 @@ Uri _getTestUri(String script) {
|
||||
}
|
||||
|
||||
class _ServiceTesteeRunner {
|
||||
Future run(
|
||||
{Function()? testeeBefore,
|
||||
Function()? testeeConcurrent,
|
||||
bool pauseOnStart = false,
|
||||
bool pauseOnExit = false}) async {
|
||||
Future<void> run({
|
||||
Function()? testeeBefore,
|
||||
Function()? testeeConcurrent,
|
||||
bool pauseOnStart = false,
|
||||
bool pauseOnExit = false,
|
||||
}) async {
|
||||
if (!pauseOnStart) {
|
||||
if (testeeBefore != null) {
|
||||
var result = testeeBefore();
|
||||
final result = testeeBefore();
|
||||
if (result is Future) {
|
||||
await result;
|
||||
}
|
||||
@@ -58,7 +59,7 @@ class _ServiceTesteeRunner {
|
||||
print(''); // Print blank line to signal that testeeBefore has run.
|
||||
}
|
||||
if (testeeConcurrent != null) {
|
||||
var result = testeeConcurrent();
|
||||
final result = testeeConcurrent();
|
||||
if (result is Future) {
|
||||
await result;
|
||||
}
|
||||
@@ -69,11 +70,12 @@ class _ServiceTesteeRunner {
|
||||
}
|
||||
}
|
||||
|
||||
void runSync(
|
||||
{void Function()? testeeBeforeSync,
|
||||
void Function()? testeeConcurrentSync,
|
||||
bool pauseOnStart = false,
|
||||
bool pauseOnExit = false}) {
|
||||
void runSync({
|
||||
void Function()? testeeBeforeSync,
|
||||
void Function()? testeeConcurrentSync,
|
||||
bool pauseOnStart = false,
|
||||
bool pauseOnExit = false,
|
||||
}) {
|
||||
if (!pauseOnStart) {
|
||||
if (testeeBeforeSync != null) {
|
||||
testeeBeforeSync();
|
||||
@@ -113,24 +115,26 @@ class _ServiceTesteeLauncher {
|
||||
List<String>? extraArgs,
|
||||
) {
|
||||
return _spawnDartProcess(
|
||||
pauseOnStart,
|
||||
pauseOnExit,
|
||||
pauseOnUnhandledExceptions,
|
||||
testeeControlsServer,
|
||||
useAuthToken,
|
||||
experiments,
|
||||
extraArgs);
|
||||
pauseOnStart,
|
||||
pauseOnExit,
|
||||
pauseOnUnhandledExceptions,
|
||||
testeeControlsServer,
|
||||
useAuthToken,
|
||||
experiments,
|
||||
extraArgs,
|
||||
);
|
||||
}
|
||||
|
||||
Future<io.Process> _spawnDartProcess(
|
||||
bool pauseOnStart,
|
||||
bool pauseOnExit,
|
||||
bool pauseOnUnhandledExceptions,
|
||||
bool testeeControlsServer,
|
||||
bool useAuthToken,
|
||||
List<String>? experiments,
|
||||
List<String>? extraArgs) {
|
||||
String dartExecutable = io.Platform.executable;
|
||||
bool pauseOnStart,
|
||||
bool pauseOnExit,
|
||||
bool pauseOnUnhandledExceptions,
|
||||
bool testeeControlsServer,
|
||||
bool useAuthToken,
|
||||
List<String>? experiments,
|
||||
List<String>? extraArgs,
|
||||
) {
|
||||
final String dartExecutable = io.Platform.executable;
|
||||
|
||||
final fullArgs = <String>[];
|
||||
if (pauseOnStart) {
|
||||
@@ -161,10 +165,13 @@ class _ServiceTesteeLauncher {
|
||||
return _spawnCommon(dartExecutable, fullArgs, <String, String>{});
|
||||
}
|
||||
|
||||
Future<io.Process> _spawnCommon(String executable,
|
||||
List<String> /*!*/ arguments, Map<String, String> dartEnvironment) {
|
||||
var environment = _TESTEE_SPAWN_ENV;
|
||||
var bashEnvironment = StringBuffer();
|
||||
Future<io.Process> _spawnCommon(
|
||||
String executable,
|
||||
List<String> /*!*/ arguments,
|
||||
Map<String, String> dartEnvironment,
|
||||
) {
|
||||
final environment = _TESTEE_SPAWN_ENV;
|
||||
final bashEnvironment = StringBuffer();
|
||||
environment.forEach((k, v) => bashEnvironment.write('$k=$v '));
|
||||
dartEnvironment.forEach((k, v) {
|
||||
arguments.insert(0, '-D$k=$v');
|
||||
@@ -178,17 +185,24 @@ class _ServiceTesteeLauncher {
|
||||
}
|
||||
|
||||
Future<Uri> launch(
|
||||
bool pauseOnStart,
|
||||
bool pauseOnExit,
|
||||
bool pauseOnUnhandledExceptions,
|
||||
bool testeeControlsServer,
|
||||
bool useAuthToken,
|
||||
List<String>? experiments,
|
||||
List<String>? extraArgs) {
|
||||
return _spawnProcess(pauseOnStart, pauseOnExit, pauseOnUnhandledExceptions,
|
||||
testeeControlsServer, useAuthToken, experiments, extraArgs)
|
||||
.then((p) {
|
||||
Completer<Uri> completer = Completer<Uri>();
|
||||
bool pauseOnStart,
|
||||
bool pauseOnExit,
|
||||
bool pauseOnUnhandledExceptions,
|
||||
bool testeeControlsServer,
|
||||
bool useAuthToken,
|
||||
List<String>? experiments,
|
||||
List<String>? extraArgs,
|
||||
) {
|
||||
return _spawnProcess(
|
||||
pauseOnStart,
|
||||
pauseOnExit,
|
||||
pauseOnUnhandledExceptions,
|
||||
testeeControlsServer,
|
||||
useAuthToken,
|
||||
experiments,
|
||||
extraArgs,
|
||||
).then((p) {
|
||||
final Completer<Uri> completer = Completer<Uri>();
|
||||
process = p;
|
||||
Uri? uri;
|
||||
bool blank = false;
|
||||
@@ -241,7 +255,7 @@ void setupAddresses(Uri /*!*/ serverAddress) {
|
||||
}
|
||||
|
||||
class _ServiceTesterRunner {
|
||||
Future run({
|
||||
Future<void> run({
|
||||
List<String>? mainArgs,
|
||||
List<String>? extraArgs,
|
||||
List<String>? experiments,
|
||||
@@ -257,17 +271,24 @@ class _ServiceTesterRunner {
|
||||
bool allowForNonZeroExitCode = false,
|
||||
VmServiceFactory serviceFactory = VmService.defaultFactory,
|
||||
}) async {
|
||||
var process = _ServiceTesteeLauncher(scriptName);
|
||||
final process = _ServiceTesteeLauncher(scriptName);
|
||||
late VmService vm;
|
||||
late IsolateRef isolate;
|
||||
setUp(() async {
|
||||
await process
|
||||
.launch(pauseOnStart, pauseOnExit, pauseOnUnhandledExceptions,
|
||||
testeeControlsServer, useAuthToken, experiments, extraArgs)
|
||||
.launch(
|
||||
pauseOnStart,
|
||||
pauseOnExit,
|
||||
pauseOnUnhandledExceptions,
|
||||
testeeControlsServer,
|
||||
useAuthToken,
|
||||
experiments,
|
||||
extraArgs,
|
||||
)
|
||||
.then((Uri serverAddress) async {
|
||||
if (mainArgs!.contains('--gdb')) {
|
||||
var pid = process.process!.pid;
|
||||
var wait = Duration(seconds: 10);
|
||||
final pid = process.process!.pid;
|
||||
final wait = Duration(seconds: 10);
|
||||
print('Testee has pid $pid, waiting $wait before continuing');
|
||||
io.sleep(wait);
|
||||
}
|
||||
@@ -289,7 +310,7 @@ class _ServiceTesterRunner {
|
||||
// Run vm tests.
|
||||
if (vmTests != null) {
|
||||
var testIndex = 1;
|
||||
var totalTests = vmTests.length;
|
||||
final totalTests = vmTests.length;
|
||||
for (var t in vmTests) {
|
||||
print('$name [$testIndex/$totalTests]');
|
||||
await t(vm);
|
||||
@@ -300,7 +321,7 @@ class _ServiceTesterRunner {
|
||||
// Run isolate tests.
|
||||
if (isolateTests != null) {
|
||||
var testIndex = 1;
|
||||
var totalTests = isolateTests.length;
|
||||
final totalTests = isolateTests.length;
|
||||
for (var t in isolateTests) {
|
||||
print('$name [$testIndex/$totalTests]');
|
||||
await t(vm, isolate);
|
||||
@@ -430,20 +451,22 @@ void runIsolateTestsSynchronous(
|
||||
assert(!pauseOnStart || testeeBefore == null);
|
||||
if (_isTestee()) {
|
||||
_ServiceTesteeRunner().runSync(
|
||||
testeeBeforeSync: testeeBefore,
|
||||
testeeConcurrentSync: testeeConcurrent,
|
||||
pauseOnStart: pauseOnStart,
|
||||
pauseOnExit: pauseOnExit);
|
||||
testeeBeforeSync: testeeBefore,
|
||||
testeeConcurrentSync: testeeConcurrent,
|
||||
pauseOnStart: pauseOnStart,
|
||||
pauseOnExit: pauseOnExit,
|
||||
);
|
||||
} else {
|
||||
_ServiceTesterRunner().run(
|
||||
mainArgs: mainArgs,
|
||||
scriptName: scriptName,
|
||||
extraArgs: extraArgs,
|
||||
isolateTests: tests,
|
||||
pauseOnStart: pauseOnStart,
|
||||
pauseOnExit: pauseOnExit,
|
||||
verboseVm: verboseVm,
|
||||
pauseOnUnhandledExceptions: pauseOnUnhandledExceptions);
|
||||
mainArgs: mainArgs,
|
||||
scriptName: scriptName,
|
||||
extraArgs: extraArgs,
|
||||
isolateTests: tests,
|
||||
pauseOnStart: pauseOnStart,
|
||||
pauseOnExit: pauseOnExit,
|
||||
verboseVm: verboseVm,
|
||||
pauseOnUnhandledExceptions: pauseOnUnhandledExceptions,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -466,20 +489,22 @@ Future<void> runVMTests(
|
||||
}) async {
|
||||
if (_isTestee()) {
|
||||
await _ServiceTesteeRunner().run(
|
||||
testeeBefore: testeeBefore,
|
||||
testeeConcurrent: testeeConcurrent,
|
||||
pauseOnStart: pauseOnStart,
|
||||
pauseOnExit: pauseOnExit);
|
||||
testeeBefore: testeeBefore,
|
||||
testeeConcurrent: testeeConcurrent,
|
||||
pauseOnStart: pauseOnStart,
|
||||
pauseOnExit: pauseOnExit,
|
||||
);
|
||||
} else {
|
||||
await _ServiceTesterRunner().run(
|
||||
mainArgs: mainArgs,
|
||||
scriptName: scriptName,
|
||||
extraArgs: extraArgs,
|
||||
vmTests: tests,
|
||||
pauseOnStart: pauseOnStart,
|
||||
pauseOnExit: pauseOnExit,
|
||||
verboseVm: verboseVm,
|
||||
pauseOnUnhandledExceptions: pauseOnUnhandledExceptions,
|
||||
serviceFactory: serviceFactory);
|
||||
mainArgs: mainArgs,
|
||||
scriptName: scriptName,
|
||||
extraArgs: extraArgs,
|
||||
vmTests: tests,
|
||||
pauseOnStart: pauseOnStart,
|
||||
pauseOnExit: pauseOnExit,
|
||||
verboseVm: verboseVm,
|
||||
pauseOnUnhandledExceptions: pauseOnUnhandledExceptions,
|
||||
serviceFactory: serviceFactory,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,28 +18,28 @@ late final Function fullBlock;
|
||||
late final Function fullBlockWithChain;
|
||||
|
||||
Function genCleanBlock() {
|
||||
block(x) => x;
|
||||
dynamic block(x) => x;
|
||||
return block;
|
||||
}
|
||||
|
||||
Function genCopyingBlock() {
|
||||
final x = 'I could be copied into the block';
|
||||
block() => x;
|
||||
String block() => x;
|
||||
return block;
|
||||
}
|
||||
|
||||
Function genFullBlock() {
|
||||
var x = 42; // I must captured in a context.
|
||||
block() => x;
|
||||
int block() => x;
|
||||
x++;
|
||||
return block;
|
||||
}
|
||||
|
||||
Function genFullBlockWithChain() {
|
||||
var x = 420; // I must captured in a context.
|
||||
outerBlock() {
|
||||
int Function() outerBlock() {
|
||||
var y = 4200;
|
||||
innerBlock() => x + y;
|
||||
int innerBlock() => x + y;
|
||||
y++;
|
||||
return innerBlock;
|
||||
}
|
||||
|
||||
@@ -61,9 +61,9 @@ IsolateTest coverageTest(Map<String, dynamic> expectedRange) {
|
||||
|
||||
final root =
|
||||
await service.getObject(isolateId, isolate.rootLib!.id!) as Library;
|
||||
FuncRef funcRef =
|
||||
final FuncRef funcRef =
|
||||
root.functions!.singleWhere((f) => f.name == 'wrapperFunction');
|
||||
Func func = await service.getObject(isolateId, funcRef.id!) as Func;
|
||||
final Func func = await service.getObject(isolateId, funcRef.id!) as Func;
|
||||
final location = func.location!;
|
||||
|
||||
final report = await service.getSourceReport(
|
||||
@@ -95,8 +95,8 @@ var tests = <IsolateTest>[
|
||||
'compiled': true,
|
||||
'coverage': {
|
||||
'hits': [],
|
||||
'misses': [27, 28, 28, 29, 29, 29, 30, 32, 32, 33]
|
||||
}
|
||||
'misses': [27, 28, 28, 29, 29, 29, 30, 32, 32, 33],
|
||||
},
|
||||
},
|
||||
),
|
||||
resumeIsolate,
|
||||
@@ -109,13 +109,13 @@ var tests = <IsolateTest>[
|
||||
'compiled': true,
|
||||
'coverage': {
|
||||
'hits': [27, 28, 28, 29, 29, 29, 30, 32, 32, 33],
|
||||
'misses': []
|
||||
}
|
||||
'misses': [],
|
||||
},
|
||||
},
|
||||
),
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
Future<void> main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'coverage_async_test.dart',
|
||||
|
||||
@@ -55,8 +55,8 @@ final tests = <IsolateTest>[
|
||||
'compiled': true,
|
||||
'coverage': {
|
||||
'hits': [],
|
||||
'misses': [399, 443]
|
||||
}
|
||||
'misses': [399, 443],
|
||||
},
|
||||
};
|
||||
|
||||
final location = func.location!;
|
||||
@@ -101,8 +101,8 @@ final tests = <IsolateTest>[
|
||||
'compiled': true,
|
||||
'coverage': {
|
||||
'hits': [399, 443],
|
||||
'misses': []
|
||||
}
|
||||
'misses': [],
|
||||
},
|
||||
};
|
||||
|
||||
final location = func.location!;
|
||||
|
||||
@@ -52,7 +52,9 @@ var tests = <IsolateTest>[
|
||||
final rootLib =
|
||||
await service.getObject(isolateId, isolate.rootLib!.id!) as Library;
|
||||
final script = await service.getObject(
|
||||
isolateId, rootLib.scripts!.first.id!) as Script;
|
||||
isolateId,
|
||||
rootLib.scripts!.first.id!,
|
||||
) as Script;
|
||||
|
||||
final report = await service.getSourceReport(
|
||||
isolateId,
|
||||
@@ -63,7 +65,7 @@ var tests = <IsolateTest>[
|
||||
int match = 0;
|
||||
for (var range in report.ranges!) {
|
||||
for (int i in range.coverage!.hits!) {
|
||||
int? line = script.getLineNumberFromTokenPos(i);
|
||||
final int? line = script.getLineNumberFromTokenPos(i);
|
||||
if (line == null) {
|
||||
throw FormatException('token $i was missing source location');
|
||||
}
|
||||
@@ -78,10 +80,10 @@ var tests = <IsolateTest>[
|
||||
// Neither LINE nor Bar.field should be added into coverage.
|
||||
expect(match, 0);
|
||||
},
|
||||
resumeIsolate
|
||||
resumeIsolate,
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
Future<void> main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'coverage_const_field_async_closure_test.dart',
|
||||
|
||||
@@ -29,8 +29,10 @@ bool allRangesCompiled(coverage) {
|
||||
return true;
|
||||
}
|
||||
|
||||
IsolateTest coverageTest(Map<String, dynamic> expectedRange,
|
||||
{required bool reportLines}) {
|
||||
IsolateTest coverageTest(
|
||||
Map<String, dynamic> expectedRange, {
|
||||
required bool reportLines,
|
||||
}) {
|
||||
return (VmService service, IsolateRef isolateRef) async {
|
||||
final isolateId = isolateRef.id!;
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
@@ -42,9 +44,9 @@ IsolateTest coverageTest(Map<String, dynamic> expectedRange,
|
||||
|
||||
final root =
|
||||
await service.getObject(isolateId, isolate.rootLib!.id!) as Library;
|
||||
FuncRef funcRef =
|
||||
final FuncRef funcRef =
|
||||
root.functions!.singleWhere((f) => f.name == 'leafFunction');
|
||||
Func func = await service.getObject(isolateId, funcRef.id!) as Func;
|
||||
final Func func = await service.getObject(isolateId, funcRef.id!) as Func;
|
||||
final location = func.location!;
|
||||
|
||||
final report = await service.getSourceReport(
|
||||
@@ -76,8 +78,8 @@ var tests = <IsolateTest>[
|
||||
'compiled': true,
|
||||
'coverage': {
|
||||
'hits': [],
|
||||
'misses': [399]
|
||||
}
|
||||
'misses': [399],
|
||||
},
|
||||
},
|
||||
reportLines: false,
|
||||
),
|
||||
@@ -89,8 +91,8 @@ var tests = <IsolateTest>[
|
||||
'compiled': true,
|
||||
'coverage': {
|
||||
'hits': [],
|
||||
'misses': [13]
|
||||
}
|
||||
'misses': [13],
|
||||
},
|
||||
},
|
||||
reportLines: true,
|
||||
),
|
||||
@@ -104,8 +106,8 @@ var tests = <IsolateTest>[
|
||||
'compiled': true,
|
||||
'coverage': {
|
||||
'hits': [399],
|
||||
'misses': []
|
||||
}
|
||||
'misses': [],
|
||||
},
|
||||
},
|
||||
reportLines: false,
|
||||
),
|
||||
@@ -117,14 +119,14 @@ var tests = <IsolateTest>[
|
||||
'compiled': true,
|
||||
'coverage': {
|
||||
'hits': [13],
|
||||
'misses': []
|
||||
}
|
||||
'misses': [],
|
||||
},
|
||||
},
|
||||
reportLines: true,
|
||||
),
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
Future<void> main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'coverage_leaf_function_test.dart',
|
||||
|
||||
@@ -65,7 +65,7 @@ var tests = <IsolateTest>[
|
||||
},
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
Future<void> main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'coverage_optimized_function_test.dart',
|
||||
|
||||
@@ -10,14 +10,14 @@ import 'package:vm_service/vm_service.dart';
|
||||
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
fib(int n) {
|
||||
int fib(int n) {
|
||||
if (n <= 1) {
|
||||
return n;
|
||||
}
|
||||
return fib(n - 1) + fib(n - 2);
|
||||
}
|
||||
|
||||
void testMain() async {
|
||||
Future<void> testMain() async {
|
||||
int i = 10;
|
||||
while (true) {
|
||||
++i;
|
||||
@@ -62,7 +62,7 @@ var tests = <IsolateTest>[
|
||||
},
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) async => await runIsolateTests(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'cpu_samples_stream_test.dart',
|
||||
|
||||
@@ -47,7 +47,7 @@ final tests = <IsolateTest>[
|
||||
},
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
Future<void> main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'debugger_inspect_test.dart',
|
||||
|
||||
@@ -29,9 +29,9 @@ num Function() testFunction() {
|
||||
try {
|
||||
late int b;
|
||||
try {
|
||||
for (int i = 0; i < 10;) {
|
||||
for (final int i = 0; i < 10;) {
|
||||
// ignore: prefer_function_declarations_over_variables
|
||||
x() => i + a + b;
|
||||
int x() => i + a + b;
|
||||
return x; // LINE_B
|
||||
}
|
||||
} finally {
|
||||
|
||||
@@ -11,7 +11,7 @@ Future<void> main(List<String> args, SendPort port) async {
|
||||
await prefix1.loadLibrary();
|
||||
// Notify the spawner that we've finished loading the library.
|
||||
port.send(null);
|
||||
RawReceivePort _ = RawReceivePort();
|
||||
final RawReceivePort _ = RawReceivePort();
|
||||
print('spawned isolate running');
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,10 @@ Future<String> invokeTest(VmService service, IsolateRef isolateRef) async {
|
||||
final isolateId = isolateRef.id!;
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
final result = await service.evaluate(
|
||||
isolateId, isolate.rootLib!.id!, 'test()') as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'test()',
|
||||
) as InstanceRef;
|
||||
expect(result.kind, InstanceKind.kString);
|
||||
return result.valueAsString!;
|
||||
}
|
||||
|
||||
@@ -16,28 +16,38 @@ Future<ServiceExtensionResponse> handler(String method, Map parameters) {
|
||||
print('Invoked extension: $method');
|
||||
switch (method) {
|
||||
case 'ext..delay':
|
||||
var c = Completer<ServiceExtensionResponse>();
|
||||
final c = Completer<ServiceExtensionResponse>();
|
||||
Timer(Duration(seconds: 1), () {
|
||||
c.complete(ServiceExtensionResponse.result(jsonEncode({
|
||||
'type': '_delayedType',
|
||||
'method': method,
|
||||
'parameters': parameters,
|
||||
})));
|
||||
c.complete(
|
||||
ServiceExtensionResponse.result(
|
||||
jsonEncode({
|
||||
'type': '_delayedType',
|
||||
'method': method,
|
||||
'parameters': parameters,
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
return c.future;
|
||||
case 'ext..error':
|
||||
return Future<ServiceExtensionResponse>.value(
|
||||
ServiceExtensionResponse.error(
|
||||
ServiceExtensionResponse.extensionErrorMin, 'My error detail.'));
|
||||
ServiceExtensionResponse.error(
|
||||
ServiceExtensionResponse.extensionErrorMin,
|
||||
'My error detail.',
|
||||
),
|
||||
);
|
||||
case 'ext..exception':
|
||||
throw 'I always throw!';
|
||||
case 'ext..success':
|
||||
return Future<ServiceExtensionResponse>.value(
|
||||
ServiceExtensionResponse.result(jsonEncode({
|
||||
'type': '_extensionType',
|
||||
'method': method,
|
||||
'parameters': parameters,
|
||||
})));
|
||||
ServiceExtensionResponse.result(
|
||||
jsonEncode({
|
||||
'type': '_extensionType',
|
||||
'method': method,
|
||||
'parameters': parameters,
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
throw 'Unknown extension: $method';
|
||||
}
|
||||
@@ -128,7 +138,7 @@ var tests = <IsolateTest>[
|
||||
},
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) async => runIsolateTests(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'developer_extension_test.dart',
|
||||
|
||||
@@ -34,10 +34,10 @@ Future testeeMain() async {
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
getSelfId() => selfId;
|
||||
String getSelfId() => selfId;
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
getChildId() => childId;
|
||||
String getChildId() => childId;
|
||||
|
||||
// tester state:
|
||||
late IsolateRef initialIsolate;
|
||||
@@ -69,7 +69,7 @@ var tests = <VMTest>[
|
||||
initialIsolate = await service.getIsolate(initialIsolate.id!);
|
||||
|
||||
// Grab the root library.
|
||||
Library rootLib = await service.getObject(
|
||||
final Library rootLib = await service.getObject(
|
||||
initialIsolate.id!,
|
||||
(initialIsolate as Isolate).rootLib!.id!,
|
||||
) as Library;
|
||||
@@ -99,7 +99,7 @@ var tests = <VMTest>[
|
||||
}
|
||||
];
|
||||
|
||||
main(args) async => runVMTests(
|
||||
void main([args = const <String>[]]) => runVMTests(
|
||||
args,
|
||||
tests,
|
||||
'developer_service_get_isolate_id_test.dart',
|
||||
|
||||
@@ -16,19 +16,24 @@ final tests = <IsolateTest>[
|
||||
final isolateId = isolateRef.id!;
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
final evalResult = await service.evaluate(
|
||||
isolateId, isolate.rootLib!.id!, 'abcString') as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'abcString',
|
||||
) as InstanceRef;
|
||||
final getObjectIdResult = Service.getObjectId(abcString)!;
|
||||
final objectFromEval =
|
||||
await service.getObject(isolateId, evalResult.id!) as Instance;
|
||||
final objectFromGetObjectId =
|
||||
await service.getObject(isolateId, getObjectIdResult) as Instance;
|
||||
expect(objectFromEval.identityHashCode,
|
||||
objectFromGetObjectId.identityHashCode);
|
||||
expect(
|
||||
objectFromEval.identityHashCode,
|
||||
objectFromGetObjectId.identityHashCode,
|
||||
);
|
||||
expect(objectFromEval.valueAsString, objectFromGetObjectId.valueAsString);
|
||||
},
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) async => runIsolateTests(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'developer_service_get_object_id_test.dart',
|
||||
|
||||
@@ -133,7 +133,7 @@ final tests = <IsolateTest>[
|
||||
'interfaceSetter2=',
|
||||
'staticMethod',
|
||||
'staticGetter',
|
||||
'staticSetter='
|
||||
'staticSetter=',
|
||||
]),
|
||||
);
|
||||
expect(
|
||||
@@ -196,7 +196,7 @@ final tests = <IsolateTest>[
|
||||
},
|
||||
(VmService service, _) async {
|
||||
// Ensure we can evaluate instance getters and methods.
|
||||
dynamic e1 = await service.evaluate(isolateId, enumEClsId, 'e1');
|
||||
final dynamic e1 = await service.evaluate(isolateId, enumEClsId, 'e1');
|
||||
expect(e1, isA<InstanceRef>());
|
||||
final e1Id = e1.id!;
|
||||
|
||||
@@ -238,7 +238,7 @@ final tests = <IsolateTest>[
|
||||
},
|
||||
(VmService service, _) async {
|
||||
// Ensure we can invoke instance methods.
|
||||
dynamic e1 = await service.evaluate(isolateId, enumEClsId, 'e1');
|
||||
final dynamic e1 = await service.evaluate(isolateId, enumEClsId, 'e1');
|
||||
expect(e1, isA<InstanceRef>());
|
||||
final e1Id = e1.id!;
|
||||
|
||||
@@ -261,7 +261,7 @@ final tests = <IsolateTest>[
|
||||
},
|
||||
(VmService service, _) async {
|
||||
// Ensure we can invoke static methods.
|
||||
dynamic result =
|
||||
final dynamic result =
|
||||
await service.evaluate(isolateId, enumEClsId, 'staticMethod()');
|
||||
expect(result, isA<InstanceRef>());
|
||||
expect(result.valueAsString, '42');
|
||||
@@ -298,7 +298,7 @@ final tests = <IsolateTest>[
|
||||
},
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
Future<void> main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'enhanced_enum_test.dart',
|
||||
|
||||
@@ -15,7 +15,7 @@ var tests = <IsolateTest>[
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
) as Library;
|
||||
Class classLibrary = await service.getObject(
|
||||
final Class classLibrary = await service.getObject(
|
||||
isolateId,
|
||||
rootLib.classRef!.id!,
|
||||
) as Class;
|
||||
@@ -23,7 +23,7 @@ var tests = <IsolateTest>[
|
||||
{
|
||||
bool caughtExceptions = false;
|
||||
try {
|
||||
dynamic result = await service.evaluate(
|
||||
final dynamic result = await service.evaluate(
|
||||
isolateId,
|
||||
classLibrary.id!,
|
||||
'3 + 4',
|
||||
@@ -43,7 +43,7 @@ var tests = <IsolateTest>[
|
||||
{
|
||||
bool caughtExceptions = false;
|
||||
try {
|
||||
dynamic result = await service.evaluate(
|
||||
final dynamic result = await service.evaluate(
|
||||
isolateId,
|
||||
classClass.id!,
|
||||
'3 + 4',
|
||||
@@ -65,7 +65,7 @@ var tests = <IsolateTest>[
|
||||
.classRef!
|
||||
.id!,
|
||||
) as Class;
|
||||
dynamic result = await service.evaluate(
|
||||
final dynamic result = await service.evaluate(
|
||||
isolateId,
|
||||
classArray.id!,
|
||||
'3 + 4',
|
||||
@@ -75,7 +75,7 @@ var tests = <IsolateTest>[
|
||||
},
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
Future<void> main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'eval_internal_class_test.dart',
|
||||
|
||||
@@ -33,15 +33,18 @@ var tests = <IsolateTest>[
|
||||
// Evaluate against top frame.
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
final isolateId = isolateRef.id!;
|
||||
var topFrame = 0;
|
||||
final topFrame = 0;
|
||||
final dynamic result = await service.evaluateInFrame(
|
||||
isolateId, topFrame, 'a.runtimeType.toString()');
|
||||
isolateId,
|
||||
topFrame,
|
||||
'a.runtimeType.toString()',
|
||||
);
|
||||
print(result);
|
||||
expect(result.valueAsString, equals('A<C>'));
|
||||
},
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
Future<void> main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'eval_issue_49209_test.dart',
|
||||
|
||||
@@ -63,7 +63,7 @@ final tests = <IsolateTest>[
|
||||
},
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
Future<void> main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'eval_named_args_anywhere_test.dart',
|
||||
|
||||
@@ -72,7 +72,7 @@ void testFunction() {
|
||||
}
|
||||
|
||||
Future triggerEvaluation(VmService service, IsolateRef isolateRef) async {
|
||||
Stack stack = await service.getStack(isolateRef.id!);
|
||||
final Stack stack = await service.getStack(isolateRef.id!);
|
||||
|
||||
// Make sure we are in the right place.
|
||||
expect(stack.frames!.length, greaterThanOrEqualTo(2));
|
||||
@@ -105,7 +105,7 @@ final testSteps = <IsolateTest>[
|
||||
resumeIsolate,
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
Future<void> main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
testSteps,
|
||||
'eval_regression_flutter20255_test.dart',
|
||||
|
||||
@@ -10,20 +10,27 @@ import 'package:vm_service/vm_service.dart';
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const int LINE_A = 22;
|
||||
const int LINE_B = 17;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_B = 24;
|
||||
const LINE_A = 28;
|
||||
// AUTOGENERATED END
|
||||
|
||||
bar() {
|
||||
print('bar');
|
||||
void bar() {
|
||||
print('bar'); // LINE_B
|
||||
}
|
||||
|
||||
testMain() {
|
||||
debugger();
|
||||
void testMain() {
|
||||
debugger(); // LINE_A
|
||||
bar();
|
||||
print('Done');
|
||||
}
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
stoppedAtLine(LINE_A),
|
||||
// Add breakpoint
|
||||
@@ -47,7 +54,7 @@ var tests = <IsolateTest>[
|
||||
resumeIsolate,
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'eval_skip_breakpoint.dart',
|
||||
|
||||
@@ -29,12 +29,12 @@ void testFunction() {
|
||||
while (true) {
|
||||
if (++i % 100000000 == 0) {
|
||||
MyClass.method(10000);
|
||||
(_MyClass()).foo();
|
||||
_MyClass().foo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
final tests = <IsolateTest>[
|
||||
hasStoppedAtBreakpoint,
|
||||
|
||||
// Evaluate against library, class, and instance.
|
||||
@@ -57,8 +57,9 @@ var tests = <IsolateTest>[
|
||||
print(result);
|
||||
expect(result.valueAsString, '105');
|
||||
|
||||
await expectError(() =>
|
||||
service.evaluate(isolateId, lib.id!, 'globalVar + staticVar + 5'));
|
||||
await expectError(
|
||||
() => service.evaluate(isolateId, lib.id!, 'globalVar + staticVar + 5'),
|
||||
);
|
||||
|
||||
result =
|
||||
await service.evaluate(isolateId, cls.id!, 'globalVar + staticVar + 5');
|
||||
@@ -72,7 +73,8 @@ var tests = <IsolateTest>[
|
||||
expect(result.valueAsString, '10005');
|
||||
|
||||
await expectError(
|
||||
() => service.evaluate(isolateId, instance.id!, 'this + frog'));
|
||||
() => service.evaluate(isolateId, instance.id!, 'this + frog'),
|
||||
);
|
||||
},
|
||||
resumeIsolate,
|
||||
hasStoppedAtBreakpoint,
|
||||
@@ -94,7 +96,7 @@ var tests = <IsolateTest>[
|
||||
}
|
||||
];
|
||||
|
||||
expectError(func) async {
|
||||
Future<void> expectError(func) async {
|
||||
bool gotException = false;
|
||||
dynamic result;
|
||||
try {
|
||||
@@ -109,7 +111,7 @@ expectError(func) async {
|
||||
}
|
||||
}
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'eval_test.dart',
|
||||
|
||||
@@ -11,9 +11,9 @@ var topLevel = 'OtherLibrary';
|
||||
class Superclass2 {
|
||||
final _instVar = 'Superclass2';
|
||||
var instVar = 'Superclass2';
|
||||
method() => 'Superclass2';
|
||||
static staticMethod() => 'Superclass2';
|
||||
suppressWarning() => _instVar;
|
||||
String method() => 'Superclass2';
|
||||
static String staticMethod() => 'Superclass2';
|
||||
String suppressWarning() => _instVar;
|
||||
}
|
||||
|
||||
class Superclass1 extends Superclass2 {
|
||||
@@ -22,12 +22,12 @@ class Superclass1 extends Superclass2 {
|
||||
@override
|
||||
var instVar = 'Superclass1';
|
||||
@override
|
||||
method() => 'Superclass1';
|
||||
static staticMethod() => 'Superclass1';
|
||||
String method() => 'Superclass1';
|
||||
static String staticMethod() => 'Superclass1';
|
||||
|
||||
test() {
|
||||
void test() {
|
||||
// ignore: no_leading_underscores_for_local_identifiers
|
||||
var _local = 'Superclass1';
|
||||
final _local = 'Superclass1';
|
||||
debugger();
|
||||
// Suppress unused variable warning.
|
||||
print(_local);
|
||||
|
||||
@@ -23,24 +23,24 @@ class Subclass extends Superclass1 {
|
||||
@override
|
||||
var instVar = 'Subclass';
|
||||
@override
|
||||
method() => 'Subclass';
|
||||
static staticMethod() => 'Subclass';
|
||||
String method() => 'Subclass';
|
||||
static String staticMethod() => 'Subclass';
|
||||
@override
|
||||
suppressWarning() => _instVar;
|
||||
String suppressWarning() => _instVar;
|
||||
}
|
||||
|
||||
testeeDo() {
|
||||
var obj = Subclass();
|
||||
void testeeDo() {
|
||||
final obj = Subclass();
|
||||
obj.test();
|
||||
}
|
||||
|
||||
Future testerDo(VmService service, IsolateRef isolateRef) async {
|
||||
Future<void> testerDo(VmService service, IsolateRef isolateRef) async {
|
||||
await hasStoppedAtBreakpoint(service, isolateRef);
|
||||
final isolateId = isolateRef.id!;
|
||||
|
||||
// Make sure we are in the right place.
|
||||
var stack = await service.getStack(isolateId);
|
||||
var topFrame = 0;
|
||||
final stack = await service.getStack(isolateId);
|
||||
final topFrame = 0;
|
||||
expect(
|
||||
stack.frames![topFrame].function!.name,
|
||||
equals('test'),
|
||||
@@ -101,7 +101,7 @@ Future testerDo(VmService service, IsolateRef isolateRef) async {
|
||||
expect(result.valueAsString, equals('OtherLibrary'));
|
||||
}
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
[testerDo],
|
||||
'evaluate_activation_in_method_class_test.dart',
|
||||
|
||||
@@ -8,22 +8,29 @@ import 'package:vm_service/vm_service.dart';
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const LINE_A = 16;
|
||||
const LINE_B = LINE_A + 6;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_A = 23;
|
||||
const LINE_B = 29;
|
||||
// AUTOGENERATED END
|
||||
|
||||
class A<T> {
|
||||
void foo() {
|
||||
debugger();
|
||||
debugger(); // LINE_A
|
||||
}
|
||||
}
|
||||
|
||||
class B<S> extends A<int> {
|
||||
void bar() {
|
||||
debugger();
|
||||
debugger(); // LINE_B
|
||||
}
|
||||
}
|
||||
|
||||
testFunction() {
|
||||
void testFunction() {
|
||||
final v = B<String>();
|
||||
v.bar();
|
||||
v.foo();
|
||||
|
||||
@@ -11,9 +11,11 @@ import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
void testFunction() {
|
||||
List<String> x = ['a', 'b', 'c'];
|
||||
int xCombinedLength = x.fold<int>(
|
||||
0, (previousValue, element) => previousValue + element.length);
|
||||
final List<String> x = ['a', 'b', 'c'];
|
||||
final int xCombinedLength = x.fold<int>(
|
||||
0,
|
||||
(previousValue, element) => previousValue + element.length,
|
||||
);
|
||||
debugger();
|
||||
print('xCombinedLength = $xCombinedLength');
|
||||
}
|
||||
|
||||
@@ -8,42 +8,49 @@ import 'package:vm_service/vm_service.dart';
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const LINE_A = 18;
|
||||
const LINE_B = LINE_A + 3;
|
||||
const LINE_C = LINE_B + 6;
|
||||
const LINE_D = LINE_C + 8;
|
||||
const LINE_E = LINE_D + 4;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_A = 25;
|
||||
const LINE_B = 28;
|
||||
const LINE_C = 34;
|
||||
const LINE_D = 42;
|
||||
const LINE_E = 46;
|
||||
// AUTOGENERATED END
|
||||
|
||||
topLevel<S>() {
|
||||
debugger();
|
||||
void topLevel<S>() {
|
||||
debugger(); // LINE_A
|
||||
|
||||
void inner1<TBool, TString, TDouble, TInt>(TInt x) {
|
||||
debugger();
|
||||
debugger(); // LINE_B
|
||||
}
|
||||
|
||||
inner1<bool, String, double, int>(3);
|
||||
|
||||
void inner2() {
|
||||
debugger();
|
||||
debugger(); // LINE_C
|
||||
}
|
||||
|
||||
inner2();
|
||||
}
|
||||
|
||||
class A {
|
||||
foo<T, S>() {
|
||||
debugger();
|
||||
void foo<T, S>() {
|
||||
debugger(); // LINE_D
|
||||
}
|
||||
|
||||
bar<T>(T t) {
|
||||
debugger();
|
||||
void bar<T>(T t) {
|
||||
debugger(); // LINE_E
|
||||
}
|
||||
}
|
||||
|
||||
void testMain() {
|
||||
topLevel<String>();
|
||||
(A()).foo<int, bool>();
|
||||
(A()).bar<dynamic>(42);
|
||||
A().foo<int, bool>();
|
||||
A().bar<dynamic>(42);
|
||||
}
|
||||
|
||||
final tests = <IsolateTest>[
|
||||
@@ -52,7 +59,11 @@ final tests = <IsolateTest>[
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
final isolateId = isolateRef.id!;
|
||||
await evaluateInFrameAndExpect(
|
||||
service, isolateId, 'S.toString()', 'String');
|
||||
service,
|
||||
isolateId,
|
||||
'S.toString()',
|
||||
'String',
|
||||
);
|
||||
},
|
||||
resumeIsolate,
|
||||
hasStoppedAtBreakpoint,
|
||||
|
||||
@@ -13,11 +13,11 @@ import 'common/test_helper.dart';
|
||||
const LINE_A = 19;
|
||||
const LINE_B = LINE_A + 2;
|
||||
|
||||
testFunction() async {
|
||||
var x = 3;
|
||||
var y = 4;
|
||||
Future<int> testFunction() async {
|
||||
final x = 3;
|
||||
final y = 4;
|
||||
debugger();
|
||||
var z = await Future(() => x + y);
|
||||
final z = await Future(() => x + y);
|
||||
debugger();
|
||||
return z;
|
||||
}
|
||||
|
||||
@@ -29,10 +29,8 @@ Stream<int> generator() async* {
|
||||
yield z;
|
||||
}
|
||||
|
||||
testFunction() async {
|
||||
await for (var _ in generator()) {
|
||||
{}
|
||||
}
|
||||
Future<void> testFunction() async {
|
||||
await for (var _ in generator()) {}
|
||||
}
|
||||
|
||||
final tests = <IsolateTest>[
|
||||
|
||||
@@ -29,7 +29,7 @@ void testeeMain() {
|
||||
}
|
||||
|
||||
int foo(x, y) {
|
||||
var local = x + y;
|
||||
final local = x + y;
|
||||
debugger(); // LINE_A
|
||||
return local;
|
||||
}
|
||||
@@ -95,10 +95,15 @@ final tests = <IsolateTest>[
|
||||
);
|
||||
|
||||
try {
|
||||
await service.evaluate(isolateId, rootLibId, 'x + y', scope: {
|
||||
'x': rootLibId,
|
||||
'y': rootLibId,
|
||||
});
|
||||
await service.evaluate(
|
||||
isolateId,
|
||||
rootLibId,
|
||||
'x + y',
|
||||
scope: {
|
||||
'x': rootLibId,
|
||||
'y': rootLibId,
|
||||
},
|
||||
);
|
||||
fail('Evaluated against a VM-internal object');
|
||||
} on RPCError catch (e) {
|
||||
expect(e.code, RPCErrorKind.kExpressionCompilationError.code);
|
||||
@@ -109,15 +114,20 @@ final tests = <IsolateTest>[
|
||||
}
|
||||
|
||||
try {
|
||||
await service.evaluate(isolateId, rootLibId, 'x + y', scope: {
|
||||
'not&an&identifier': thing1.id!,
|
||||
});
|
||||
await service.evaluate(
|
||||
isolateId,
|
||||
rootLibId,
|
||||
'x + y',
|
||||
scope: {
|
||||
'not&an&identifier': thing1.id!,
|
||||
},
|
||||
);
|
||||
fail('Evaluated with an invalid identifier');
|
||||
} on RPCError catch (e) {
|
||||
expect(e.code, RPCErrorKind.kExpressionCompilationError.code);
|
||||
expect(
|
||||
e.details,
|
||||
contains('invalid \'scope\' parameter'),
|
||||
contains("invalid 'scope' parameter"),
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -12,22 +12,29 @@ import 'package:vm_service/vm_service.dart';
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const LINE_A = 23;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_A = 30;
|
||||
// AUTOGENERATED END
|
||||
|
||||
class S {}
|
||||
|
||||
mixin class M {
|
||||
static String? foo;
|
||||
bar() {
|
||||
void bar() {
|
||||
foo = 'theExpectedValue';
|
||||
debugger();
|
||||
debugger(); // LINE_A
|
||||
}
|
||||
}
|
||||
|
||||
// MA=S&M -> S -> Object
|
||||
class MA = S with M;
|
||||
|
||||
testeeMain() {
|
||||
void testeeMain() {
|
||||
MA().bar();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,22 +12,29 @@ import 'package:vm_service/vm_service.dart';
|
||||
import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
const LINE_A = 23;
|
||||
// AUTOGENERATED START
|
||||
//
|
||||
// Update these constants by running:
|
||||
//
|
||||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
|
||||
//
|
||||
const LINE_A = 30;
|
||||
// AUTOGENERATED END
|
||||
|
||||
class S {}
|
||||
|
||||
mixin class M {
|
||||
static String? foo;
|
||||
bar() {
|
||||
void bar() {
|
||||
foo = 'theExpectedValue';
|
||||
debugger();
|
||||
debugger(); // LINE_A
|
||||
}
|
||||
}
|
||||
|
||||
// MA2 -> S&M -> S -> Object
|
||||
class MA extends S with M {}
|
||||
|
||||
testeeMain() {
|
||||
void testeeMain() {
|
||||
MA().bar();
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ class C {
|
||||
|
||||
void use(_) {}
|
||||
|
||||
testMain() {
|
||||
C c = C();
|
||||
void testMain() {
|
||||
final C c = C();
|
||||
C.staticMethod();
|
||||
c.instanceMethod();
|
||||
}
|
||||
@@ -49,7 +49,10 @@ final tests = <IsolateTest>[
|
||||
expect(xRef.valueAsString, '56');
|
||||
|
||||
InstanceRef staticFieldRef = await service.evaluateInFrame(
|
||||
isolateId, 0, 'staticField += 1') as InstanceRef;
|
||||
isolateId,
|
||||
0,
|
||||
'staticField += 1',
|
||||
) as InstanceRef;
|
||||
expect(staticFieldRef.valueAsString, '13');
|
||||
staticFieldRef = await service.evaluateInFrame(isolateId, 0, 'staticField')
|
||||
as InstanceRef;
|
||||
@@ -75,21 +78,33 @@ final tests = <IsolateTest>[
|
||||
expect(yRef.valueAsString, '78');
|
||||
|
||||
InstanceRef staticFieldRef = await service.evaluateInFrame(
|
||||
isolateId, 0, 'staticField += 1') as InstanceRef;
|
||||
isolateId,
|
||||
0,
|
||||
'staticField += 1',
|
||||
) as InstanceRef;
|
||||
expect(staticFieldRef.valueAsString, '14');
|
||||
staticFieldRef = await service.evaluateInFrame(isolateId, 0, 'staticField')
|
||||
as InstanceRef;
|
||||
expect(staticFieldRef.valueAsString, '14');
|
||||
|
||||
InstanceRef instanceFieldRef = await service.evaluateInFrame(
|
||||
isolateId, 0, 'instanceField += 1') as InstanceRef;
|
||||
isolateId,
|
||||
0,
|
||||
'instanceField += 1',
|
||||
) as InstanceRef;
|
||||
expect(instanceFieldRef.valueAsString, '35');
|
||||
instanceFieldRef = await service.evaluateInFrame(
|
||||
isolateId, 0, 'instanceField') as InstanceRef;
|
||||
isolateId,
|
||||
0,
|
||||
'instanceField',
|
||||
) as InstanceRef;
|
||||
expect(instanceFieldRef.valueAsString, '35');
|
||||
}
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) async =>
|
||||
runIsolateTests(args, tests, 'evaluate_inside_closures_test.dart',
|
||||
testeeConcurrent: testMain);
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'evaluate_inside_closures_test.dart',
|
||||
testeeConcurrent: testMain,
|
||||
);
|
||||
|
||||
@@ -11,15 +11,15 @@ import 'common/test_helper.dart';
|
||||
|
||||
extension on String {
|
||||
String printAndReturnHello() {
|
||||
String response = "Hello from String '$this'";
|
||||
final String response = "Hello from String '$this'";
|
||||
print(response);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
void testFunction() {
|
||||
String x = 'hello';
|
||||
String value = x.printAndReturnHello();
|
||||
final String x = 'hello';
|
||||
final String value = x.printAndReturnHello();
|
||||
debugger();
|
||||
print('value = $value');
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'common/service_test_common.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
void testFunction() {
|
||||
List<dynamic> v = <dynamic>[1, 2, '3'];
|
||||
final List<dynamic> v = <dynamic>[1, 2, '3'];
|
||||
debugger();
|
||||
print('v = $v');
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'common/test_helper.dart';
|
||||
|
||||
dynamic escapedClosure;
|
||||
|
||||
testeeMain() {}
|
||||
void testeeMain() {}
|
||||
|
||||
final tests = <IsolateTest>[
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
|
||||
@@ -10,14 +10,18 @@ import 'common/test_helper.dart';
|
||||
int? thing1;
|
||||
int? thing2;
|
||||
|
||||
testeeMain() {
|
||||
void testeeMain() {
|
||||
thing1 = 3;
|
||||
thing2 = 4;
|
||||
}
|
||||
|
||||
Future evaluate(VmService service, isolate, target, x, y) async =>
|
||||
await service.evaluate(isolate!.id!!, target.id!, 'x + y',
|
||||
scope: {'x': x.id!, 'y': y.id!});
|
||||
Future<InstanceRef> evaluate(VmService service, isolate, target, x, y) async =>
|
||||
await service.evaluate(
|
||||
isolate!.id!!,
|
||||
target.id!,
|
||||
'x + y',
|
||||
scope: {'x': x.id!, 'y': y.id!},
|
||||
) as InstanceRef;
|
||||
|
||||
final tests = <IsolateTest>[
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
@@ -26,15 +30,17 @@ final tests = <IsolateTest>[
|
||||
final Library lib =
|
||||
(await service.getObject(isolateId, isolate.rootLib!.id!)) as Library;
|
||||
|
||||
final Field field1 = (await service.getObject(isolateId,
|
||||
lib.variables!.singleWhere((v) => v.name == 'thing1').id!)) as Field;
|
||||
final thing1 =
|
||||
(await service.getObject(isolateId, field1.staticValue!.id!));
|
||||
final Field field1 = (await service.getObject(
|
||||
isolateId,
|
||||
lib.variables!.singleWhere((v) => v.name == 'thing1').id!,
|
||||
)) as Field;
|
||||
final thing1 = await service.getObject(isolateId, field1.staticValue!.id!);
|
||||
|
||||
final Field field2 = (await service.getObject(isolateId,
|
||||
lib.variables!.singleWhere((v) => v.name == 'thing2').id!)) as Field;
|
||||
final thing2 =
|
||||
(await service.getObject(isolateId, field2.staticValue!.id!));
|
||||
final Field field2 = (await service.getObject(
|
||||
isolateId,
|
||||
lib.variables!.singleWhere((v) => v.name == 'thing2').id!,
|
||||
)) as Field;
|
||||
final thing2 = await service.getObject(isolateId, field2.staticValue!.id!);
|
||||
|
||||
var result = await evaluate(service, isolate, lib, thing1, thing2);
|
||||
expect(result.valueAsString, equals('7'));
|
||||
@@ -45,15 +51,21 @@ final tests = <IsolateTest>[
|
||||
print(result);
|
||||
} catch (e) {
|
||||
didThrow = true;
|
||||
expect(e.toString(),
|
||||
contains('Cannot evaluate against a VM-internal object'));
|
||||
expect(
|
||||
e.toString(),
|
||||
contains('Cannot evaluate against a VM-internal object'),
|
||||
);
|
||||
}
|
||||
expect(didThrow, isTrue);
|
||||
|
||||
didThrow = false;
|
||||
try {
|
||||
result = await service.evaluate(isolateId, lib.id!, 'x + y',
|
||||
scope: <String, String>{'not&an&id!entifier': thing1.id!});
|
||||
result = await service.evaluate(
|
||||
isolateId,
|
||||
lib.id!,
|
||||
'x + y',
|
||||
scope: <String, String>{'not&an&id!entifier': thing1.id!},
|
||||
) as InstanceRef;
|
||||
print(result);
|
||||
} catch (e) {
|
||||
didThrow = true;
|
||||
@@ -63,7 +75,7 @@ final tests = <IsolateTest>[
|
||||
}
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) => runIsolateTests(
|
||||
Future<void> main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'evaluate_with_scope_test.dart',
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
|
||||
import 'dart:developer';
|
||||
|
||||
main() {
|
||||
void main() {
|
||||
debugger();
|
||||
}
|
||||
|
||||
@@ -83,7 +83,10 @@ void main() {
|
||||
await waitForRunnableIsolate(service, isolate);
|
||||
try {
|
||||
await service.evaluate(
|
||||
isolate.id!, isolate.libraries!.first.id!, '1 + 1');
|
||||
isolate.id!,
|
||||
isolate.libraries!.first.id!,
|
||||
'1 + 1',
|
||||
);
|
||||
} catch (_) {
|
||||
// ignore error
|
||||
}
|
||||
|
||||
@@ -68,11 +68,13 @@ Future<void> testSuccessService(
|
||||
// check requests while they arrive
|
||||
expect(params[paramKey + end], paramValue + end);
|
||||
// answer later
|
||||
completions.add(() => responseCompleter.complete({
|
||||
'result': {
|
||||
resultKey + end: resultValue + end,
|
||||
},
|
||||
}));
|
||||
completions.add(
|
||||
() => responseCompleter.complete({
|
||||
'result': {
|
||||
resultKey + end: resultValue + end,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// Shuffle and respond out of order.
|
||||
|
||||
@@ -10,13 +10,13 @@ import 'common/test_helper.dart';
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
var profile = await service.getAllocationProfile(isolateRef.id!);
|
||||
final profile = await service.getAllocationProfile(isolateRef.id!);
|
||||
for (var entry in profile.members!) {
|
||||
if (entry.instancesCurrent == 0) continue;
|
||||
|
||||
var classRef = entry.classRef!;
|
||||
final classRef = entry.classRef!;
|
||||
print(classRef);
|
||||
var instanceSet =
|
||||
final instanceSet =
|
||||
await service.getInstances(isolateRef.id!, classRef.id!, 10);
|
||||
for (var instance in instanceSet.instances!) {
|
||||
await service.getObject(isolateRef.id!, instance.id!);
|
||||
@@ -25,7 +25,7 @@ var tests = <IsolateTest>[
|
||||
},
|
||||
];
|
||||
|
||||
main(args) => runIsolateTests(
|
||||
Future<void> main(args) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'fetch_all_types_test.dart',
|
||||
|
||||
@@ -71,8 +71,10 @@ final tests = <IsolateTest>[
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
final isolateId = isolateRef.id!;
|
||||
try {
|
||||
await service.callServiceExtension('ext.dart.io.setup',
|
||||
isolateId: isolateId);
|
||||
await service.callServiceExtension(
|
||||
'ext.dart.io.setup',
|
||||
isolateId: isolateId,
|
||||
);
|
||||
final result = await service.getOpenFiles(isolateId);
|
||||
expect(result.files.length, 2);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:vm_service/vm_service.dart';
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
void script() {
|
||||
grow(int iterations, int size, Duration duration) {
|
||||
void grow(int iterations, int size, Duration duration) {
|
||||
if (iterations <= 0) {
|
||||
return;
|
||||
}
|
||||
@@ -22,7 +22,7 @@ void script() {
|
||||
|
||||
final tests = <IsolateTest>[
|
||||
(VmService service, IsolateRef isolateRef) async {
|
||||
Completer completer = Completer();
|
||||
final Completer completer = Completer();
|
||||
// Expect at least this many GC events.
|
||||
int gcCountdown = 3;
|
||||
late final StreamSubscription sub;
|
||||
|
||||
@@ -65,7 +65,7 @@ var tests = <IsolateTest>[
|
||||
},
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) async => runIsolateTests(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'get_allocation_profile_rpc_test.dart',
|
||||
|
||||
@@ -23,7 +23,7 @@ class Bar {
|
||||
}
|
||||
|
||||
void test() {
|
||||
List l = <Object>[];
|
||||
final List l = <Object>[];
|
||||
debugger();
|
||||
// Toggled on for Foo.
|
||||
// Traced allocation.
|
||||
@@ -43,7 +43,7 @@ Future<Class?> getClassFromRootLib(
|
||||
String className,
|
||||
) async {
|
||||
final isolate = await service.getIsolate(isolateRef.id!);
|
||||
Library rootLib =
|
||||
final Library rootLib =
|
||||
(await service.getObject(isolate.id!, isolate.rootLib!.id!)) as Library;
|
||||
for (ClassRef cls in rootLib.classes!) {
|
||||
if (cls.name == className) {
|
||||
@@ -92,8 +92,10 @@ final tests = <IsolateTest>[
|
||||
expect(instances.totalCount, 1);
|
||||
final instance = instances.instances!.first as InstanceRef;
|
||||
expect(instance.identityHashCode != 0, isTrue);
|
||||
expect(instance.identityHashCode,
|
||||
profileResponse.samples!.first.identityHashCode);
|
||||
expect(
|
||||
instance.identityHashCode,
|
||||
profileResponse.samples!.first.identityHashCode,
|
||||
);
|
||||
|
||||
await service.setTraceClassAllocation(isolate.id!, fooClass.id!, false);
|
||||
|
||||
@@ -114,12 +116,12 @@ final tests = <IsolateTest>[
|
||||
|
||||
(VmService service, IsolateRef isolate) async {
|
||||
// Ensure the allocation of `Bar()` was recorded.
|
||||
final profileResponse = (await service.getAllocationTraces(isolate.id!));
|
||||
final profileResponse = await service.getAllocationTraces(isolate.id!);
|
||||
expect(profileResponse.samples!.length, 2);
|
||||
},
|
||||
];
|
||||
|
||||
main(args) async => runIsolateTests(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'get_allocation_traces_test.dart',
|
||||
|
||||
@@ -7,19 +7,19 @@ import 'package:vm_service/vm_service.dart';
|
||||
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
fib(n) {
|
||||
int fib(n) {
|
||||
if (n < 0) return 0;
|
||||
if (n == 0) return 1;
|
||||
return fib(n - 1) + fib(n - 2);
|
||||
}
|
||||
|
||||
testeeDo() {
|
||||
void testeeDo() {
|
||||
print('Testee doing something.');
|
||||
fib(30);
|
||||
print('Testee did something.');
|
||||
}
|
||||
|
||||
Future checkSamples(VmService service, IsolateRef isolate) async {
|
||||
Future<void> checkSamples(VmService service, IsolateRef isolate) async {
|
||||
// Grab all the samples.
|
||||
final isolateId = isolate.id!;
|
||||
final result = await service.getCpuSamples(isolateId, 0, ~0);
|
||||
@@ -27,8 +27,11 @@ Future checkSamples(VmService service, IsolateRef isolate) async {
|
||||
final isString = TypeMatcher<String>();
|
||||
final isInt = TypeMatcher<int>();
|
||||
final isList = TypeMatcher<List>();
|
||||
expect(result.functions!.length, greaterThan(10),
|
||||
reason: 'Should have many functions!');
|
||||
expect(
|
||||
result.functions!.length,
|
||||
greaterThan(10),
|
||||
reason: 'Should have many functions!',
|
||||
);
|
||||
|
||||
final samples = result.samples!;
|
||||
expect(samples.length, greaterThan(10), reason: 'Should have many samples');
|
||||
@@ -46,16 +49,16 @@ Future checkSamples(VmService service, IsolateRef isolate) async {
|
||||
expect(sample.stack, isList);
|
||||
}
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
((VmService service, IsolateRef i) => checkSamples(service, i)),
|
||||
final tests = <IsolateTest>[
|
||||
checkSamples,
|
||||
];
|
||||
|
||||
var vmArgs = [
|
||||
const vmArgs = <String>[
|
||||
'--profiler=true',
|
||||
'--profile-vm=false', // So this also works with KBC.
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) async => runIsolateTests(
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'get_cpu_samples_rpc_test.dart',
|
||||
|
||||
@@ -30,7 +30,9 @@ final tests = <VMTest>[
|
||||
// Modify a flag with the wrong value type.
|
||||
(VmService service) async {
|
||||
final Error result = (await service.setFlag(
|
||||
'pause_isolates_on_start', 'not-boolean')) as Error;
|
||||
'pause_isolates_on_start',
|
||||
'not-boolean',
|
||||
)) as Error;
|
||||
expect(result.message, equals('Cannot set flag: invalid value'));
|
||||
},
|
||||
|
||||
|
||||
@@ -58,10 +58,12 @@ Uri randomlyAddRequestParams(Uri uri) {
|
||||
possiblePathSegments.sublist(0, rng.nextInt(possiblePathSegments.length));
|
||||
uri = uri.replace(pathSegments: segmentSubset);
|
||||
if (rng.nextInt(3) == 0) {
|
||||
uri = uri.replace(queryParameters: {
|
||||
'foo': 'bar',
|
||||
'year': '2019',
|
||||
});
|
||||
uri = uri.replace(
|
||||
queryParameters: {
|
||||
'foo': 'bar',
|
||||
'year': '2019',
|
||||
},
|
||||
);
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
@@ -78,7 +80,8 @@ Future<HttpServer> startServer() async {
|
||||
}
|
||||
// Randomly delay response.
|
||||
await Future.delayed(
|
||||
Duration(milliseconds: rng.nextInt(maxResponseDelayMs)));
|
||||
Duration(milliseconds: rng.nextInt(maxResponseDelayMs)),
|
||||
);
|
||||
await response.close();
|
||||
});
|
||||
return server;
|
||||
@@ -305,7 +308,7 @@ void hasDefaultRequestHeaders(HttpProfile profile) {
|
||||
}
|
||||
|
||||
void hasCustomRequestHeaders(HttpProfile profile) {
|
||||
var requests = profile.requests.where((e) => e.method == 'GET').toList();
|
||||
final requests = profile.requests.where((e) => e.method == 'GET').toList();
|
||||
for (final request in requests) {
|
||||
// Some requests are unable to complete due to the server closing after a
|
||||
// random delay. Don't try and inspect the request data from these
|
||||
|
||||
@@ -44,9 +44,11 @@ final tests = <IsolateTest>[
|
||||
const <String>[],
|
||||
);
|
||||
|
||||
Future<int> instanceCount(String className,
|
||||
{bool includeSubclasses = false,
|
||||
bool includeImplementors = false}) async {
|
||||
Future<int> instanceCount(
|
||||
String className, {
|
||||
bool includeSubclasses = false,
|
||||
bool includeImplementors = false,
|
||||
}) async {
|
||||
final objectId =
|
||||
rootLib.classes!.singleWhere((cls) => cls.name == className).id!;
|
||||
final result = await service.getInstancesAsList(
|
||||
|
||||
+7
-3
@@ -25,7 +25,8 @@ final tests = <IsolateTest>[
|
||||
if (error.code == 113 &&
|
||||
error.message == 'Expression compilation error' &&
|
||||
error.details.contains(
|
||||
"invalid 'targetId' parameter: Cannot evaluate against a VM-internal object")) {
|
||||
"invalid 'targetId' parameter: Cannot evaluate against a VM-internal object",
|
||||
)) {
|
||||
gotError = true;
|
||||
return Response();
|
||||
} else {
|
||||
@@ -47,5 +48,8 @@ final tests = <IsolateTest>[
|
||||
}
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) async => runIsolateTests(args, tests,
|
||||
'get_instances_as_list_rpc_expression_evaluation_on_internal_test.dart');
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'get_instances_as_list_rpc_expression_evaluation_on_internal_test.dart',
|
||||
);
|
||||
|
||||
@@ -53,9 +53,11 @@ IsolateTest expectInstanceCounts(
|
||||
isolate.rootLib!.id!,
|
||||
) as Library;
|
||||
|
||||
Future<int> instanceCount(String className,
|
||||
{bool includeSubclasses = false,
|
||||
bool includeImplementers = false}) async {
|
||||
Future<int> instanceCount(
|
||||
String className, {
|
||||
bool includeSubclasses = false,
|
||||
bool includeImplementers = false,
|
||||
}) async {
|
||||
final result = await service.getInstancesAsList(
|
||||
isolateId,
|
||||
rootLib.classes!
|
||||
|
||||
@@ -41,9 +41,10 @@ void testMain() {
|
||||
}
|
||||
|
||||
IsolateTest expectInstanceCounts(
|
||||
int numInstances,
|
||||
int numInstancesWhenIncludingSubclasses,
|
||||
int numInstancesWhenIncludingImplementers) {
|
||||
int numInstances,
|
||||
int numInstancesWhenIncludingSubclasses,
|
||||
int numInstancesWhenIncludingImplementers,
|
||||
) {
|
||||
return (VmService service, IsolateRef isolateRef) async {
|
||||
final isolateId = isolateRef.id!;
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
@@ -52,9 +53,11 @@ IsolateTest expectInstanceCounts(
|
||||
isolate.rootLib!.id!,
|
||||
) as Library;
|
||||
|
||||
Future<int> instanceCount(String className,
|
||||
{bool includeSubclasses = false,
|
||||
bool includeImplementers = false}) async {
|
||||
Future<int> instanceCount(
|
||||
String className, {
|
||||
bool includeSubclasses = false,
|
||||
bool includeImplementers = false,
|
||||
}) async {
|
||||
final result = await service.getInstances(
|
||||
isolateId,
|
||||
rootLib.classes!.singleWhere((cls) => cls.name == className).id!,
|
||||
|
||||
@@ -24,15 +24,17 @@ var tests = <VMTest>[
|
||||
} on RPCError catch (e) {
|
||||
caughtException = true;
|
||||
expect(
|
||||
e.details,
|
||||
contains(
|
||||
"getMemoryUsage: invalid 'isolateGroupId' parameter: badid"));
|
||||
e.details,
|
||||
contains(
|
||||
"getMemoryUsage: invalid 'isolateGroupId' parameter: badid",
|
||||
),
|
||||
);
|
||||
}
|
||||
expect(caughtException, isTrue);
|
||||
},
|
||||
];
|
||||
|
||||
main(args) async => runVMTests(
|
||||
void main([args = const <String>[]]) => runVMTests(
|
||||
args,
|
||||
tests,
|
||||
'get_isolate_group_memory_usage.dart',
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:vm_service/vm_service.dart';
|
||||
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
var tests = <VMTest>[
|
||||
final tests = <VMTest>[
|
||||
(VmService service) async {
|
||||
final vm = await service.getVM();
|
||||
final result = await service.getIsolatePauseEvent(vm.isolates!.first.id!);
|
||||
@@ -33,7 +33,7 @@ var tests = <VMTest>[
|
||||
},
|
||||
];
|
||||
|
||||
main(args) async => runVMTests(
|
||||
void main([args = const <String>[]]) => runVMTests(
|
||||
args,
|
||||
tests,
|
||||
'get_isolate_pause_event_rpc_test.dart',
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:vm_service/vm_service.dart';
|
||||
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
var tests = <VMTest>[
|
||||
final tests = <VMTest>[
|
||||
(VmService service) async {
|
||||
final vm = await service.getVM();
|
||||
final result = await service.getIsolate(vm.isolates!.first.id!);
|
||||
@@ -55,7 +55,7 @@ var tests = <VMTest>[
|
||||
},
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) async => runVMTests(
|
||||
void main([args = const <String>[]]) => runVMTests(
|
||||
args,
|
||||
tests,
|
||||
'get_isolate_rpc_test.dart',
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:vm_service/vm_service.dart';
|
||||
|
||||
import 'common/test_helper.dart';
|
||||
|
||||
var tests = <VMTest>[
|
||||
final tests = <VMTest>[
|
||||
(VmService service) async {
|
||||
final vm = await service.getVM();
|
||||
final result = await service.getMemoryUsage(vm.isolates!.first.id!);
|
||||
@@ -22,14 +22,16 @@ var tests = <VMTest>[
|
||||
fail('Unreachable');
|
||||
} on RPCError catch (e) {
|
||||
caughtException = true;
|
||||
expect(e.details,
|
||||
contains("getMemoryUsage: invalid 'isolateId' parameter: badid"));
|
||||
expect(
|
||||
e.details,
|
||||
contains("getMemoryUsage: invalid 'isolateId' parameter: badid"),
|
||||
);
|
||||
}
|
||||
expect(caughtException, isTrue);
|
||||
},
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) async => runVMTests(
|
||||
void main([args = const <String>[]]) => runVMTests(
|
||||
args,
|
||||
tests,
|
||||
'get_memory_usage_test.dart',
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
// @dart=3.0
|
||||
|
||||
// ignore_for_file: library_private_types_in_public_api
|
||||
|
||||
library get_object_rpc_test;
|
||||
|
||||
import 'dart:collection';
|
||||
@@ -60,43 +62,44 @@ void warmup() {
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
getChattanooga() => 'Chattanooga';
|
||||
String getChattanooga() => 'Chattanooga';
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
getList() => [3, 2, 1];
|
||||
List<int> getList() => [3, 2, 1];
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
getMap() => {'x': 3, 'y': 4, 'z': 5};
|
||||
Map<String, int> getMap() => {'x': 3, 'y': 4, 'z': 5};
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
getSet() => {6, 7, 8};
|
||||
Set<int> getSet() => {6, 7, 8};
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
getUint8List() => Uint8List.fromList([3, 2, 1]);
|
||||
Uint8List getUint8List() => Uint8List.fromList([3, 2, 1]);
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
getUint64List() => Uint64List.fromList([3, 2, 1]);
|
||||
Uint64List getUint64List() => Uint64List.fromList([3, 2, 1]);
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
getRecord() => (1, x: 2, 3.0, y: 4.0);
|
||||
(int, double, {int x, double y}) getRecord() => (1, x: 2, 3.0, y: 4.0);
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
getDummyClass() => _DummyClass();
|
||||
_DummyClass getDummyClass() => _DummyClass();
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
getDummyFinalClass() => _DummyFinalClass();
|
||||
_DummyFinalClass getDummyFinalClass() => _DummyFinalClass();
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
getDummyGenericSubClass() => _DummyGenericSubClass<Object>();
|
||||
_DummyGenericSubClass<Object> getDummyGenericSubClass() =>
|
||||
_DummyGenericSubClass<Object>();
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
getDummyInterfaceClass() => _DummyInterfaceClass();
|
||||
_DummyInterfaceClass getDummyInterfaceClass() => _DummyInterfaceClass();
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
getDummyClassWithMixins() => _DummyClassWithMixins();
|
||||
_DummyClassWithMixins getDummyClassWithMixins() => _DummyClassWithMixins();
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
getUserTag() => UserTag('Test Tag');
|
||||
UserTag getUserTag() => UserTag('Test Tag');
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
// null object.
|
||||
@@ -144,7 +147,11 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a Dart String.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getChattanooga', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getChattanooga',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = evalResult.id!;
|
||||
final result = await service.getObject(isolateId, objectId) as Instance;
|
||||
expect(result.kind, InstanceKind.kString);
|
||||
@@ -165,7 +172,11 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a Dart String.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getChattanooga', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getChattanooga',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = evalResult.id!;
|
||||
final result =
|
||||
await service.getObject(isolateId, objectId, count: 4) as Instance;
|
||||
@@ -187,10 +198,18 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a Dart String.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getChattanooga', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getChattanooga',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = evalResult.id!;
|
||||
final result = await service.getObject(isolateId, objectId,
|
||||
offset: 4, count: 6) as Instance;
|
||||
final result = await service.getObject(
|
||||
isolateId,
|
||||
objectId,
|
||||
offset: 4,
|
||||
count: 6,
|
||||
) as Instance;
|
||||
expect(result.kind, InstanceKind.kString);
|
||||
expect(result.json!['_vmType'], equals('String'));
|
||||
expect(result.id, startsWith('objects/'));
|
||||
@@ -209,10 +228,18 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a Dart String.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getChattanooga', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getChattanooga',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = evalResult.id!;
|
||||
final result = await service.getObject(isolateId, objectId,
|
||||
offset: 100, count: 2) as Instance;
|
||||
final result = await service.getObject(
|
||||
isolateId,
|
||||
objectId,
|
||||
offset: 100,
|
||||
count: 2,
|
||||
) as Instance;
|
||||
expect(result.kind, InstanceKind.kString);
|
||||
expect(result.json!['_vmType'], equals('String'));
|
||||
expect(result.id, startsWith('objects/'));
|
||||
@@ -295,8 +322,12 @@ var tests = <IsolateTest>[
|
||||
final evalResult = await service
|
||||
.invoke(isolateId, isolate.rootLib!.id!, 'getList', []) as InstanceRef;
|
||||
final objectId = evalResult.id!;
|
||||
final result = await service.getObject(isolateId, objectId,
|
||||
offset: 2, count: 2) as Instance;
|
||||
final result = await service.getObject(
|
||||
isolateId,
|
||||
objectId,
|
||||
offset: 2,
|
||||
count: 2,
|
||||
) as Instance;
|
||||
expect(result.kind, InstanceKind.kList);
|
||||
expect(result.json!['_vmType'], equals('GrowableObjectArray'));
|
||||
expect(result.id, startsWith('objects/'));
|
||||
@@ -322,8 +353,12 @@ var tests = <IsolateTest>[
|
||||
final evalResult = await service
|
||||
.invoke(isolateId, isolate.rootLib!.id!, 'getList', []) as InstanceRef;
|
||||
final objectId = evalResult.id!;
|
||||
final result = await service.getObject(isolateId, objectId,
|
||||
offset: 100, count: 2) as Instance;
|
||||
final result = await service.getObject(
|
||||
isolateId,
|
||||
objectId,
|
||||
offset: 100,
|
||||
count: 2,
|
||||
) as Instance;
|
||||
expect(result.kind, InstanceKind.kList);
|
||||
expect(result.json!['_vmType'], equals('GrowableObjectArray'));
|
||||
expect(result.id, startsWith('objects/'));
|
||||
@@ -422,8 +457,12 @@ var tests = <IsolateTest>[
|
||||
final evalResult = await service
|
||||
.invoke(isolateId, isolate.rootLib!.id!, 'getMap', []) as InstanceRef;
|
||||
final objectId = evalResult.id!;
|
||||
final result = await service.getObject(isolateId, objectId,
|
||||
offset: 2, count: 2) as Instance;
|
||||
final result = await service.getObject(
|
||||
isolateId,
|
||||
objectId,
|
||||
offset: 2,
|
||||
count: 2,
|
||||
) as Instance;
|
||||
expect(result.kind, InstanceKind.kMap);
|
||||
expect(result.json!['_vmType'], equals('Map'));
|
||||
expect(result.id, startsWith('objects/'));
|
||||
@@ -452,8 +491,12 @@ var tests = <IsolateTest>[
|
||||
final evalResult = await service
|
||||
.invoke(isolateId, isolate.rootLib!.id!, 'getMap', []) as InstanceRef;
|
||||
final objectId = evalResult.id!;
|
||||
final result = await service.getObject(isolateId, objectId,
|
||||
offset: 100, count: 2) as Instance;
|
||||
final result = await service.getObject(
|
||||
isolateId,
|
||||
objectId,
|
||||
offset: 100,
|
||||
count: 2,
|
||||
) as Instance;
|
||||
expect(result.kind, InstanceKind.kMap);
|
||||
expect(result.json!['_vmType'], equals('Map'));
|
||||
expect(result.id, startsWith('objects/'));
|
||||
@@ -505,7 +548,11 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a Dart list.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getUint8List', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getUint8List',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = evalResult.id!;
|
||||
final result = await service.getObject(isolateId, objectId) as Instance;
|
||||
expect(result.kind, InstanceKind.kUint8List);
|
||||
@@ -519,7 +566,7 @@ var tests = <IsolateTest>[
|
||||
expect(result.offset, isNull);
|
||||
expect(result.count, isNull);
|
||||
expect(result.bytes, equals('AwIB'));
|
||||
Uint8List bytes = base64Decode(result.bytes!);
|
||||
final Uint8List bytes = base64Decode(result.bytes!);
|
||||
expect(bytes.buffer.asUint8List().toString(), equals('[3, 2, 1]'));
|
||||
},
|
||||
|
||||
@@ -529,7 +576,11 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a Dart list.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getUint8List', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getUint8List',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = evalResult.id!;
|
||||
final result =
|
||||
await service.getObject(isolateId, objectId, count: 2) as Instance;
|
||||
@@ -544,7 +595,7 @@ var tests = <IsolateTest>[
|
||||
expect(result.offset, isNull);
|
||||
expect(result.count, equals(2));
|
||||
expect(result.bytes, equals('AwI='));
|
||||
Uint8List bytes = base64Decode(result.bytes!);
|
||||
final Uint8List bytes = base64Decode(result.bytes!);
|
||||
expect(bytes.buffer.asUint8List().toString(), equals('[3, 2]'));
|
||||
},
|
||||
|
||||
@@ -554,10 +605,18 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a Dart list.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getUint8List', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getUint8List',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = evalResult.id!;
|
||||
final result = await service.getObject(isolateId, objectId,
|
||||
offset: 2, count: 2) as Instance;
|
||||
final result = await service.getObject(
|
||||
isolateId,
|
||||
objectId,
|
||||
offset: 2,
|
||||
count: 2,
|
||||
) as Instance;
|
||||
expect(result.kind, InstanceKind.kUint8List);
|
||||
expect(result.json!['_vmType'], equals('TypedData'));
|
||||
expect(result.id, startsWith('objects/'));
|
||||
@@ -569,7 +628,7 @@ var tests = <IsolateTest>[
|
||||
expect(result.offset, equals(2));
|
||||
expect(result.count, equals(1));
|
||||
expect(result.bytes, equals('AQ=='));
|
||||
Uint8List bytes = base64Decode(result.bytes!);
|
||||
final Uint8List bytes = base64Decode(result.bytes!);
|
||||
expect(bytes.buffer.asUint8List().toString(), equals('[1]'));
|
||||
},
|
||||
|
||||
@@ -579,10 +638,18 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a Dart list.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getUint8List', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getUint8List',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = evalResult.id!;
|
||||
final result = await service.getObject(isolateId, objectId,
|
||||
offset: 100, count: 2) as Instance;
|
||||
final result = await service.getObject(
|
||||
isolateId,
|
||||
objectId,
|
||||
offset: 100,
|
||||
count: 2,
|
||||
) as Instance;
|
||||
expect(result.kind, InstanceKind.kUint8List);
|
||||
expect(result.json!['_vmType'], equals('TypedData'));
|
||||
expect(result.id, startsWith('objects/'));
|
||||
@@ -602,7 +669,11 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a Dart list.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getUint64List', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getUint64List',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = evalResult.id!;
|
||||
final result = await service.getObject(isolateId, objectId) as Instance;
|
||||
expect(result.kind, InstanceKind.kUint64List);
|
||||
@@ -616,7 +687,7 @@ var tests = <IsolateTest>[
|
||||
expect(result.offset, isNull);
|
||||
expect(result.count, isNull);
|
||||
expect(result.bytes, equals('AwAAAAAAAAACAAAAAAAAAAEAAAAAAAAA'));
|
||||
Uint8List bytes = base64Decode(result.bytes!);
|
||||
final Uint8List bytes = base64Decode(result.bytes!);
|
||||
expect(bytes.buffer.asUint64List().toString(), equals('[3, 2, 1]'));
|
||||
},
|
||||
|
||||
@@ -626,7 +697,11 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a Dart list.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getUint64List', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getUint64List',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = evalResult.id!;
|
||||
final result =
|
||||
await service.getObject(isolateId, objectId, count: 2) as Instance;
|
||||
@@ -641,7 +716,7 @@ var tests = <IsolateTest>[
|
||||
expect(result.offset, isNull);
|
||||
expect(result.count, equals(2));
|
||||
expect(result.bytes, equals('AwAAAAAAAAACAAAAAAAAAA=='));
|
||||
Uint8List bytes = base64Decode(result.bytes!);
|
||||
final Uint8List bytes = base64Decode(result.bytes!);
|
||||
expect(bytes.buffer.asUint64List().toString(), equals('[3, 2]'));
|
||||
},
|
||||
|
||||
@@ -651,10 +726,18 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a Dart list.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getUint64List', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getUint64List',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = evalResult.id!;
|
||||
final result = await service.getObject(isolateId, objectId,
|
||||
offset: 2, count: 2) as Instance;
|
||||
final result = await service.getObject(
|
||||
isolateId,
|
||||
objectId,
|
||||
offset: 2,
|
||||
count: 2,
|
||||
) as Instance;
|
||||
expect(result.kind, InstanceKind.kUint64List);
|
||||
expect(result.json!['_vmType'], equals('TypedData'));
|
||||
expect(result.id, startsWith('objects/'));
|
||||
@@ -666,7 +749,7 @@ var tests = <IsolateTest>[
|
||||
expect(result.offset, equals(2));
|
||||
expect(result.count, equals(1));
|
||||
expect(result.bytes, equals('AQAAAAAAAAA='));
|
||||
Uint8List bytes = base64Decode(result.bytes!);
|
||||
final Uint8List bytes = base64Decode(result.bytes!);
|
||||
expect(bytes.buffer.asUint64List().toString(), equals('[1]'));
|
||||
},
|
||||
|
||||
@@ -676,10 +759,18 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a Dart list.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getUint64List', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getUint64List',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = evalResult.id!;
|
||||
final result = await service.getObject(isolateId, objectId,
|
||||
offset: 100, count: 2) as Instance;
|
||||
final result = await service.getObject(
|
||||
isolateId,
|
||||
objectId,
|
||||
offset: 100,
|
||||
count: 2,
|
||||
) as Instance;
|
||||
expect(result.kind, InstanceKind.kUint64List);
|
||||
expect(result.json!['_vmType'], equals('TypedData'));
|
||||
expect(result.id, startsWith('objects/'));
|
||||
@@ -724,7 +815,8 @@ var tests = <IsolateTest>[
|
||||
expect(result.size, isPositive);
|
||||
expect(result.length, 4);
|
||||
final fieldsMap = HashMap.fromEntries(
|
||||
result.fields!.map((f) => MapEntry(f.name, f.value)));
|
||||
result.fields!.map((f) => MapEntry(f.name, f.value)),
|
||||
);
|
||||
expect(fieldsMap.keys.length, result.length);
|
||||
// [BoundField]s have fields with type [dynamic], and such fields have
|
||||
// broken [toJson()] in the past. So, we make the following call just to
|
||||
@@ -814,7 +906,11 @@ var tests = <IsolateTest>[
|
||||
final isolateId = isolateRef.id!;
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = evalResult.id!;
|
||||
final result = await service.getObject(isolateId, objectId) as Instance;
|
||||
expect(result.kind, InstanceKind.kPlainInstance);
|
||||
@@ -826,16 +922,21 @@ var tests = <IsolateTest>[
|
||||
expect(result.size, isPositive);
|
||||
expect(result.length, 3);
|
||||
final fieldsMap = HashMap.fromEntries(
|
||||
result.fields!.map((f) => MapEntry(f.name, f.value)));
|
||||
result.fields!.map((f) => MapEntry(f.name, f.value)),
|
||||
);
|
||||
expect(fieldsMap.keys.length, result.length);
|
||||
expect(fieldsMap.containsKey('dummyList'), true);
|
||||
expect((fieldsMap['dummyList'] as InstanceRef).kind, InstanceKind.kList);
|
||||
expect(fieldsMap.containsKey('dummyLateVarWithInit'), true);
|
||||
expect((fieldsMap['dummyLateVarWithInit'] as Sentinel).kind,
|
||||
SentinelKind.kNotInitialized);
|
||||
expect(
|
||||
(fieldsMap['dummyLateVarWithInit'] as Sentinel).kind,
|
||||
SentinelKind.kNotInitialized,
|
||||
);
|
||||
expect(fieldsMap.containsKey('dummyLateVar'), true);
|
||||
expect((fieldsMap['dummyLateVar'] as Sentinel).kind,
|
||||
SentinelKind.kNotInitialized);
|
||||
expect(
|
||||
(fieldsMap['dummyLateVar'] as Sentinel).kind,
|
||||
SentinelKind.kNotInitialized,
|
||||
);
|
||||
},
|
||||
|
||||
// An abstract base mixin class.
|
||||
@@ -844,7 +945,11 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Use invoke to get a reference to an instance of [_DummyClass].
|
||||
final invokeResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final derivedClass =
|
||||
await service.getObject(isolateId, invokeResult.classRef!.id!) as Class;
|
||||
final baseClassRef = derivedClass.superClass!;
|
||||
@@ -884,7 +989,11 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Use invoke to get a reference to an instance of [_DummyClass].
|
||||
final invokeResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final result =
|
||||
await service.getObject(isolateId, invokeResult.classRef!.id!) as Class;
|
||||
expect(result.id, startsWith('classes/'));
|
||||
@@ -921,8 +1030,11 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Use invoke to get a reference to an instance of [_DummyGenericSubClass].
|
||||
final invokeResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyGenericSubClass', [])
|
||||
as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyGenericSubClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final result =
|
||||
await service.getObject(isolateId, invokeResult.classRef!.id!) as Class;
|
||||
expect(result.id, startsWith('classes/'));
|
||||
@@ -997,8 +1109,11 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Use invoke to get a reference to an instance of [_DummyInterfaceClass].
|
||||
final invokeResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyInterfaceClass', [])
|
||||
as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyInterfaceClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final derivedClass =
|
||||
await service.getObject(isolateId, invokeResult.classRef!.id!) as Class;
|
||||
final baseClassRef = derivedClass.superClass!;
|
||||
@@ -1038,8 +1153,11 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Use invoke to get a reference to an instance of [_DummyInterfaceClass].
|
||||
final invokeResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyInterfaceClass', [])
|
||||
as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyInterfaceClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final result =
|
||||
await service.getObject(isolateId, invokeResult.classRef!.id!) as Class;
|
||||
expect(result.id, startsWith('classes/'));
|
||||
@@ -1076,16 +1194,23 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Use invoke to get a reference to an instance of [_DummyClassWithMixins].
|
||||
final dummyClassInstanceRef = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClassWithMixins', [])
|
||||
as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClassWithMixins',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final dummyClass = await service.getObject(
|
||||
isolateId, dummyClassInstanceRef.classRef!.id!) as Class;
|
||||
isolateId,
|
||||
dummyClassInstanceRef.classRef!.id!,
|
||||
) as Class;
|
||||
|
||||
final dummyClassWithTwoMixinsApplied =
|
||||
await service.getObject(isolateId, dummyClass.superClass!.id!) as Class;
|
||||
expect(dummyClassWithTwoMixinsApplied.id, startsWith('classes/'));
|
||||
expect(dummyClassWithTwoMixinsApplied.name,
|
||||
'__DummyClassWithMixins&Object&_DummyBaseMixin&_DummyMixin');
|
||||
expect(
|
||||
dummyClassWithTwoMixinsApplied.name,
|
||||
'__DummyClassWithMixins&Object&_DummyBaseMixin&_DummyMixin',
|
||||
);
|
||||
expect(dummyClassWithTwoMixinsApplied.isAbstract, true);
|
||||
expect(dummyClassWithTwoMixinsApplied.isConst, true);
|
||||
expect(dummyClassWithTwoMixinsApplied.isSealed, false);
|
||||
@@ -1105,23 +1230,31 @@ var tests = <IsolateTest>[
|
||||
final dummyClassWithTwoMixinsAppliedJson =
|
||||
dummyClassWithTwoMixinsApplied.json!;
|
||||
expect(
|
||||
dummyClassWithTwoMixinsAppliedJson['_vmName'],
|
||||
startsWith(
|
||||
'__DummyClassWithMixins&Object&_DummyBaseMixin&_DummyMixin@'));
|
||||
dummyClassWithTwoMixinsAppliedJson['_vmName'],
|
||||
startsWith(
|
||||
'__DummyClassWithMixins&Object&_DummyBaseMixin&_DummyMixin@',
|
||||
),
|
||||
);
|
||||
expect(dummyClassWithTwoMixinsAppliedJson['_finalized'], true);
|
||||
expect(dummyClassWithTwoMixinsAppliedJson['_implemented'], false);
|
||||
expect(dummyClassWithTwoMixinsAppliedJson['_patch'], false);
|
||||
|
||||
expect(dummyClassWithTwoMixinsApplied.interfaces!.length, 1);
|
||||
expect(dummyClassWithTwoMixinsApplied.interfaces!.first,
|
||||
dummyClassWithTwoMixinsApplied.mixin!);
|
||||
expect(
|
||||
dummyClassWithTwoMixinsApplied.interfaces!.first,
|
||||
dummyClassWithTwoMixinsApplied.mixin!,
|
||||
);
|
||||
final dummyMixinType = await service.getObject(
|
||||
isolateId, dummyClassWithTwoMixinsApplied.mixin!.id!) as Instance;
|
||||
isolateId,
|
||||
dummyClassWithTwoMixinsApplied.mixin!.id!,
|
||||
) as Instance;
|
||||
expect(dummyMixinType.kind, InstanceKind.kType);
|
||||
expect(dummyMixinType.id, startsWith('classes/'));
|
||||
expect(dummyMixinType.name, '_DummyMixin');
|
||||
final dummyMixinClass = await service.getObject(
|
||||
isolateId, dummyMixinType.typeClass!.id!) as Class;
|
||||
isolateId,
|
||||
dummyMixinType.typeClass!.id!,
|
||||
) as Class;
|
||||
expect(dummyMixinClass.id, startsWith('classes/'));
|
||||
expect(dummyMixinClass.name, '_DummyMixin');
|
||||
expect(dummyMixinClass.isAbstract, true);
|
||||
@@ -1149,10 +1282,14 @@ var tests = <IsolateTest>[
|
||||
expect(dummyMixinClassJson['_patch'], false);
|
||||
|
||||
final dummyClassWithOneMixinApplied = await service.getObject(
|
||||
isolateId, dummyClassWithTwoMixinsApplied.superClass!.id!) as Class;
|
||||
isolateId,
|
||||
dummyClassWithTwoMixinsApplied.superClass!.id!,
|
||||
) as Class;
|
||||
expect(dummyClassWithOneMixinApplied.id, startsWith('classes/'));
|
||||
expect(dummyClassWithOneMixinApplied.name,
|
||||
'__DummyClassWithMixins&Object&_DummyBaseMixin');
|
||||
expect(
|
||||
dummyClassWithOneMixinApplied.name,
|
||||
'__DummyClassWithMixins&Object&_DummyBaseMixin',
|
||||
);
|
||||
expect(dummyClassWithOneMixinApplied.isAbstract, true);
|
||||
expect(dummyClassWithOneMixinApplied.isConst, true);
|
||||
expect(dummyClassWithOneMixinApplied.isSealed, false);
|
||||
@@ -1171,22 +1308,30 @@ var tests = <IsolateTest>[
|
||||
expect(dummyClassWithOneMixinApplied.subclasses!.length, 1);
|
||||
final dummyClassWithOneMixinAppliedJson =
|
||||
dummyClassWithOneMixinApplied.json!;
|
||||
expect(dummyClassWithOneMixinAppliedJson['_vmName'],
|
||||
startsWith('__DummyClassWithMixins&Object&_DummyBaseMixin@'));
|
||||
expect(
|
||||
dummyClassWithOneMixinAppliedJson['_vmName'],
|
||||
startsWith('__DummyClassWithMixins&Object&_DummyBaseMixin@'),
|
||||
);
|
||||
expect(dummyClassWithOneMixinAppliedJson['_finalized'], true);
|
||||
expect(dummyClassWithOneMixinAppliedJson['_implemented'], false);
|
||||
expect(dummyClassWithOneMixinAppliedJson['_patch'], false);
|
||||
|
||||
expect(dummyClassWithOneMixinApplied.interfaces!.length, 1);
|
||||
expect(dummyClassWithOneMixinApplied.interfaces!.first,
|
||||
dummyClassWithOneMixinApplied.mixin!);
|
||||
expect(
|
||||
dummyClassWithOneMixinApplied.interfaces!.first,
|
||||
dummyClassWithOneMixinApplied.mixin!,
|
||||
);
|
||||
final dummyBaseMixinType = await service.getObject(
|
||||
isolateId, dummyClassWithOneMixinApplied.mixin!.id!) as Instance;
|
||||
isolateId,
|
||||
dummyClassWithOneMixinApplied.mixin!.id!,
|
||||
) as Instance;
|
||||
expect(dummyBaseMixinType.kind, InstanceKind.kType);
|
||||
expect(dummyBaseMixinType.id, startsWith('classes/'));
|
||||
expect(dummyBaseMixinType.name, '_DummyBaseMixin');
|
||||
final dummyBaseMixinClass = await service.getObject(
|
||||
isolateId, dummyBaseMixinType.typeClass!.id!) as Class;
|
||||
isolateId,
|
||||
dummyBaseMixinType.typeClass!.id!,
|
||||
) as Class;
|
||||
expect(dummyBaseMixinClass.id, startsWith('classes/'));
|
||||
expect(dummyBaseMixinClass.name, '_DummyBaseMixin');
|
||||
expect(dummyBaseMixinClass.isAbstract, true);
|
||||
@@ -1233,7 +1378,11 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a class id.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = '${evalResult.classRef!.id!}/types/0';
|
||||
final result = await service.getObject(isolateId, objectId) as Instance;
|
||||
expect(result.kind, InstanceKind.kType);
|
||||
@@ -1249,7 +1398,11 @@ var tests = <IsolateTest>[
|
||||
final isolateId = isolateRef.id!;
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = '${evalResult.classRef!.id!}/types/9999999';
|
||||
try {
|
||||
await service.getObject(isolateId, objectId);
|
||||
@@ -1267,7 +1420,11 @@ var tests = <IsolateTest>[
|
||||
// Call [invoke] to get an [InstanceRef], and then use the ID of its
|
||||
// [classRef] field to build a function ID.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = '${evalResult.classRef!.id!}/functions/dummyFunction';
|
||||
final result = await service.getObject(isolateId, objectId) as Func;
|
||||
expect(result.id, equals(objectId));
|
||||
@@ -1305,7 +1462,11 @@ var tests = <IsolateTest>[
|
||||
// Call [invoke] to get an [InstanceRef], and then use the ID of its
|
||||
// [classRef] field to build a function ID.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId =
|
||||
'${evalResult.classRef!.id!}/functions/dummyGenericFunction';
|
||||
final result = await service.getObject(isolateId, objectId) as Func;
|
||||
@@ -1345,7 +1506,11 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a class id.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = evalResult.classRef!.id!;
|
||||
final result = await service.getObject(isolateId, objectId) as Class;
|
||||
expect(result.id, startsWith('classes/'));
|
||||
@@ -1398,7 +1563,11 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a class id.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = '${evalResult.classRef!.id!}/functions/invalid';
|
||||
try {
|
||||
await service.getObject(isolateId, objectId);
|
||||
@@ -1415,7 +1584,11 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a class id.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = '${evalResult.classRef!.id!}/fields/dummyVar';
|
||||
final result = await service.getObject(isolateId, objectId) as Field;
|
||||
expect(result.id, equals(objectId));
|
||||
@@ -1438,7 +1611,11 @@ var tests = <IsolateTest>[
|
||||
// Call [invoke] to get an [InstanceRef], and then use the ID of its
|
||||
// [classRef] field to build a function ID.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId =
|
||||
"${evalResult.classRef!.id!}/functions/get${Uri.encodeComponent(':')}dummyVarGetter";
|
||||
final result = await service.getObject(isolateId, objectId) as Func;
|
||||
@@ -1473,7 +1650,11 @@ var tests = <IsolateTest>[
|
||||
// Call [invoke] to get an [InstanceRef], and then use the ID of its
|
||||
// [classRef] field to build a function ID.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId =
|
||||
"${evalResult.classRef!.id!}/functions/set${Uri.encodeComponent(':')}dummyVarSetter";
|
||||
final result = await service.getObject(isolateId, objectId) as Func;
|
||||
@@ -1510,7 +1691,11 @@ var tests = <IsolateTest>[
|
||||
// Call [invoke] to get an [InstanceRef], and then use the ID of its
|
||||
// [classRef] field to build a function ID.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = '${evalResult.classRef!.id!}/field_inits/dummyVarWithInit';
|
||||
final result = await service.getObject(isolateId, objectId) as Func;
|
||||
expect(result.id, equals(objectId));
|
||||
@@ -1543,7 +1728,11 @@ var tests = <IsolateTest>[
|
||||
// Call [invoke] to get an [InstanceRef], and then use the ID of its
|
||||
// [classRef] field to build a function ID.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId =
|
||||
'${evalResult.classRef!.id!}/field_inits/dummyLateVarWithInit';
|
||||
final result = await service.getObject(isolateId, objectId) as Func;
|
||||
@@ -1576,7 +1765,11 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a class id.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = '${evalResult.classRef!.id!}/field_inits/dummyLateVar';
|
||||
try {
|
||||
await service.getObject(isolateId, objectId);
|
||||
@@ -1591,15 +1784,20 @@ var tests = <IsolateTest>[
|
||||
final isolateId = isolateRef.id!;
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
final flagList = await service.getFlagList();
|
||||
if (!flagList.flags!.any((flag) =>
|
||||
flag.name == 'use_field_guards' && flag.valueAsString == 'true')) {
|
||||
if (!flagList.flags!.any(
|
||||
(flag) => flag.name == 'use_field_guards' && flag.valueAsString == 'true',
|
||||
)) {
|
||||
// Skip the test if guards are not enabled.
|
||||
return;
|
||||
}
|
||||
|
||||
// Call eval to get a class id.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = '${evalResult.classRef!.id!}/fields/dummyList';
|
||||
final result = await service.getObject(isolateId, objectId) as Field;
|
||||
expect(result.id, equals(objectId));
|
||||
@@ -1620,7 +1818,11 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a class id.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = '${evalResult.classRef!.id!}/fields/mythicalField';
|
||||
try {
|
||||
await service.getObject(isolateId, objectId);
|
||||
@@ -1649,7 +1851,11 @@ var tests = <IsolateTest>[
|
||||
final isolate = await service.getIsolate(isolateId);
|
||||
// Call eval to get a class id.
|
||||
final evalResult = await service.invoke(
|
||||
isolateId, isolate.rootLib!.id!, 'getDummyClass', []) as InstanceRef;
|
||||
isolateId,
|
||||
isolate.rootLib!.id!,
|
||||
'getDummyClass',
|
||||
[],
|
||||
) as InstanceRef;
|
||||
final objectId = '${evalResult.classRef!.id!}/functions/dummyFunction';
|
||||
final funcResult = await service.getObject(isolateId, objectId) as Func;
|
||||
final result =
|
||||
@@ -1683,6 +1889,9 @@ var tests = <IsolateTest>[
|
||||
},
|
||||
];
|
||||
|
||||
main([args = const <String>[]]) async =>
|
||||
runIsolateTests(args, tests, 'get_object_rpc_test.dart',
|
||||
testeeBefore: warmup);
|
||||
void main([args = const <String>[]]) => runIsolateTests(
|
||||
args,
|
||||
tests,
|
||||
'get_object_rpc_test.dart',
|
||||
testeeBefore: warmup,
|
||||
);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user