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

Unified Diff: test/command_line_test.dart

Issue 968053004: Allow command-line API to pass in selection to preserve. Fix #194. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Update version Created 5 years, 10 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 | « pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/command_line_test.dart
diff --git a/test/command_line_test.dart b/test/command_line_test.dart
index b2cf84a0d7f5114efe593265714bb8bf7d1eb705..4d1e0d9a3ab9861ca955188752e03380bcbf949d 100644
--- a/test/command_line_test.dart
+++ b/test/command_line_test.dart
@@ -147,6 +147,41 @@ void main() {
});
});
+ group("--preserve", () {
+ test("errors if given paths.", () {
+ var process = runFormatter(["--preserve", "path", "another"]);
+ process.shouldExit(64);
+ });
+
+ test("errors on wrong number of components.", () {
+ var process = runFormatter(["--preserve", "1"]);
+ process.shouldExit(64);
+
+ process = runFormatter(["--preserve", "1:2:3"]);
+ process.shouldExit(64);
+ });
+
+ test("errors on non-integer component.", () {
+ var process = runFormatter(["--preserve", "1:2.3"]);
+ process.shouldExit(64);
+ });
+
+ test("updates selection.", () {
+ var process = runFormatter(["--preserve", "6:10", "-m"]);
+ process.writeLine(unformattedSource);
+ process.closeStdin();
+
+ var json = JSON.encode({
+ "path": "<stdin>",
+ "source": formattedSource,
+ "selection": {"offset": 5, "length": 9}
+ });
+
+ process.stdout.expect(json);
+ process.shouldExit();
+ });
+ });
+
group("with no paths", () {
test("errors on --overwrite.", () {
var process = runFormatter(["--overwrite"]);
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698