Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Unified Diff: dart/tests/try/paste_content_rewriting_test.dart

Issue 212823002: Don't loop forever on scanner errors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix long line that Kasper missed :-) Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/site/try/src/interaction_manager.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/try/paste_content_rewriting_test.dart
diff --git a/dart/tests/try/paste_content_rewriting_test.dart b/dart/tests/try/paste_content_rewriting_test.dart
index 6d12d967ae7f9ccc9c4be657c6cf906d116fa3ee..232d272e2ec558f6b40ab155eed106949fa159d4 100644
--- a/dart/tests/try/paste_content_rewriting_test.dart
+++ b/dart/tests/try/paste_content_rewriting_test.dart
@@ -22,27 +22,58 @@ import '../../site/try/src/user_option.dart' show
import '../../pkg/expect/lib/expect.dart';
import '../../pkg/async_helper/lib/async_helper.dart';
-main() {
+const Map<String, String> tests = const <String, String> {
+ '<span><p>//...</p>}</span>': '//...\n}\n',
+ 'someText': 'someText\n',
+ '"\$"': '"\$"<DIAGNOSTIC>\n',
+ '"\$\$"': '"\$\$<DIAGNOSTIC>"<DIAGNOSTIC>\n',
+ '"\$\$4"': '"\$\$<DIAGNOSTIC>4<DIAGNOSTIC>"\n',
+ '"\$\$4 "': '"\$\$<DIAGNOSTIC>4<DIAGNOSTIC> "\n',
+};
+
+List<Node> queryDiagnosticNodes() {
+ return mainEditorPane.querySelectorAll('a.diagnostic>span');
+}
+
+Future runTests() {
+ Iterator<String> keys = tests.keys.iterator;
+ keys.moveNext();
+ mainEditorPane.innerHtml = keys.current;
+
+ Future makeFuture() => new Future(() {
+ String key = keys.current;
+ print('Checking $key');
+ queryDiagnosticNodes().forEach((Node node) {
+ node.replaceWith(new Text('<DIAGNOSTIC>'));
+ observer.takeRecords(); // Discard mutations.
+ });
+ Expect.stringEquals(tests[key], mainEditorPane.text);
+ if (keys.moveNext()) {
+ key = keys.current;
+ print('Setting $key');
+ mainEditorPane.innerHtml = key;
+ return makeFuture();
+ } else {
+ // Clear the DOM to work around a bug in test.dart.
+ document.body.nodes.clear();
+ return null;
+ }
+ });
+
+ return makeFuture();
+}
+
+void main() {
UserOption.storage = {};
var interaction = new InteractionManager();
mainEditorPane = new DivElement();
document.body.append(mainEditorPane);
observer = new MutationObserver(interaction.onMutation)
- ..observe(mainEditorPane, childList: true, characterData: true, subtree: true);
+ ..observe(
+ mainEditorPane, childList: true, characterData: true, subtree: true);
ahe 2014/03/26 12:45:05 You missed this long line :-)
mainEditorPane.innerHtml = "<span><p>//...</p>}</span>";
- asyncTest(() => new Future(() {
- print('Welcome to the future');
- Expect.stringEquals('//...\n}\n', mainEditorPane.text);
- }).then((_) {
- mainEditorPane.innerHtml = 'someText';
- return new Future(() {
- Expect.stringEquals('someText\n', mainEditorPane.text);
-
- // Clear the DOM to work around a bug in test.dart.
- document.body.nodes.clear();
- });
- }));
+ asyncTest(runTests);
}
« no previous file with comments | « dart/site/try/src/interaction_manager.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698