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

Unified Diff: packages/dart_style/test/source_code_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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: packages/dart_style/test/source_code_test.dart
diff --git a/packages/dart_style/test/source_code_test.dart b/packages/dart_style/test/source_code_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a3e1169c73e076920f36f31030f3eaa22c103a60
--- /dev/null
+++ b/packages/dart_style/test/source_code_test.dart
@@ -0,0 +1,83 @@
+// Copyright (c) 2014, 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 dart_style.test.source_code_test;
+
+import 'package:test/test.dart';
+
+import 'package:dart_style/dart_style.dart';
+
+void main() {
+ var selection =
+ new SourceCode("123456;", selectionStart: 3, selectionLength: 2);
+ var noSelection = new SourceCode("123456;");
+
+ group('constructor', () {
+ test('throws on negative start', () {
+ expect(() {
+ new SourceCode("12345;", selectionStart: -1, selectionLength: 0);
+ }, throwsArgumentError);
+ });
+
+ test('throws on out of bounds start', () {
+ expect(() {
+ new SourceCode("12345;", selectionStart: 7, selectionLength: 0);
+ }, throwsArgumentError);
+ });
+
+ test('throws on negative length', () {
+ expect(() {
+ new SourceCode("12345;", selectionStart: 1, selectionLength: -1);
+ }, throwsArgumentError);
+ });
+
+ test('throws on out of bounds length', () {
+ expect(() {
+ new SourceCode("12345;", selectionStart: 2, selectionLength: 5);
+ }, throwsArgumentError);
+ });
+
+ test('throws is start is null and length is not', () {
+ expect(() {
+ new SourceCode("12345;", selectionStart: 0);
+ }, throwsArgumentError);
+ });
+
+ test('throws is length is null and start is not', () {
+ expect(() {
+ new SourceCode("12345;", selectionLength: 1);
+ }, throwsArgumentError);
+ });
+ });
+
+ group('textBeforeSelection', () {
+ test('gets substring before selection', () {
+ expect(selection.textBeforeSelection, equals("123"));
+ });
+
+ test('gets entire string if no selection', () {
+ expect(noSelection.textBeforeSelection, equals("123456;"));
+ });
+ });
+
+ group('selectedText', () {
+ test('gets selection substring', () {
+ expect(selection.selectedText, equals("45"));
+ });
+
+ test('gets empty string if no selection', () {
+ expect(noSelection.selectedText, equals(""));
+ });
+ });
+
+ group('textAfterSelection', () {
+ test('gets substring after selection', () {
+ expect(selection.textAfterSelection, equals("6;"));
+ });
+
+ test('gets empty string if no selection', () {
+ expect(noSelection.textAfterSelection, equals(""));
+ });
+ });
+}
« no previous file with comments | « packages/dart_style/test/selections/selections.unit ('k') | packages/dart_style/test/splitting/._arrows.unit » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698