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

Unified Diff: runtime/bin/vmservice/client/tests/class_parser_test.dart

Issue 361743002: observatory/vm: add support for computing/passing end tokens on classes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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: runtime/bin/vmservice/client/tests/class_parser_test.dart
diff --git a/runtime/bin/vmservice/client/tests/class_parser_test.dart b/runtime/bin/vmservice/client/tests/class_parser_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2428d30f8d7fdfdefa074dcf03ded7f553874e66
--- /dev/null
+++ b/runtime/bin/vmservice/client/tests/class_parser_test.dart
@@ -0,0 +1,142 @@
+// 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.
+
+part of observatory_test;
+
+_prepareSource(String rawSource) {
+ List<ScriptLine> source = [];
+ List parts = rawSource.split('\n');
+ for (var i = 0; i < parts.length; i++) {
+ source.add(new ScriptLine(i + 1, parts[i]));
+ }
+ return source;
+}
+
+runClassParserTest() {
+ group('ClassParser', () {
+ test('Empty', () {
+ String rawSource = r"""
+class EmptyClass {}""";
+ List<ScriptLine> source = _prepareSource(rawSource);
+ ClassParser clsp = new ClassParser(source);
+ expect(clsp.findEndPos(), [1, 19]);
+ });
+
+ test('Simple', () {
+ String rawSource = r"""
+class TestClass {
+ Simple();
+}""";
+ List<ScriptLine> source = _prepareSource(rawSource);
+ ClassParser clsp = new ClassParser(source);
+ expect(clsp.findEndPos(), [3, 1]);
+ });
+
+ test('WithSingleQuotedString', () {
+ String rawSource = r"""
+class TestClass {
+ String a = '}';
+ }""";
+ List<ScriptLine> source = _prepareSource(rawSource);
+ ClassParser clsp = new ClassParser(source);
+ expect(clsp.findEndPos(), [3, 2]);
+ });
+
+ test('WithDoubleQuotedString', () {
+ String rawSource = r"""
+class TestClass {
+ String a = "}";
+ }""";
+ List<ScriptLine> source = _prepareSource(rawSource);
+ ClassParser clsp = new ClassParser(source);
+ expect(clsp.findEndPos(), [3, 3]);
+ });
+
+ test('WithSingleQuotedMultilineString', () {
+ String rawSource = r"""
+class TestClass {
+ String a = '''
+}{}''';
+}""";
+ List<ScriptLine> source = _prepareSource(rawSource);
+ ClassParser clsp = new ClassParser(source);
+ expect(clsp.findEndPos(), [4, 1]);
+ });
+
+ test('WithDoubleQuotedMultilineString', () {
+ String rawSource = r'''
+class TestClass {
+ String a = """
+}{}""";
+}''';
+ List<ScriptLine> source = _prepareSource(rawSource);
+ ClassParser clsp = new ClassParser(source);
+ expect(clsp.findEndPos(), [4, 1]);
+ });
+
+ test('WithSingleQuotedEscape', () {
+ String rawSource = r'''
+class TestClass {
+ String a = '\'}';
+
+ }''';
+ List<ScriptLine> source = _prepareSource(rawSource);
+ ClassParser clsp = new ClassParser(source);
+ expect(clsp.findEndPos(), [4, 2]);
+ });
+
+ test('WithDoubleQuotedEscape', () {
+ String rawSource = r"""
+class TestClass {
+ String a = "\"}";
+}""";
+ List<ScriptLine> source = _prepareSource(rawSource);
+ ClassParser clsp = new ClassParser(source);
+ expect(clsp.findEndPos(), [3, 1]);
+ });
+
+ test('WithSinglelineComments', () {
+ String rawSource = r"""
+class TestClass {
+ // }
+ // -- } // }
+ // }
+}""";
+ List<ScriptLine> source = _prepareSource(rawSource);
+ ClassParser clsp = new ClassParser(source);
+ expect(clsp.findEndPos(), [5, 1]);
+ });
+
+ test('WithMultilineComments', () {
+ String rawSource = r"""
+class TestClass {
+ /*
+ /* } */
+ //
+ */
+ }""";
+ List<ScriptLine> source = _prepareSource(rawSource);
+ ClassParser clsp = new ClassParser(source);
+ expect(clsp.findEndPos(), [6, 2]);
+ });
+
+ test('LittleBitOfEverything', () {
+ String rawSource = r'''
+class TestClass {
+ /**
+ * }
+ */
+ var a = """
+\'\"\"\"}
+""";
+ // foo
+ bar() { return "'\'}"; }
+ /* /* */ /* } */ */
+}''';
+ List<ScriptLine> source = _prepareSource(rawSource);
+ ClassParser clsp = new ClassParser(source);
+ expect(clsp.findEndPos(), [11, 1]);
+ });
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698