@@ -18,44 +18,55 @@ public static int Main()
18
18
19
19
public void RunTest ( )
20
20
{
21
- CreateAndThrow ( ) ;
21
+ CreateAndThrow ( ) ;
22
22
}
23
23
24
24
public void CreateAndThrow ( )
25
25
{
26
- string currStack ;
27
-
26
+ string currStack ;
27
+
28
28
try
29
29
{
30
- throw new Exception ( ) ;
30
+ throw new Exception ( ) ;
31
+ }
32
+ catch ( Exception e )
33
+ {
34
+ currStack = e . StackTrace ;
31
35
}
32
- catch ( Exception e )
33
- {
34
- currStack = e . StackTrace ;
35
- }
36
-
36
+
37
37
try
38
- {
38
+ {
39
39
Guid [ ] g = new Guid [ Int32 . MaxValue ] ;
40
40
}
41
41
catch ( OutOfMemoryException e )
42
42
{
43
43
retVal = 100 ;
44
-
45
- Console . WriteLine ( "Caught OOM" ) ;
46
44
47
- if ( e . StackTrace . ToString ( ) . Substring ( 0 , e . StackTrace . Length - 8 ) != currStack . Substring ( 0 , currStack . Length - 8 ) )
48
- {
49
- Console . WriteLine ( "Actual Exception Stack Trace:" ) ;
45
+ Console . WriteLine ( "Caught OOM" ) ;
46
+
47
+ string oomStack = e . StackTrace ;
48
+ string expectedStack = currStack ;
49
+
50
+ if ( oomStack . IndexOf ( ':' ) != - 1 )
51
+ {
52
+ oomStack = oomStack . Substring ( 0 , oomStack . IndexOf ( ':' ) - 1 ) ;
53
+ }
54
+
55
+ if ( expectedStack . IndexOf ( ':' ) != - 1 )
56
+ {
57
+ expectedStack = expectedStack . Substring ( 0 , expectedStack . IndexOf ( ':' ) - 1 ) ;
58
+ }
59
+
60
+ if ( oomStack != expectedStack )
61
+ {
62
+ Console . WriteLine ( "Actual Exception Stack Trace:" ) ;
50
63
Console . WriteLine ( e . StackTrace ) ;
51
64
Console . WriteLine ( ) ;
52
- Console . WriteLine ( "Expected Stack Trace:" ) ;
53
- Console . WriteLine ( currStack . ToString ( ) ) ;
65
+ Console . WriteLine ( "Expected Stack Trace:" ) ;
66
+ Console . WriteLine ( currStack . ToString ( ) ) ;
54
67
retVal = 50 ;
55
68
}
56
69
}
57
-
58
70
}
59
-
60
71
}
61
72
0 commit comments