| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /// Test that poi.dart can serialize a scope. | 5 /// Test that poi.dart can serialize a scope. |
| 6 | 6 |
| 7 library trydart.serialize_test; | 7 library trydart.serialize_test; |
| 8 | 8 |
| 9 import 'dart:io' show | 9 import 'dart:io' show |
| 10 Platform; | 10 Platform; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 FormattingDiagnosticHandler handler = new FormattingDiagnosticHandler(); | 32 FormattingDiagnosticHandler handler = new FormattingDiagnosticHandler(); |
| 33 | 33 |
| 34 int position = 263; | 34 int position = 263; |
| 35 | 35 |
| 36 Future future = poi.runPoi(script, position, handler.provider, handler); | 36 Future future = poi.runPoi(script, position, handler.provider, handler); |
| 37 return future.then((Element element) { | 37 return future.then((Element element) { |
| 38 Uri foundScript = element.compilationUnit.script.resourceUri; | 38 Uri foundScript = element.compilationUnit.script.resourceUri; |
| 39 Expect.stringEquals('$script', '$foundScript'); | 39 Expect.stringEquals('$script', '$foundScript'); |
| 40 Expect.stringEquals('fisk', element.name); | 40 Expect.stringEquals('fisk', element.name); |
| 41 | 41 |
| 42 String scope = poi.scopeInformation(element, position); |
| 42 Expect.stringEquals( | 43 Expect.stringEquals( |
| 43 JSON.encode(expected), | 44 JSON.encode(expected), JSON.encode(JSON.decode(scope)), scope); |
| 44 JSON.encode(JSON.decode(poi.scopeInformation(element, position)))); | |
| 45 }); | 45 }); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void main() { | 48 void main() { |
| 49 asyncTest(testPoi); | 49 asyncTest(testPoi); |
| 50 } | 50 } |
| 51 | 51 |
| 52 final expected = { | 52 final expected = { |
| 53 "name": "fisk", | 53 "name": "fisk", |
| 54 "kind": "function", | 54 "kind": "function", |
| 55 "type": "() -> dynamic", |
| 55 "enclosing": { | 56 "enclosing": { |
| 56 "name": "Foo", | 57 "name": "Foo", |
| 57 "kind": "class", | 58 "kind": "class", |
| 58 "members": [ | 59 "members": [ |
| 59 { | 60 { |
| 60 "name": "fisk", | 61 "name": "fisk", |
| 61 "kind": "function" | 62 "kind": "function", |
| 63 "type": "() -> dynamic" |
| 62 }, | 64 }, |
| 63 { | 65 { |
| 64 "name": "hest", | 66 "name": "hest", |
| 65 "kind": "function" | 67 "kind": "function", |
| 68 "type": "() -> dynamic" |
| 66 }, | 69 }, |
| 67 { | 70 { |
| 68 "name": "", | 71 "name": "", |
| 69 "kind": "generative_constructor" | 72 "kind": "generative_constructor", |
| 73 "type": "() -> Foo" |
| 70 } | 74 } |
| 71 ], | 75 ], |
| 72 "enclosing": { | 76 "enclosing": { |
| 73 "name": "interesting", | 77 "name": "interesting", |
| 74 "kind": "library", | 78 "kind": "library", |
| 75 "members": [ | 79 "members": [ |
| 76 { | 80 { |
| 77 "name": "main", | 81 "name": "main", |
| 78 "kind": "function" | 82 "kind": "function", |
| 83 "type": "() -> dynamic" |
| 79 }, | 84 }, |
| 80 { | 85 { |
| 81 "name": "Foo", | 86 "name": "Foo", |
| 82 "kind": "class" | 87 "kind": "class" |
| 83 } | 88 } |
| 84 ] | 89 ] |
| 85 } | 90 } |
| 86 } | 91 } |
| 87 }; | 92 }; |
| OLD | NEW |