| OLD | NEW |
| 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 /// This file tests stack_trace's ability to parse live stack traces. It's a | 5 /// This file tests stack_trace's ability to parse live stack traces. It's a |
| 6 /// dual of dartium_test.dart, since method names can differ somewhat from | 6 /// dual of dartium_test.dart, since method names can differ somewhat from |
| 7 /// platform to platform. No similar file exists for dart2js since the specific | 7 /// platform to platform. No similar file exists for dart2js since the specific |
| 8 /// method names there are implementation details. | 8 /// method names there are implementation details. |
| 9 | 9 |
| 10 import 'package:path/path.dart' as path; | 10 import 'package:path/path.dart' as path; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 Trace getCurrentTrace([int level]) => new Trace.current(level); | 37 Trace getCurrentTrace([int level]) => new Trace.current(level); |
| 38 | 38 |
| 39 Trace nestedGetCurrentTrace(int level) => getCurrentTrace(level); | 39 Trace nestedGetCurrentTrace(int level) => getCurrentTrace(level); |
| 40 | 40 |
| 41 void main() { | 41 void main() { |
| 42 group('Trace', () { | 42 group('Trace', () { |
| 43 test('.parse parses a real stack trace correctly', () { | 43 test('.parse parses a real stack trace correctly', () { |
| 44 var string = getStackTraceString(); | 44 var string = getStackTraceString(); |
| 45 var trace = new Trace.parse(string); | 45 var trace = new Trace.parse(string); |
| 46 var builder = new path.Builder(style: path.Style.url); | 46 expect(path.url.basename(trace.frames.first.uri.path), |
| 47 expect(builder.basename(trace.frames.first.uri.path), | |
| 48 equals('vm_test.dart')); | 47 equals('vm_test.dart')); |
| 49 expect(trace.frames.first.member, equals('getStackTraceString')); | 48 expect(trace.frames.first.member, equals('getStackTraceString')); |
| 50 }); | 49 }); |
| 51 | 50 |
| 52 test('converts from a native stack trace correctly', () { | 51 test('converts from a native stack trace correctly', () { |
| 53 var trace = new Trace.from(getStackTraceObject()); | 52 var trace = new Trace.from(getStackTraceObject()); |
| 54 var builder = new path.Builder(style: path.Style.url); | 53 expect(path.url.basename(trace.frames.first.uri.path), |
| 55 expect(builder.basename(trace.frames.first.uri.path), | |
| 56 equals('vm_test.dart')); | 54 equals('vm_test.dart')); |
| 57 expect(trace.frames.first.member, equals('getStackTraceObject')); | 55 expect(trace.frames.first.member, equals('getStackTraceObject')); |
| 58 }); | 56 }); |
| 59 | 57 |
| 60 group('.current()', () { | 58 group('.current()', () { |
| 61 test('with no argument returns a trace starting at the current frame', | 59 test('with no argument returns a trace starting at the current frame', |
| 62 () { | 60 () { |
| 63 var trace = new Trace.current(); | 61 var trace = new Trace.current(); |
| 64 expect(trace.frames.first.member, equals('main.<fn>.<fn>.<fn>')); | 62 expect(trace.frames.first.member, equals('main.<fn>.<fn>.<fn>')); |
| 65 }); | 63 }); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 98 |
| 101 test('at level 2 returns the grandparent frame', () { | 99 test('at level 2 returns the grandparent frame', () { |
| 102 expect(nestedGetCaller(2).member, equals('main.<fn>.<fn>')); | 100 expect(nestedGetCaller(2).member, equals('main.<fn>.<fn>')); |
| 103 }); | 101 }); |
| 104 | 102 |
| 105 test('throws an ArgumentError for negative levels', () { | 103 test('throws an ArgumentError for negative levels', () { |
| 106 expect(() => new Frame.caller(-1), throwsArgumentError); | 104 expect(() => new Frame.caller(-1), throwsArgumentError); |
| 107 }); | 105 }); |
| 108 }); | 106 }); |
| 109 } | 107 } |
| OLD | NEW |