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

Unified Diff: pkg/codegen/test/refactor_test.dart

Issue 22396004: Make observable transform a barback transform. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: changes alone (patchset 1 has the existing code, in the new location) Created 7 years, 4 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
Index: pkg/codegen/test/refactor_test.dart
diff --git a/pkg/codegen/test/refactor_test.dart b/pkg/codegen/test/refactor_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..38e774b496bad3563d39713ca8a0f280b85072ad
--- /dev/null
+++ b/pkg/codegen/test/refactor_test.dart
@@ -0,0 +1,44 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library polymer.test.refactor_test;
+
+import 'package:unittest/unittest.dart';
+import 'package:codegen/refactor.dart';
+import 'package:source_maps/span.dart';
+
+main() {
+ var original = "0123456789abcdefghij";
+ var file = new SourceFile.text('', original);
+
+ test('non conflicting, in order edits', () {
+ var txn = new TextEditTransaction(original, file);
+ txn.edit(2, 4, '.');
+ txn.edit(5, 5, '|');
+ txn.edit(6, 6, '-');
+ txn.edit(6, 7, '_');
+ expect((txn.commit()..build('')).text, "01.4|5-_789abcdefghij");
+ });
+
+ test('non conflicting, out of order edits', () {
+ var txn = new TextEditTransaction(original, file);
+ txn.edit(2, 4, '.');
+ txn.edit(5, 5, '|');
+
+ // Regresion test for issue #404: there is no conflict/overlap for edits
+ // that don't remove any of the original code.
+ txn.edit(6, 7, '_');
+ txn.edit(6, 6, '-');
+ expect((txn.commit()..build('')).text, "01.4|5-_789abcdefghij");
+
+ });
+
+ test('non conflicting edits', () {
+ var txn = new TextEditTransaction(original, file);
+ txn.edit(2, 4, '.');
+ txn.edit(3, 3, '-');
+ expect(() => txn.commit(), throwsA(predicate(
+ (e) => e.toString().contains('overlapping edits'))));
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698