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

Side by Side Diff: packages/stack_trace/test/chain/dart2js_test.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 // dart2js chain tests are separated out because dart2js stack traces are 5 // dart2js chain tests are separated out because dart2js stack traces are
6 // inconsistent due to inlining and browser differences. These tests don't 6 // inconsistent due to inlining and browser differences. These tests don't
7 // assert anything about the content of the traces, just the number of traces in 7 // assert anything about the content of the traces, just the number of traces in
8 // a chain. 8 // a chain.
9 @TestOn('js') 9 @TestOn('js')
10 10
(...skipping 10 matching lines...) Expand all
21 var chain = await captureFuture(() => throw 'error'); 21 var chain = await captureFuture(() => throw 'error');
22 expect(chain.traces, hasLength(1)); 22 expect(chain.traces, hasLength(1));
23 }); 23 });
24 24
25 test('thrown in a microtask', () async { 25 test('thrown in a microtask', () async {
26 var chain = await captureFuture(() => inMicrotask(() => throw 'error')); 26 var chain = await captureFuture(() => inMicrotask(() => throw 'error'));
27 expect(chain.traces, hasLength(2)); 27 expect(chain.traces, hasLength(2));
28 }); 28 });
29 29
30 test('thrown in a one-shot timer', () async { 30 test('thrown in a one-shot timer', () async {
31 var chain = await captureFuture( 31 var chain =
32 () => inOneShotTimer(() => throw 'error')); 32 await captureFuture(() => inOneShotTimer(() => throw 'error'));
33 expect(chain.traces, hasLength(2)); 33 expect(chain.traces, hasLength(2));
34 }); 34 });
35 35
36 test('thrown in a periodic timer', () async { 36 test('thrown in a periodic timer', () async {
37 var chain = await captureFuture( 37 var chain =
38 () => inPeriodicTimer(() => throw 'error')); 38 await captureFuture(() => inPeriodicTimer(() => throw 'error'));
39 expect(chain.traces, hasLength(2)); 39 expect(chain.traces, hasLength(2));
40 }); 40 });
41 41
42 test('thrown in a nested series of asynchronous operations', () async { 42 test('thrown in a nested series of asynchronous operations', () async {
43 var chain = await captureFuture(() { 43 var chain = await captureFuture(() {
44 inPeriodicTimer(() { 44 inPeriodicTimer(() {
45 inOneShotTimer(() => inMicrotask(() => throw 'error')); 45 inOneShotTimer(() => inMicrotask(() => throw 'error'));
46 }); 46 });
47 }); 47 });
48 48
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 var completer = new Completer(); 231 var completer = new Completer();
232 Chain.capture(() { 232 Chain.capture(() {
233 inFutureChain(() => completer.complete(new Chain.current())); 233 inFutureChain(() => completer.complete(new Chain.current()));
234 }); 234 });
235 235
236 var chain = await completer.future; 236 var chain = await completer.future;
237 expect(chain.traces, hasLength(2)); 237 expect(chain.traces, hasLength(2));
238 }); 238 });
239 }); 239 });
240 240
241 test('current() outside of capture() returns a chain wrapping the current ' 241 test(
242 'current() outside of capture() returns a chain wrapping the current '
242 'trace', () { 243 'trace', () {
243 // The test runner runs all tests with chains enabled, so to test without we 244 // The test runner runs all tests with chains enabled.
244 // have to do some zone munging. 245 return Chain.disable(() async {
245 return runZoned(() async {
246 var completer = new Completer(); 246 var completer = new Completer();
247 inMicrotask(() => completer.complete(new Chain.current())); 247 inMicrotask(() => completer.complete(new Chain.current()));
248 248
249 var chain = await completer.future; 249 var chain = await completer.future;
250 // Since the chain wasn't loaded within [Chain.capture], the full stack 250 // Since the chain wasn't loaded within [Chain.capture], the full stack
251 // chain isn't available and it just returns the current stack when 251 // chain isn't available and it just returns the current stack when
252 // called. 252 // called.
253 expect(chain.traces, hasLength(1)); 253 expect(chain.traces, hasLength(1));
254 }, zoneValues: {#stack_trace.stack_zone.spec: null}); 254 });
255 }); 255 });
256 256
257 group('forTrace() within capture()', () { 257 group('forTrace() within capture()', () {
258 test('called for a stack trace from a microtask', () async { 258 test('called for a stack trace from a microtask', () async {
259 var chain = await Chain.capture(() { 259 var chain = await Chain.capture(() {
260 return chainForTrace(inMicrotask, () => throw 'error'); 260 return chainForTrace(inMicrotask, () => throw 'error');
261 }); 261 });
262 262
263 // Because [chainForTrace] has to set up a future chain to capture the 263 // Because [chainForTrace] has to set up a future chain to capture the
264 // stack trace while still showing it to the zone specification, it adds 264 // stack trace while still showing it to the zone specification, it adds
(...skipping 10 matching lines...) Expand all
275 }); 275 });
276 276
277 test('called for a stack trace from a periodic timer', () async { 277 test('called for a stack trace from a periodic timer', () async {
278 var chain = await Chain.capture(() { 278 var chain = await Chain.capture(() {
279 return chainForTrace(inPeriodicTimer, () => throw 'error'); 279 return chainForTrace(inPeriodicTimer, () => throw 'error');
280 }); 280 });
281 281
282 expect(chain.traces, hasLength(3)); 282 expect(chain.traces, hasLength(3));
283 }); 283 });
284 284
285 test('called for a stack trace from a nested series of asynchronous ' 285 test(
286 'called for a stack trace from a nested series of asynchronous '
286 'operations', () async { 287 'operations', () async {
287 var chain = await Chain.capture(() { 288 var chain = await Chain.capture(() {
288 return chainForTrace((callback) { 289 return chainForTrace((callback) {
289 inPeriodicTimer(() => inOneShotTimer(() => inMicrotask(callback))); 290 inPeriodicTimer(() => inOneShotTimer(() => inMicrotask(callback)));
290 }, () => throw 'error'); 291 }, () => throw 'error');
291 }); 292 });
292 293
293 expect(chain.traces, hasLength(5)); 294 expect(chain.traces, hasLength(5));
294 }); 295 });
295 296
296 test('called for a stack trace from a long future chain', () async { 297 test('called for a stack trace from a long future chain', () async {
297 var chain = await Chain.capture(() { 298 var chain = await Chain.capture(() {
298 return chainForTrace(inFutureChain, () => throw 'error'); 299 return chainForTrace(inFutureChain, () => throw 'error');
299 }); 300 });
300 301
301 expect(chain.traces, hasLength(3)); 302 expect(chain.traces, hasLength(3));
302 }); 303 });
303 304
304 test('called for an unregistered stack trace returns a chain wrapping that ' 305 test(
306 'called for an unregistered stack trace returns a chain wrapping that '
305 'trace', () { 307 'trace', () {
306 var trace; 308 var trace;
307 var chain = Chain.capture(() { 309 var chain = Chain.capture(() {
308 try { 310 try {
309 throw 'error'; 311 throw 'error';
310 } catch (_, stackTrace) { 312 } catch (_, stackTrace) {
311 trace = stackTrace; 313 trace = stackTrace;
312 return new Chain.forTrace(stackTrace); 314 return new Chain.forTrace(stackTrace);
313 } 315 }
314 }); 316 });
315 317
316 expect(chain.traces, hasLength(1)); 318 expect(chain.traces, hasLength(1));
317 expect(chain.traces.first.toString(), 319 expect(chain.traces.first.toString(),
318 equals(new Trace.from(trace).toString())); 320 equals(new Trace.from(trace).toString()));
319 }); 321 });
320 }); 322 });
321 323
322 test('forTrace() outside of capture() returns a chain wrapping the given ' 324 test(
325 'forTrace() outside of capture() returns a chain wrapping the given '
323 'trace', () { 326 'trace', () {
324 var trace; 327 var trace;
325 var chain = Chain.capture(() { 328 var chain = Chain.capture(() {
326 try { 329 try {
327 throw 'error'; 330 throw 'error';
328 } catch (_, stackTrace) { 331 } catch (_, stackTrace) {
329 trace = stackTrace; 332 trace = stackTrace;
330 return new Chain.forTrace(stackTrace); 333 return new Chain.forTrace(stackTrace);
331 } 334 }
332 }); 335 });
333 336
334 expect(chain.traces, hasLength(1)); 337 expect(chain.traces, hasLength(1));
335 expect(chain.traces.first.toString(), 338 expect(chain.traces.first.toString(),
336 equals(new Trace.from(trace).toString())); 339 equals(new Trace.from(trace).toString()));
337 }); 340 });
338 } 341 }
OLDNEW
« no previous file with comments | « packages/stack_trace/test/chain/chain_test.dart ('k') | packages/stack_trace/test/chain/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698