| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2017, 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 // Test that stack traces are properly demangled in constructors (#28740). | |
| 6 | |
| 7 import "package:expect/expect.dart"; | |
| 8 | |
| 9 class SomeClass { | |
| 10 SomeClass.namedConstructor() { | |
| 11 throw new Exception(); | |
| 12 } | |
| 13 | |
| 14 SomeClass() { | |
| 15 throw new Exception(); | |
| 16 } | |
| 17 | |
| 18 factory SomeClass.useFactory() { | |
| 19 throw new Exception(); | |
| 20 } | |
| 21 } | |
| 22 | |
| 23 class OnlyHasFactory { | |
| 24 factory OnlyHasFactory() { | |
| 25 throw new Exception(); | |
| 26 } | |
| 27 } | |
| 28 | |
| 29 void main() { | |
| 30 try { | |
| 31 new SomeClass(); | |
| 32 } on Exception catch (e, st) { | |
| 33 final stString = st.toString(); | |
| 34 Expect.isTrue(stString.contains("new SomeClass")); | |
| 35 Expect.isFalse(stString.contains("SomeClass.")); | |
| 36 } | |
| 37 | |
| 38 try { | |
| 39 new SomeClass.namedConstructor(); | |
| 40 } on Exception catch (e, st) { | |
| 41 final stString = st.toString(); | |
| 42 Expect.isTrue(stString.contains("new SomeClass.namedConstructor")); | |
| 43 } | |
| 44 | |
| 45 try { | |
| 46 new OnlyHasFactory(); | |
| 47 } on Exception catch (e, st) { | |
| 48 final stString = st.toString(); | |
| 49 Expect.isTrue(stString.contains("new OnlyHasFactory")); | |
| 50 Expect.isFalse(stString.contains("OnlyHasFactory.")); | |
| 51 } | |
| 52 | |
| 53 try { | |
| 54 new SomeClass.useFactory(); | |
| 55 } on Exception catch (e, st) { | |
| 56 final stString = st.toString(); | |
| 57 Expect.isTrue(stString.contains("new SomeClass.useFactory")); | |
| 58 } | |
| 59 } | |
| OLD | NEW |