| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 54 | 54 | 
| 55   Future future = poi.runPoi(script, position, handler.provider, handler); | 55   Future future = poi.runPoi(script, position, handler.provider, handler); | 
| 56   return future.then((Element element) { | 56   return future.then((Element element) { | 
| 57     Uri foundScript = element.compilationUnit.script.resourceUri; | 57     Uri foundScript = element.compilationUnit.script.resourceUri; | 
| 58     Expect.stringEquals('$script', '$foundScript'); | 58     Expect.stringEquals('$script', '$foundScript'); | 
| 59     Expect.stringEquals('instanceMethod2', element.name); | 59     Expect.stringEquals('instanceMethod2', element.name); | 
| 60 | 60 | 
| 61     String scope = poi.scopeInformation(element, position); | 61     String scope = poi.scopeInformation(element, position); | 
| 62     Expect.stringEquals( | 62     Expect.stringEquals( | 
| 63         JSON.encode(expectedSubclass), JSON.encode(JSON.decode(scope)), scope); | 63         JSON.encode(expectedSubclass), JSON.encode(JSON.decode(scope)), scope); | 
|  | 64 | 
|  | 65     return testAbstractField(handler); | 
| 64   }); | 66   }); | 
| 65 } | 67 } | 
| 66 | 68 | 
|  | 69 Future testAbstractField(FormattingDiagnosticHandler handler) { | 
|  | 70   int position = 321; | 
|  | 71 | 
|  | 72   Uri script = Platform.script.resolve('data/abstract_field.dart'); | 
|  | 73 | 
|  | 74   Future future = poi.runPoi(script, position, handler.provider, handler); | 
|  | 75   return future.then((Element element) { | 
|  | 76     Uri foundScript = element.compilationUnit.script.resourceUri; | 
|  | 77     Expect.stringEquals('$script', '$foundScript'); | 
|  | 78     Expect.stringEquals('method', element.name); | 
|  | 79 | 
|  | 80     String scope = poi.scopeInformation(element, position); | 
|  | 81     Expect.stringEquals( | 
|  | 82         JSON.encode(expectedAbstractField), JSON.encode(JSON.decode(scope)), | 
|  | 83         scope); | 
|  | 84   }); | 
|  | 85 } | 
|  | 86 | 
| 67 void main() { | 87 void main() { | 
| 68   asyncTest(testInteresting); | 88   asyncTest(testInteresting); | 
| 69 } | 89 } | 
| 70 | 90 | 
| 71 final expectedInteresting = { | 91 final expectedInteresting = { | 
| 72   "name": "fisk", | 92   "name": "fisk", | 
| 73   "kind": "function", | 93   "kind": "function", | 
| 74   "type": "() -> dynamic", | 94   "type": "() -> dynamic", | 
| 75   "enclosing": { | 95   "enclosing": { | 
| 76     "name": "Foo", | 96     "name": "Foo", | 
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 235               ], | 255               ], | 
| 236               "enclosing": object, | 256               "enclosing": object, | 
| 237             } | 257             } | 
| 238           } | 258           } | 
| 239         } | 259         } | 
| 240       } | 260       } | 
| 241     } | 261     } | 
| 242   } | 262   } | 
| 243 }; | 263 }; | 
| 244 | 264 | 
|  | 265 final expectedAbstractField = { | 
|  | 266   "name": "method", | 
|  | 267   "kind": "function", | 
|  | 268   "type": "() -> dynamic", | 
|  | 269   "enclosing": { | 
|  | 270     "name": "A", | 
|  | 271     "kind": "class side", | 
|  | 272     "members": [ | 
|  | 273       { | 
|  | 274         "kind": "generative_constructor", | 
|  | 275         "type": "() -> A" | 
|  | 276       } | 
|  | 277     ], | 
|  | 278     "enclosing": { | 
|  | 279       "name": "A", | 
|  | 280       "kind": "instance side", | 
|  | 281       "members": [ | 
|  | 282         { | 
|  | 283           "name": "foo", | 
|  | 284           "kind": "getter" | 
|  | 285         }, | 
|  | 286         { | 
|  | 287           "name": "foo", | 
|  | 288           "kind": "setter" | 
|  | 289         }, | 
|  | 290         { | 
|  | 291           "name": "method", | 
|  | 292           "kind": "function", | 
|  | 293           "type": "() -> dynamic" | 
|  | 294         } | 
|  | 295       ], | 
|  | 296       "enclosing": { | 
|  | 297         "name": "abstract_field", | 
|  | 298         "kind": "library", | 
|  | 299         "members": [ | 
|  | 300           { | 
|  | 301             "name": "A", | 
|  | 302             "kind": "class" | 
|  | 303           }, | 
|  | 304           { | 
|  | 305             "name": "bar", | 
|  | 306             "kind": "getter" | 
|  | 307           }, | 
|  | 308           { | 
|  | 309             "name": "bar", | 
|  | 310             "kind": "getter" | 
|  | 311           }, | 
|  | 312           { | 
|  | 313             "name": "main", | 
|  | 314             "kind": "function", | 
|  | 315             "type": "() -> dynamic" | 
|  | 316           } | 
|  | 317         ], | 
|  | 318         "enclosing": { | 
|  | 319           "kind": "imports", | 
|  | 320           "members": coreImports, | 
|  | 321           "enclosing": object | 
|  | 322         }, | 
|  | 323       }, | 
|  | 324     }, | 
|  | 325   }, | 
|  | 326 }; | 
|  | 327 | 
| 245 final coreImports = [ | 328 final coreImports = [ | 
| 246   { | 329   { | 
| 247     "name": "Deprecated", | 330     "name": "Deprecated", | 
| 248     "kind": "class" | 331     "kind": "class" | 
| 249   }, | 332   }, | 
| 250   { | 333   { | 
| 251     "name": "deprecated", | 334     "name": "deprecated", | 
| 252     "kind": "field", | 335     "kind": "field", | 
| 253     "type": "Deprecated" | 336     "type": "Deprecated" | 
| 254   }, | 337   }, | 
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 513       "name": "noSuchMethod", | 596       "name": "noSuchMethod", | 
| 514       "kind": "function", | 597       "kind": "function", | 
| 515       "type": "(Invocation) -> dynamic" | 598       "type": "(Invocation) -> dynamic" | 
| 516     }, | 599     }, | 
| 517     { | 600     { | 
| 518       "name": "runtimeType", | 601       "name": "runtimeType", | 
| 519       "kind": "getter" | 602       "kind": "getter" | 
| 520     } | 603     } | 
| 521   ] | 604   ] | 
| 522 }; | 605 }; | 
| OLD | NEW | 
|---|