Files
sdk/runtime/observatory/tests/service/local_variable_declaration_test.dart
T
Ben Konyi b61efcd3c4 [ VM / Service ] Started cleaning up tests for the service protocol.
Mostly focused on app_jitk tests in this CL, but updated issue numbers
and statuses where appropriate.

Change-Id: I6b57d0a3091ad10ddd143c5b420f6b2121e9cc73
Reviewed-on: https://dart-review.googlesource.com/c/88128
Commit-Queue: Ben Konyi <bkonyi@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-12-28 20:53:39 +00:00

113 lines
3.6 KiB
Dart

// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// VMOptions=--verbose_debug
import 'package:observatory/service_io.dart';
import 'package:unittest/unittest.dart';
import 'service_test_common.dart';
import 'test_helper.dart';
import 'dart:developer';
testParameters(int jjjj, int oooo, [int hhhh, int nnnn]) {
debugger();
}
testMain() {
int xxx, yyyy, zzzzz;
for (int i = 0; i < 1; i++) {
var foo = () {};
debugger();
}
var bar = () {
print(xxx);
print(yyyy);
debugger();
};
bar();
testParameters(0, 0);
}
var tests = <IsolateTest>[
hasStoppedAtBreakpoint,
stoppedInFunction('testMain'),
(Isolate isolate) async {
var stack = await isolate.getStack();
expect(stack.type, equals('Stack'));
expect(stack['frames'].length, greaterThanOrEqualTo(1));
// Grab the top frame.
Frame frame = stack['frames'][0];
// Grab the script.
Script script = frame.location.script;
await script.load();
// Ensure that the token at each declaration position is the name of the
// variable.
for (var variable in frame.variables) {
final int declarationTokenPos = variable['declarationTokenPos'];
final String name = variable['name'];
final String token = script.getToken(declarationTokenPos);
// When running from an appjit snapshot, sources aren't available so the returned token will
// be null.
if (token != null) {
expect(name, token);
}
}
},
resumeIsolate,
hasStoppedAtBreakpoint,
// We have stopped in the anonymous closure assigned to bar. Verify that
// variables captured in the context have valid declaration positions.
(Isolate isolate) async {
var stack = await isolate.getStack();
expect(stack.type, equals('Stack'));
expect(stack['frames'].length, greaterThanOrEqualTo(1));
// Grab the top frame.
Frame frame = stack['frames'][0];
// Grab the script.
Script script = frame.location.script;
await script.load();
print(frame);
expect(frame.variables.length, greaterThanOrEqualTo(1));
for (var variable in frame.variables) {
final int declarationTokenPos = variable['declarationTokenPos'];
final String name = variable['name'];
final String token = script.getToken(declarationTokenPos);
// When running from an appjit snapshot, sources aren't available so the returned token will
// be null.
if (token != null) {
expect(name, token);
}
}
},
resumeIsolate,
hasStoppedAtBreakpoint,
stoppedInFunction('testParameters'),
(Isolate isolate) async {
var stack = await isolate.getStack();
expect(stack.type, equals('Stack'));
expect(stack['frames'].length, greaterThanOrEqualTo(1));
// Grab the top frame.
Frame frame = stack['frames'][0];
// Grab the script.
Script script = frame.location.script;
await script.load();
// Ensure that the token at each declaration position is the name of the
// variable.
expect(frame.variables.length, greaterThanOrEqualTo(1));
for (var variable in frame.variables) {
final int declarationTokenPos = variable['declarationTokenPos'];
final String name = variable['name'];
final String token = script.getToken(declarationTokenPos);
// When running from an appjit snapshot, sources aren't available so the returned token will
// be null.
if (token != null) {
expect(name, token);
}
}
}
];
main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain);