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

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

Issue 839543002: Revert "Build Observatory with runtime" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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
OLDNEW
(Empty)
1 // Copyright (c) 2014, 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
5 library inbound_references_test;
6
7 import 'dart:async';
8 import 'package:observatory/service_io.dart';
9 import 'package:unittest/unittest.dart';
10 import 'test_helper.dart';
11
12 var cleanBlock, copyingBlock, fullBlock, fullBlockWithChain;
13
14 Function genCleanBlock() {
15 block(x) => x;
16 return block;
17 }
18
19 Function genCopyingBlock() {
20 final x = 'I could be copied into the block';
21 block() => x;
22 return block;
23 }
24
25 Function genFullBlock() {
26 var x = 42; // I must captured in a context.
27 block() => x;
28 x++;
29 return block;
30 }
31
32 Function genFullBlockWithChain() {
33 var x = 420; // I must captured in a context.
34 outerBlock() {
35 var y = 4200;
36 innerBlock() => x + y;
37 y++;
38 return innerBlock;
39 }
40 x++;
41 return outerBlock();
42 }
43
44 void script() {
45 cleanBlock = genCleanBlock();
46 copyingBlock = genCopyingBlock();
47 fullBlock = genFullBlock();
48 fullBlockWithChain = genFullBlockWithChain();
49 }
50
51 var tests = [
52
53 (Isolate isolate) =>
54 isolate.rootLib.load().then((Library lib) {
55 Field field = lib.variables.singleWhere((v) => v.name == 'cleanBlock');
56 return field.value.load().then((Instance block) {
57 expect(block.isClosure, isTrue);
58 expect(block.closureCtxt.isContext, isTrue);
59 expect(block.closureCtxt.length, equals(0));
60 return block.closureCtxt.load().then((Context ctxt) {
61 expect(ctxt.parentContext.isNull, isTrue);
62 });
63 });
64 }),
65
66 (Isolate isolate) =>
67 isolate.rootLib.load().then((Library lib) {
68 Field field = lib.variables.singleWhere((v) => v.name == 'copyingBlock');
69 return field.value.load().then((Instance block) {
70 expect(block.isClosure, isTrue);
71 expect(block.closureCtxt.isContext, isTrue);
72 expect(block.closureCtxt.length, equals(1));
73 return block.closureCtxt.load().then((Context ctxt) {
74 expect(ctxt.variables.single['value'].isString, isTrue);
75 expect(ctxt.variables.single['value'].valueAsString, equals('I could be copied into the block'));
76 expect(block.closureCtxt.parentContext.isNull, isTrue);
77 });
78 });
79 }),
80
81 (Isolate isolate) =>
82 isolate.rootLib.load().then((Library lib) {
83 Field field = lib.variables.singleWhere((v) => v.name == 'fullBlock');
84 return field.value.load().then((Instance block) {
85 expect(block.isClosure, isTrue);
86 expect(block.closureCtxt.isContext, isTrue);
87 expect(block.closureCtxt.length, equals(1));
88 return block.closureCtxt.load().then((ctxt) {
89 expect(ctxt.variables.single['value'].isInt, isTrue);
90 expect(ctxt.variables.single['value'].valueAsString, equals('43'));
91 expect(ctxt.parentContext.isNull, isTrue);
92 });
93 });
94 }),
95
96 (Isolate isolate) =>
97 isolate.rootLib.load().then((Library lib) {
98 Field field = lib.variables.singleWhere((v) => v.name == 'fullBlockWithChain ');
99 return field.value.load().then((Instance block) {
100 expect(block.isClosure, isTrue);
101 expect(block.closureCtxt.isContext, isTrue);
102 expect(block.closureCtxt.length, equals(1));
103 return block.closureCtxt.load().then((Context ctxt) {
104 expect(ctxt.variables.single['value'].isInt, isTrue);
105 expect(ctxt.variables.single['value'].valueAsString, equals('4201'));
106 expect(ctxt.parentContext.isContext, isTrue);
107 expect(ctxt.parentContext.length, equals(1));
108 return ctxt.parentContext.load().then((Context outerCtxt) {
109 expect(outerCtxt.variables.single['value'].isInt, isTrue);
110 expect(outerCtxt.variables.single['value'].valueAsString, equals('421' ));
111 expect(outerCtxt.parentContext.isNull, isTrue);
112 });
113 });
114 });
115 }),
116
117 ];
118
119 main(args) => runIsolateTests(args, tests, testeeBefore: script);
OLDNEW
« no previous file with comments | « runtime/observatory/test/classes_test.dart ('k') | runtime/observatory/test/dominator_tree_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698