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

Side by Side Diff: runtime/observatory/test/eval_test.dart

Issue 1071363002: Relocate service library tests and hookup a working status file (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/observatory/test/echo_test.dart ('k') | runtime/observatory/test/functions_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, 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=--compile-all --error_on_bad_type --error_on_bad_override --checked
5
6 import 'package:observatory/service_io.dart';
7 import 'package:unittest/unittest.dart';
8 import 'test_helper.dart';
9 import 'dart:async';
10
11 int globalVar = 100;
12
13 class MyClass {
14 static int staticVar = 1000;
15
16 static void printValue(int value) {
17 print(value); // line 16
18 }
19 }
20
21 void testFunction() {
22 int i = 0;
23 while (true) {
24 if (++i % 100000000 == 0) {
25 MyClass.printValue(10000);
26 }
27 }
28 }
29
30 var tests = [
31
32 // Go to breakpoint at line 16.
33 (Isolate isolate) {
34 return isolate.rootLib.load().then((_) {
35 // Set up a listener to wait for breakpoint events.
36 Completer completer = new Completer();
37 isolate.vm.events.stream.listen((ServiceEvent event) {
38 if (event.eventType == ServiceEvent.kPauseBreakpoint) {
39 print('Breakpoint reached');
40 completer.complete();
41 }
42 });
43
44 // Add the breakpoint.
45 var script = isolate.rootLib.scripts[0];
46 var line = 16;
47 return isolate.addBreakpoint(script, line).then((ServiceObject bpt) {
48 return completer.future; // Wait for breakpoint reached.
49 });
50 });
51 },
52
53 // Evaluate against library, class, and instance.
54 (Isolate isolate) {
55 return isolate.getStack().then((ServiceMap stack) {
56 // Make sure we are in the right place.
57 expect(stack.type, equals('Stack'));
58 expect(stack['frames'].length, greaterThanOrEqualTo(2));
59 expect(stack['frames'][0]['function'].name, equals('printValue'));
60 expect(stack['frames'][0]['function'].dartOwner.name, equals('MyClass'));
61
62 var lib = isolate.rootLib;
63 var cls = stack['frames'][0]['function'].dartOwner;
64 var instance = stack['frames'][0]['vars'][0]['value'];
65
66 List evals = [];
67 evals.add(isolate.eval(lib, 'globalVar + 5').then((result) {
68 print(result);
69 expect(result.valueAsString, equals('105'));
70 }));
71 evals.add(isolate.eval(lib, 'globalVar + staticVar + 5').then((result) {
72 expect(result.type, equals('Error'));
73 }));
74 evals.add(isolate.eval(cls, 'globalVar + staticVar + 5').then((result) {
75 print(result);
76 expect(result.valueAsString, equals('1105'));
77 }));
78 evals.add(isolate.eval(cls, 'this + 5').then((result) {
79 expect(result.type, equals('Error'));
80 }));
81 evals.add(isolate.eval(instance, 'this + 5').then((result) {
82 print(result);
83 expect(result.valueAsString, equals('10005'));
84 }));
85 evals.add(isolate.eval(instance, 'this + frog').then((result) {
86 expect(result.type, equals('Error'));
87 }));
88 return Future.wait(evals);
89 });
90 },
91
92 ];
93
94 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction);
OLDNEW
« no previous file with comments | « runtime/observatory/test/echo_test.dart ('k') | runtime/observatory/test/functions_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698