| Index: tests/standalone/debugger/debug_lib.dart
|
| ===================================================================
|
| --- tests/standalone/debugger/debug_lib.dart (revision 24149)
|
| +++ tests/standalone/debugger/debug_lib.dart (working copy)
|
| @@ -186,10 +186,16 @@
|
| int frameIndex;
|
| List<String> functionNames;
|
|
|
| + Map locals = {};
|
| +
|
| FrameMatcher(this.frameIndex, this.functionNames) {
|
| template = {"id": 0, "command": "getStackTrace", "params": {"isolateId": 0}};
|
| }
|
|
|
| + void matchLocal(String localName, String localValue) {
|
| + locals[localName] = localValue;
|
| + }
|
| +
|
| void matchResponse(Debugger debugger) {
|
| super.matchResponse(debugger);
|
| var msg = debugger.currentMessage;
|
| @@ -218,6 +224,26 @@
|
| return;
|
| }
|
| }
|
| +
|
| + // verify locals
|
| + String functionName = frames[frameIndex]['functionName'];
|
| + List localsList = frames[frameIndex]['locals'];
|
| + Map reportedLocals = {};
|
| + localsList.forEach((local) => reportedLocals[local['name']] = local['value']);
|
| + for (String key in locals.keys) {
|
| + if (reportedLocals[key] == null) {
|
| + debugger.error("Error in $functionName(): no value reported for local "
|
| + "variable $key");
|
| + return;
|
| + }
|
| + String expected = locals[key];
|
| + String actual = reportedLocals[key]['text'];
|
| + if (expected != actual) {
|
| + debugger.error("Error in $functionName(): got '$actual' for local "
|
| + "variable $key, but expected '$expected'");
|
| + return;
|
| + }
|
| + }
|
| }
|
| }
|
|
|
| @@ -231,6 +257,27 @@
|
| }
|
|
|
|
|
| +class EventMatcher {
|
| + String eventName;
|
| +
|
| + EventMatcher(this.eventName);
|
| +
|
| + void matchEvent(Debugger debugger, Map event) {
|
| + String actualName = event['event'];
|
| +
|
| + if (eventName != actualName) {
|
| + debugger.error("Error: got event $actualName but expected event $eventName");
|
| + return;
|
| + }
|
| + }
|
| +}
|
| +
|
| +
|
| +ExpectEvent(String eventName) {
|
| + return new EventMatcher(eventName);
|
| +}
|
| +
|
| +
|
| class RunCommand extends Command {
|
| RunCommand.resume() {
|
| template = {"id": 0, "command": "resume", "params": {"isolateId": 0}};
|
| @@ -285,6 +332,7 @@
|
| entries.add(MatchFrame(0, "main"));
|
| }
|
| bool get isEmpty => entries.isEmpty;
|
| + bool get isNextEventMatcher => !isEmpty && currentEntry is EventMatcher;
|
| get currentEntry => entries.last;
|
| advance() => entries.removeLast();
|
| add(entry) => entries.add(entry);
|
| @@ -361,6 +409,12 @@
|
| } else {
|
| error("Error: unknown debugger event received");
|
| }
|
| +
|
| + if (script.isNextEventMatcher) {
|
| + EventMatcher matcher = script.currentEntry;
|
| + script.advance();
|
| + matcher.matchEvent(this, msg);
|
| + }
|
| }
|
|
|
| // Handle one JSON message object and match it to the
|
|
|