Chromium Code Reviews| Index: tests/standalone/debugger/debug_lib.dart |
| =================================================================== |
| --- tests/standalone/debugger/debug_lib.dart (revision 43843) |
| +++ tests/standalone/debugger/debug_lib.dart (working copy) |
| @@ -299,8 +299,9 @@ |
| class LocalsMatcher extends Command { |
| Map locals = {}; |
| + int frame_index; |
| - LocalsMatcher(this.locals) { |
| + LocalsMatcher(this.locals, this.frame_index) { |
| template = {"id": 0, "command": "getStackTrace", "params": {"isolateId": 0}}; |
| } |
| @@ -310,8 +311,8 @@ |
| List frames = getJsonValue(debugger.currentMessage, "result:callFrames"); |
| assert(frames != null); |
| - String functionName = frames[0]['functionName']; |
| - List localsList = frames[0]['locals']; |
| + String functionName = frames[frame_index]['functionName']; |
| + List localsList = frames[frame_index]['locals']; |
| Map reportedLocals = {}; |
| localsList.forEach((local) => reportedLocals[local['name']] = local['value']); |
| for (String key in locals.keys) { |
| @@ -333,11 +334,47 @@ |
| } |
| -MatchLocals(Map localValues) { |
| - return new LocalsMatcher(localValues); |
| +MatchLocals(Map localValues, [int frame_index = 0]) { |
|
hausner
2015/02/18 18:32:29
It doesn't look like you are using MatchLocals wit
Florian Schneider
2015/02/18 18:45:23
Yes, I only used to while testing. I'll remove it
|
| + return new LocalsMatcher(localValues, frame_index); |
| } |
| +class InvertedLocalsMatcher extends Command { |
|
hausner
2015/02/18 18:32:28
Would you mind adding a one-liner comment what thi
Florian Schneider
2015/02/18 18:45:23
Added comment and renamed to AssertLocalsNotVisibl
|
| + List<String> locals; |
| + int frame_index; |
| + |
| + InvertedLocalsMatcher(this.locals, this.frame_index) { |
| + template = {"id": 0, "command": "getStackTrace", "params": {"isolateId": 0}}; |
| + } |
| + |
| + void matchResponse(Debugger debugger) { |
| + super.matchResponse(debugger); |
| + |
| + List frames = getJsonValue(debugger.currentMessage, "result:callFrames"); |
| + assert(frames != null); |
| + |
| + String functionName = frames[frame_index]['functionName']; |
| + List localsList = frames[frame_index]['locals']; |
| + Map reportedLocals = {}; |
| + localsList.forEach((local) => reportedLocals[local['name']] = local['value']); |
| + for (String key in locals) { |
| + if (reportedLocals[key] != null) { |
| + debugger.error("Error in $functionName(): local variable $key not " |
| + "expected in scope (reported value " |
| + "${reportedLocals[key]['text']})"); |
| + return; |
| + } |
| + } |
| + print("Matched locals $locals"); |
| + } |
| +} |
| + |
| + |
| +AssertLocalsNotVisible(List<String> locals, [int frame_index = 0]) { |
| + return new InvertedLocalsMatcher(locals, frame_index); |
| +} |
| + |
| + |
| class EventMatcher { |
| String eventName; |
| Map params; |