| 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 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 import 'package:expect/expect.dart'; | 22 import 'package:expect/expect.dart'; |
| 23 | 23 |
| 24 import 'package:compiler/src/elements/elements.dart' show | 24 import 'package:compiler/src/elements/elements.dart' show |
| 25 Element; | 25 Element; |
| 26 | 26 |
| 27 import 'package:compiler/src/source_file_provider.dart' show | 27 import 'package:compiler/src/source_file_provider.dart' show |
| 28 FormattingDiagnosticHandler; | 28 FormattingDiagnosticHandler; |
| 29 | 29 |
| 30 Future testInteresting() { | 30 Future testInteresting() { |
| 31 poi.cachedCompiler = null; |
| 31 Uri script = Platform.script.resolve('data/interesting.dart'); | 32 Uri script = Platform.script.resolve('data/interesting.dart'); |
| 32 FormattingDiagnosticHandler handler = new FormattingDiagnosticHandler(); | 33 FormattingDiagnosticHandler handler = new FormattingDiagnosticHandler(); |
| 33 | 34 |
| 34 int position = 263; | 35 int position = 263; |
| 35 | 36 |
| 36 Future future = poi.runPoi(script, position, handler.provider, handler); | 37 Future future = poi.runPoi(script, position, handler.provider, handler); |
| 37 return future.then((Element element) { | 38 return future.then((Element element) { |
| 38 Uri foundScript = element.compilationUnit.script.resourceUri; | 39 Uri foundScript = element.compilationUnit.script.resourceUri; |
| 39 Expect.stringEquals('$script', '$foundScript'); | 40 Expect.stringEquals('$script', '$foundScript'); |
| 40 Expect.stringEquals('fisk', element.name); | 41 Expect.stringEquals('fisk', element.name); |
| 41 | 42 |
| 42 String scope = poi.scopeInformation(element, position); | 43 String scope = poi.scopeInformation(element, position); |
| 43 Expect.stringEquals( | 44 Expect.stringEquals( |
| 44 JSON.encode(expectedInteresting), JSON.encode(JSON.decode(scope)), | 45 JSON.encode(expectedInteresting), JSON.encode(JSON.decode(scope)), |
| 45 scope); | 46 scope); |
| 46 return testSubclass(handler); | 47 return testSubclass(handler); |
| 47 }); | 48 }); |
| 48 } | 49 } |
| 49 | 50 |
| 50 Future testSubclass(FormattingDiagnosticHandler handler) { | 51 Future testSubclass(FormattingDiagnosticHandler handler) { |
| 52 poi.cachedCompiler = null; |
| 51 int position = 506; | 53 int position = 506; |
| 52 | 54 |
| 53 Uri script = Platform.script.resolve('data/subclass.dart'); | 55 Uri script = Platform.script.resolve('data/subclass.dart'); |
| 54 | 56 |
| 55 Future future = poi.runPoi(script, position, handler.provider, handler); | 57 Future future = poi.runPoi(script, position, handler.provider, handler); |
| 56 return future.then((Element element) { | 58 return future.then((Element element) { |
| 57 Uri foundScript = element.compilationUnit.script.resourceUri; | 59 Uri foundScript = element.compilationUnit.script.resourceUri; |
| 58 Expect.stringEquals('$script', '$foundScript'); | 60 Expect.stringEquals('$script', '$foundScript'); |
| 59 Expect.stringEquals('instanceMethod2', element.name); | 61 Expect.stringEquals('instanceMethod2', element.name); |
| 60 | 62 |
| 61 String scope = poi.scopeInformation(element, position); | 63 String scope = poi.scopeInformation(element, position); |
| 62 Expect.stringEquals( | 64 Expect.stringEquals( |
| 63 JSON.encode(expectedSubclass), JSON.encode(JSON.decode(scope)), scope); | 65 JSON.encode(expectedSubclass), JSON.encode(JSON.decode(scope)), scope); |
| 64 | 66 |
| 65 return testAbstractField(handler); | 67 return testAbstractField(handler); |
| 66 }); | 68 }); |
| 67 } | 69 } |
| 68 | 70 |
| 69 Future testAbstractField(FormattingDiagnosticHandler handler) { | 71 Future testAbstractField(FormattingDiagnosticHandler handler) { |
| 72 poi.cachedCompiler = null; |
| 70 int position = 321; | 73 int position = 321; |
| 71 | 74 |
| 72 Uri script = Platform.script.resolve('data/abstract_field.dart'); | 75 Uri script = Platform.script.resolve('data/abstract_field.dart'); |
| 73 | 76 |
| 74 Future future = poi.runPoi(script, position, handler.provider, handler); | 77 Future future = poi.runPoi(script, position, handler.provider, handler); |
| 75 return future.then((Element element) { | 78 return future.then((Element element) { |
| 76 Uri foundScript = element.compilationUnit.script.resourceUri; | 79 Uri foundScript = element.compilationUnit.script.resourceUri; |
| 77 Expect.stringEquals('$script', '$foundScript'); | 80 Expect.stringEquals('$script', '$foundScript'); |
| 78 Expect.stringEquals('method', element.name); | 81 Expect.stringEquals('method', element.name); |
| 79 | 82 |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 "name": "noSuchMethod", | 603 "name": "noSuchMethod", |
| 601 "kind": "function", | 604 "kind": "function", |
| 602 "type": "(Invocation) -> dynamic" | 605 "type": "(Invocation) -> dynamic" |
| 603 }, | 606 }, |
| 604 { | 607 { |
| 605 "name": "runtimeType", | 608 "name": "runtimeType", |
| 606 "kind": "getter" | 609 "kind": "getter" |
| 607 } | 610 } |
| 608 ] | 611 ] |
| 609 }; | 612 }; |
| OLD | NEW |