Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: runtime/observatory/tests/service/local_variable_declaration_test.dart

Issue 2419013004: Add local variable declaration token position to service protocol (Closed)
Patch Set: test closure variables Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4 // VMOptions=--error_on_bad_type --error_on_bad_override --verbose_debug
5
6 import 'package:observatory/service_io.dart';
7 import 'package:unittest/unittest.dart';
8 import 'service_test_common.dart';
9 import 'test_helper.dart';
10 import 'dart:developer';
11
12 testParameters(int jjjj, int oooo, [int hhhh, int nnnn]) {
13 debugger();
14 }
15
16 testMain() {
17 int xxx, yyyy, zzzzz;
18 for (int i = 0; i < 1; i++) {
19 var foo = () {
20 };
21 debugger();
22 }
23 var bar = () {
24 print(xxx);
25 print(yyyy);
26 debugger();
rmacnak 2016/10/14 23:10:38 In Dart, a variable is not in scope during its ini
27 };
28 bar();
29 testParameters(0, 0);
30 }
31
32 var tests = [
33 hasStoppedAtBreakpoint,
34 stoppedInFunction('testMain'),
35 (Isolate isolate) async {
36 var stack = await isolate.getStack();
37 expect(stack.type, equals('Stack'));
38 expect(stack['frames'].length, greaterThanOrEqualTo(1));
39 // Grab the top frame.
40 Frame frame = stack['frames'][0];
41 // Grab the script.
42 Script script = frame.location.script;
43 await script.load();
44
45 // Ensure that the token at each declaration position is the name of the
46 // variable.
47 for (var variable in frame.variables) {
48 final int declarationTokenPos = variable['declarationTokenPos'];
49 final String name = variable['name'];
50 final String token = script.getToken(declarationTokenPos);
51 expect(name, token);
52 }
53 },
54 resumeIsolate,
55 hasStoppedAtBreakpoint,
56 // We have stopped in the anonymous closure assigned to bar. Verify that
57 // variables captured in the context have valid declaration positions.
58 (Isolate isolate) async {
59 var stack = await isolate.getStack();
60 expect(stack.type, equals('Stack'));
61 expect(stack['frames'].length, greaterThanOrEqualTo(1));
62 // Grab the top frame.
63 Frame frame = stack['frames'][0];
64 // Grab the script.
65 Script script = frame.location.script;
66 await script.load();
67 print(frame);
68 expect(frame.variables.length, greaterThanOrEqualTo(1));
69 for (var variable in frame.variables) {
70 final int declarationTokenPos = variable['declarationTokenPos'];
71 final String name = variable['name'];
72 final String token = script.getToken(declarationTokenPos);
73 expect(name, token);
74 }
75 },
76 resumeIsolate,
77 hasStoppedAtBreakpoint,
78 stoppedInFunction('testParameters'),
79 (Isolate isolate) async {
80 var stack = await isolate.getStack();
81 expect(stack.type, equals('Stack'));
82 expect(stack['frames'].length, greaterThanOrEqualTo(1));
83 // Grab the top frame.
84 Frame frame = stack['frames'][0];
85 // Grab the script.
86 Script script = frame.location.script;
87 await script.load();
88
89 // Ensure that the token at each declaration position is the name of the
90 // variable.
91 expect(frame.variables.length, greaterThanOrEqualTo(1));
92 for (var variable in frame.variables) {
93 final int declarationTokenPos = variable['declarationTokenPos'];
94 final String name = variable['name'];
95 final String token = script.getToken(declarationTokenPos);
96 expect(name, token);
97 }
98 }
99 ];
100
101 main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698