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

Side by Side Diff: pkg/observe/test/transformer_test.dart

Issue 513023002: Step one towards stable error messages with details: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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
« no previous file with comments | « pkg/observe/pubspec.yaml ('k') | pkg/observe/test/unique_message_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'package:barback/barback.dart'; 6 import 'package:barback/barback.dart';
7 import 'package:observe/transformer.dart'; 7 import 'package:observe/transformer.dart';
8 import 'package:unittest/compact_vm_config.dart'; 8 import 'package:unittest/compact_vm_config.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 import 'package:stack_trace/stack_trace.dart';
10 11
11 main() { 12 main() {
12 useCompactVMConfiguration(); 13 useCompactVMConfiguration();
13 14
14 group('replaces Observable for ChangeNotifier', () { 15 group('replaces Observable for ChangeNotifier', () {
15 _testClause('extends Observable', 'extends ChangeNotifier'); 16 _testClause('extends Observable', 'extends ChangeNotifier');
16 _testClause('extends Base with Observable', 17 _testClause('extends Base with Observable',
17 'extends Base with ChangeNotifier'); 18 'extends Base with ChangeNotifier');
18 _testClause('extends Base<T> with Observable', 19 _testClause('extends Base<T> with Observable',
19 'extends Base<T> with ChangeNotifier'); 20 'extends Base<T> with ChangeNotifier');
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 var end = output.indexOf(';', begin); 123 var end = output.indexOf(';', begin);
123 if (end == -1) end = output.length; 124 if (end == -1) end = output.length;
124 var init = output.substring(begin, end).trim().replaceAll(' ', ' '); 125 var init = output.substring(begin, end).trim().replaceAll(' ', ' ');
125 expect(init, expected); 126 expect(init, expected);
126 }); 127 });
127 }); 128 });
128 } 129 }
129 130
130 /// Helper that applies the transform by creating mock assets. 131 /// Helper that applies the transform by creating mock assets.
131 Future<String> _transform(String code) { 132 Future<String> _transform(String code) {
132 var id = new AssetId('foo', 'a/b/c.dart'); 133 return Chain.capture(() {
133 var asset = new Asset.fromString(id, code); 134 var id = new AssetId('foo', 'a/b/c.dart');
134 var transformer = new ObservableTransformer(); 135 var asset = new Asset.fromString(id, code);
135 return transformer.isPrimary(asset).then((isPrimary) { 136 var transformer = new ObservableTransformer();
136 expect(isPrimary, isTrue); 137 return transformer.isPrimary(asset).then((isPrimary) {
137 var transform = new _MockTransform(asset); 138 expect(isPrimary, isTrue);
138 return transformer.apply(transform).then((_) { 139 var transform = new _MockTransform(asset);
139 expect(transform.outs, hasLength(1)); 140 return transformer.apply(transform).then((_) {
140 expect(transform.outs[0].id, id); 141 expect(transform.outs, hasLength(2));
141 return transform.outs.first.readAsString(); 142 expect(transform.outs[0].id, id);
143 expect(transform.outs[1].id, id.addExtension('._buildLogs.1'));
144 return transform.outs.first.readAsString();
145 });
142 }); 146 });
143 }); 147 });
144 } 148 }
145 149
146 class _MockTransform implements Transform { 150 class _MockTransform implements Transform {
147 bool shouldConsumePrimary = false; 151 bool shouldConsumePrimary = false;
148 List<Asset> outs = []; 152 List<Asset> outs = [];
149 Asset _asset; 153 Asset _asset;
150 TransformLogger logger = new TransformLogger(_mockLogFn); 154 TransformLogger logger = new TransformLogger(_mockLogFn);
151 Asset get primaryInput => _asset; 155 Asset get primaryInput => _asset;
152 156
153 _MockTransform(this._asset); 157 _MockTransform(this._asset);
154 Future<Asset> getInput(AssetId id) { 158 Future<Asset> getInput(AssetId id) {
155 if (id == primaryInput.id) return new Future.value(primaryInput); 159 if (id == primaryInput.id) return new Future.value(primaryInput);
156 fail('_MockTransform fail'); 160 fail('_MockTransform fail');
157 } 161 }
158 162
159 void addOutput(Asset output) { 163 void addOutput(Asset output) {
160 outs.add(output); 164 outs.add(output);
161 } 165 }
162 166
163 void consumePrimary() { 167 void consumePrimary() {
164 shouldConsumePrimary = true; 168 shouldConsumePrimary = true;
165 } 169 }
166 170
167 readInput(id) => throw new UnimplementedError(); 171 readInput(id) => throw new UnimplementedError();
168 readInputAsString(id, {encoding}) => throw new UnimplementedError(); 172 readInputAsString(id, {encoding}) => throw new UnimplementedError();
169 hasInput(id) => throw new UnimplementedError(); 173 hasInput(id) =>
174 new Future.value(id == _asset.id || outs.any((a) => a.id == id));
170 175
171 static void _mockLogFn(AssetId asset, LogLevel level, String message, 176 static void _mockLogFn(AssetId asset, LogLevel level, String message,
172 span) { 177 span) {
173 // Do nothing. 178 // Do nothing.
174 } 179 }
175 } 180 }
176 181
177 String _sampleObservable(String annotation) => ''' 182 String _sampleObservable(String annotation) => '''
178 library A_foo; 183 library A_foo;
179 import 'package:observe/observe.dart'; 184 import 'package:observe/observe.dart';
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 " Foo\n" 220 " Foo\n"
216 " get foo => __\$foo; Foo __\$foo/*D*/= 1; " 221 " get foo => __\$foo; Foo __\$foo/*D*/= 1; "
217 "${_makeSetter('Foo', 'foo')} " 222 "${_makeSetter('Foo', 'foo')} "
218 "@reflectable @$meta @otherMetadata Foo get bar => __\$bar; " 223 "@reflectable @$meta @otherMetadata Foo get bar => __\$bar; "
219 "Foo __\$bar =/*A*/2/*B*/; ${_makeSetter('Foo', 'bar')}\n" 224 "Foo __\$bar =/*A*/2/*B*/; ${_makeSetter('Foo', 'bar')}\n"
220 " @reflectable @$meta @otherMetadata Foo get quux => __\$quux; " 225 " @reflectable @$meta @otherMetadata Foo get quux => __\$quux; "
221 "Foo __\$quux/*C*/; ${_makeSetter('Foo', 'quux')}\n\n" 226 "Foo __\$quux/*C*/; ${_makeSetter('Foo', 'quux')}\n\n"
222 " @reflectable @$meta dynamic get baz => __\$baz; dynamic __\$baz; " 227 " @reflectable @$meta dynamic get baz => __\$baz; dynamic __\$baz; "
223 "${_makeSetter('dynamic', 'baz')}\n" 228 "${_makeSetter('dynamic', 'baz')}\n"
224 "}\n"; 229 "}\n";
OLDNEW
« no previous file with comments | « pkg/observe/pubspec.yaml ('k') | pkg/observe/test/unique_message_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698