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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: dart/tests/try/poi/serialize_test.dart
diff --git a/dart/tests/try/poi/serialize_test.dart b/dart/tests/try/poi/serialize_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b5af1db566d5664881e4a39a0474c85b0a68f06d
--- /dev/null
+++ b/dart/tests/try/poi/serialize_test.dart
@@ -0,0 +1,86 @@
+// Copyright (c) 2014, 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.
+
+/// Test that poi.dart can serialize a scope.
+
+library trydart.serialize_test;
+
+import 'dart:io' show
+ Platform;
+
+import 'dart:async' show
+ Future;
+
+import 'dart:convert' show
+ JSON;
+
+import 'package:try/poi/poi.dart' as poi;
+
+import 'package:async_helper/async_helper.dart';
+
+import 'package:expect/expect.dart';
+
+import 'package:compiler/implementation/elements/elements.dart' show
+ Element;
+
+import 'package:compiler/implementation/source_file_provider.dart' show
+ FormattingDiagnosticHandler;
+
+Future testPoi() {
+ Uri script = Platform.script.resolve('data/interesting.dart');
+ FormattingDiagnosticHandler handler = new FormattingDiagnosticHandler();
+
+ int position = 241;
+ Future future = poi.runPoi(script, position, handler.provider, handler);
+ return future.then((Element element) {
+ Uri foundScript = element.compilationUnit.script.resourceUri;
+ Expect.stringEquals('$script', '$foundScript');
+ Expect.stringEquals('fisk', element.name);
+
+ Expect.stringEquals(
+ JSON.encode(expected),
+ JSON.encode(JSON.decode(poi.scopeInformation(element, position))));
+ });
+}
+
+void main() {
+ asyncTest(testPoi);
+}
+
+final expected = {
+ "name": "fisk",
+ "kind": "function",
+ "enclosing": {
+ "name": "Foo",
+ "kind": "class",
+ "members": [
+ {
+ "name": "fisk",
+ "kind": "function"
+ },
+ {
+ "name": "hest",
+ "kind": "function"
+ },
+ {
+ "name": "",
+ "kind": "generative_constructor"
+ }
+ ],
+ "enclosing": {
+ "name": "tests/try/poi/data/interesting.dart",
+ "kind": "library",
+ "members": [
+ {
+ "name": "main",
+ "kind": "function"
+ },
+ {
+ "name": "Foo",
+ "kind": "class"
+ }
+ ]
+ }
+ }
+};

Powered by Google App Engine
This is Rietveld 408576698