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

Side by Side Diff: dart/tests/try/poi/serialize_test.dart

Issue 388813002: Serialize scope information at point-of-interest. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Skip serialization test in browsers Created 6 years, 5 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 /// Test that poi.dart can serialize a scope.
6
7 library trydart.serialize_test;
8
9 import 'dart:io' show
10 Platform;
11
12 import 'dart:async' show
13 Future;
14
15 import 'dart:convert' show
16 JSON;
17
18 import 'package:try/poi/poi.dart' as poi;
19
20 import 'package:async_helper/async_helper.dart';
21
22 import 'package:expect/expect.dart';
23
24 import 'package:compiler/implementation/elements/elements.dart' show
25 Element;
26
27 import 'package:compiler/implementation/source_file_provider.dart' show
28 FormattingDiagnosticHandler;
29
30 Future testPoi() {
31 Uri script = Platform.script.resolve('data/interesting.dart');
32 FormattingDiagnosticHandler handler = new FormattingDiagnosticHandler();
33
34 int position = 241;
35 Future future = poi.runPoi(script, position, handler.provider, handler);
36 return future.then((Element element) {
37 Uri foundScript = element.compilationUnit.script.resourceUri;
38 Expect.stringEquals('$script', '$foundScript');
39 Expect.stringEquals('fisk', element.name);
40
41 Expect.stringEquals(
42 JSON.encode(expected),
43 JSON.encode(JSON.decode(poi.scopeInformation(element, position))));
44 });
45 }
46
47 void main() {
48 asyncTest(testPoi);
49 }
50
51 final expected = {
52 "name": "fisk",
53 "kind": "function",
54 "enclosing": {
55 "name": "Foo",
56 "kind": "class",
57 "members": [
58 {
59 "name": "fisk",
60 "kind": "function"
61 },
62 {
63 "name": "hest",
64 "kind": "function"
65 },
66 {
67 "name": "",
68 "kind": "generative_constructor"
69 }
70 ],
71 "enclosing": {
72 "name": "tests/try/poi/data/interesting.dart",
73 "kind": "library",
74 "members": [
75 {
76 "name": "main",
77 "kind": "function"
78 },
79 {
80 "name": "Foo",
81 "kind": "class"
82 }
83 ]
84 }
85 }
86 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698