Index: tests/compiler/dart2js/sourcemaps/stacktrace_test.dart |
diff --git a/tests/compiler/dart2js/sourcemaps/stacktrace_test.dart b/tests/compiler/dart2js/sourcemaps/stacktrace_test.dart |
index 89d1ff7ba671e52a987b9ea9da1a48ec1a63e5b7..39617a8bb27f66bf9f62c3fc6012eb6031c462a9 100644 |
--- a/tests/compiler/dart2js/sourcemaps/stacktrace_test.dart |
+++ b/tests/compiler/dart2js/sourcemaps/stacktrace_test.dart |
@@ -15,6 +15,7 @@ import 'package:expect/expect.dart'; |
import 'package:source_maps/source_maps.dart'; |
import 'package:source_maps/src/utils.dart'; |
+import '../annotated_code_helper.dart'; |
import '../source_map_validator_helper.dart'; |
const String EXCEPTION_MARKER = '>ExceptionMarker<'; |
@@ -184,60 +185,28 @@ const int _CR = 0x0D; |
const int _LBRACE = 0x7B; |
Test processTestCode(String code) { |
- StringBuffer codeBuffer = new StringBuffer(); |
Map<int, StackTraceLine> stackTraceMap = <int, StackTraceLine>{}; |
List<StackTraceLine> unexpectedLines = <StackTraceLine>[]; |
- int index = 0; |
- int lineNo = 1; |
- int columnNo = 1; |
- while (index < code.length) { |
- int charCode = code.codeUnitAt(index); |
- switch (charCode) { |
- case _LF: |
- codeBuffer.write('\n'); |
- lineNo++; |
- columnNo = 1; |
- break; |
- case _CR: |
- if (index + 1 < code.length && code.codeUnitAt(index + 1) == _LF) { |
- index++; |
- } |
- codeBuffer.write('\n'); |
- lineNo++; |
- columnNo = 1; |
- break; |
- case 0x40: |
- if (index + 1 < code.length && code.codeUnitAt(index + 1) == _LBRACE) { |
- int colonIndex = code.indexOf(':', index); |
- int endIndex = code.indexOf('}', index); |
- String methodName = code.substring(colonIndex + 1, endIndex); |
- String indexText = code.substring(index + 2, colonIndex); |
- StackTraceLine stackTraceLine = |
- new StackTraceLine(methodName, INPUT_FILE_NAME, lineNo, columnNo); |
- if (indexText == '') { |
- unexpectedLines.add(stackTraceLine); |
- } else { |
- int stackTraceIndex = int.parse(indexText); |
- assert(!stackTraceMap.containsKey(stackTraceIndex)); |
- stackTraceMap[stackTraceIndex] = stackTraceLine; |
- } |
- index = endIndex; |
- } else { |
- codeBuffer.writeCharCode(charCode); |
- columnNo++; |
- } |
- break; |
- default: |
- codeBuffer.writeCharCode(charCode); |
- columnNo++; |
+ AnnotatedCode annotatedCode = new AnnotatedCode(code); |
+ for (Annotation annotation in annotatedCode.annotations) { |
+ int colonIndex = annotation.text.indexOf(':'); |
+ String indexText = annotation.text.substring(0, colonIndex); |
+ String methodName = annotation.text.substring(colonIndex + 1); |
+ StackTraceLine stackTraceLine = new StackTraceLine( |
+ methodName, INPUT_FILE_NAME, annotation.lineNo, annotation.columnNo); |
+ if (indexText == '') { |
+ unexpectedLines.add(stackTraceLine); |
+ } else { |
+ int stackTraceIndex = int.parse(indexText); |
+ assert(!stackTraceMap.containsKey(stackTraceIndex)); |
+ stackTraceMap[stackTraceIndex] = stackTraceLine; |
} |
- index++; |
} |
List<StackTraceLine> expectedLines = <StackTraceLine>[]; |
for (int stackTraceIndex in (stackTraceMap.keys.toList()..sort()).reversed) { |
expectedLines.add(stackTraceMap[stackTraceIndex]); |
} |
- return new Test(codeBuffer.toString(), expectedLines, unexpectedLines); |
+ return new Test(annotatedCode.sourceCode, expectedLines, unexpectedLines); |
} |
void main(List<String> arguments) { |