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

Side by Side 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, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 part of observatory_test;
6
7 _prepareSource(String rawSource) {
8 List<ScriptLine> source = [];
9 List parts = rawSource.split('\n');
10 for (var i = 0; i < parts.length; i++) {
11 source.add(new ScriptLine(i + 1, parts[i]));
12 }
13 return source;
14 }
15
16 runClassParserTest() {
17 group('ClassParser', () {
18 test('Empty', () {
19 String rawSource = r"""
20 class EmptyClass {}""";
21 List<ScriptLine> source = _prepareSource(rawSource);
22 ClassParser clsp = new ClassParser(source);
23 expect(clsp.findEndPos(), [1, 19]);
24 });
25
26 test('Simple', () {
27 String rawSource = r"""
28 class TestClass {
29 Simple();
30 }""";
31 List<ScriptLine> source = _prepareSource(rawSource);
32 ClassParser clsp = new ClassParser(source);
33 expect(clsp.findEndPos(), [3, 1]);
34 });
35
36 test('WithSingleQuotedString', () {
37 String rawSource = r"""
38 class TestClass {
39 String a = '}';
40 }""";
41 List<ScriptLine> source = _prepareSource(rawSource);
42 ClassParser clsp = new ClassParser(source);
43 expect(clsp.findEndPos(), [3, 2]);
44 });
45
46 test('WithDoubleQuotedString', () {
47 String rawSource = r"""
48 class TestClass {
49 String a = "}";
50 }""";
51 List<ScriptLine> source = _prepareSource(rawSource);
52 ClassParser clsp = new ClassParser(source);
53 expect(clsp.findEndPos(), [3, 3]);
54 });
55
56 test('WithSingleQuotedMultilineString', () {
57 String rawSource = r"""
58 class TestClass {
59 String a = '''
60 }{}''';
61 }""";
62 List<ScriptLine> source = _prepareSource(rawSource);
63 ClassParser clsp = new ClassParser(source);
64 expect(clsp.findEndPos(), [4, 1]);
65 });
66
67 test('WithDoubleQuotedMultilineString', () {
68 String rawSource = r'''
69 class TestClass {
70 String a = """
71 }{}""";
72 }''';
73 List<ScriptLine> source = _prepareSource(rawSource);
74 ClassParser clsp = new ClassParser(source);
75 expect(clsp.findEndPos(), [4, 1]);
76 });
77
78 test('WithSingleQuotedEscape', () {
79 String rawSource = r'''
80 class TestClass {
81 String a = '\'}';
82
83 }''';
84 List<ScriptLine> source = _prepareSource(rawSource);
85 ClassParser clsp = new ClassParser(source);
86 expect(clsp.findEndPos(), [4, 2]);
87 });
88
89 test('WithDoubleQuotedEscape', () {
90 String rawSource = r"""
91 class TestClass {
92 String a = "\"}";
93 }""";
94 List<ScriptLine> source = _prepareSource(rawSource);
95 ClassParser clsp = new ClassParser(source);
96 expect(clsp.findEndPos(), [3, 1]);
97 });
98
99 test('WithSinglelineComments', () {
100 String rawSource = r"""
101 class TestClass {
102 // }
103 // -- } // }
104 // }
105 }""";
106 List<ScriptLine> source = _prepareSource(rawSource);
107 ClassParser clsp = new ClassParser(source);
108 expect(clsp.findEndPos(), [5, 1]);
109 });
110
111 test('WithMultilineComments', () {
112 String rawSource = r"""
113 class TestClass {
114 /*
115 /* } */
116 //
117 */
118 }""";
119 List<ScriptLine> source = _prepareSource(rawSource);
120 ClassParser clsp = new ClassParser(source);
121 expect(clsp.findEndPos(), [6, 2]);
122 });
123
124 test('LittleBitOfEverything', () {
125 String rawSource = r'''
126 class TestClass {
127 /**
128 * }
129 */
130 var a = """
131 \'\"\"\"}
132 """;
133 // foo
134 bar() { return "'\'}"; }
135 /* /* */ /* } */ */
136 }''';
137 List<ScriptLine> source = _prepareSource(rawSource);
138 ClassParser clsp = new ClassParser(source);
139 expect(clsp.findEndPos(), [11, 1]);
140 });
141 });
142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698