|
| 1 | +import 'package:parameterized_test/src/errors/stack_trace_extension.dart'; |
| 2 | +import 'package:stack_trace/stack_trace.dart'; |
| 3 | +import 'package:test/test.dart'; |
| 4 | + |
| 5 | +void main() { |
| 6 | + test('StackTrace with no other call then core or parameterized_test', () { |
| 7 | + final stackTrace = Trace.parse(''' |
| 8 | +#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5) |
| 9 | +#1 _objectNoSuchMethod (dart:core-patch/object_patch.dart:85:9) |
| 10 | +#2 Function._apply (dart:core-patch/function_patch.dart:11:71) |
| 11 | +#3 Function.apply (dart:core-patch/function_patch.dart:35:12) |
| 12 | +#4 ParameterizedTestImpl.call.<anonymous closure>.<anonymous closure> (package:parameterized_test/src/parameterized_test.dart:162:33) |
| 13 | +#5 TestHelper.test (file:///parameterized_test/test/test_helpers.dart:31:9) |
| 14 | +#6 ParameterizedTestImpl.call.<anonymous closure> (package:parameterized_test/src/parameterized_test.dart:158:16) |
| 15 | +#7 TestHelper.test (file:///parameterized_test/test/test_helpers.dart:31:9) |
| 16 | +#8 ParameterizedTestImpl.call (package:parameterized_test/src/parameterized_test.dart:140:11) |
| 17 | +#9 main.<anonymous closure>.<anonymous closure>.<anonymous closure> (file:///parameterized_test/test/parameterized_test_test.dart:380:18) |
| 18 | +#10 Throws.matchAsync (package:matcher/src/expect/throws_matcher.dart:86:23) |
| 19 | +#11 _expect (package:matcher/src/expect/expect.dart:109:26) |
| 20 | +#12 expect (package:matcher/src/expect/expect.dart:56:3) |
| 21 | +#13 main.<anonymous closure>.<anonymous closure> (file:///parameterized_test/test/parameterized_test_test.dart:378:7) |
| 22 | +#14 Declarer.test.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:215:19) |
| 23 | +<asynchronous suspension> |
| 24 | +#15 Declarer.test.<anonymous closure> (package:test_api/src/backend/declarer.dart:213:7) |
| 25 | +<asynchronous suspension> |
| 26 | +#16 Invoker._waitForOutstandingCallbacks.<anonymous closure> (package:test_api/src/backend/invoker.dart:258:9) |
| 27 | +<asynchronous suspension> |
| 28 | + '''); |
| 29 | + |
| 30 | + final result = stackTrace.isInsideTestBody; |
| 31 | + |
| 32 | + expect(result, isFalse); |
| 33 | + }); |
| 34 | + |
| 35 | + test( |
| 36 | + 'StackTrace with multiple no other call then core or parameterized_test', |
| 37 | + () { |
| 38 | + final stackTrace = Trace.parse(''' |
| 39 | +#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5) |
| 40 | +#1 _objectNoSuchMethod (dart:core-patch/object_patch.dart:85:9) |
| 41 | +#2 Function._apply (dart:core-patch/function_patch.dart:11:71) |
| 42 | +#3 Function.apply (dart:core-patch/function_patch.dart:35:12) |
| 43 | +#4 ParameterizedTestImpl.call.<anonymous closure>.<anonymous closure> (package:parameterized_test/src/parameterized_test.dart:162:33) |
| 44 | +#5 Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5) |
| 45 | +#6 _objectNoSuchMethod (dart:core-patch/object_patch.dart:85:9) |
| 46 | +#7 Function._apply (dart:core-patch/function_patch.dart:11:71) |
| 47 | +#8 Function.apply (dart:core-patch/function_patch.dart:35:12) |
| 48 | +#9 ParameterizedTestImpl.call.<anonymous closure>.<anonymous closure> (package:parameterized_test/src/parameterized_test.dart:162:33) |
| 49 | + '''); |
| 50 | + |
| 51 | + final result = stackTrace.isInsideTestBody; |
| 52 | + |
| 53 | + expect(result, isFalse); |
| 54 | + }, |
| 55 | + ); |
| 56 | + |
| 57 | + test( |
| 58 | + 'StackTrace with no function.apply call', |
| 59 | + () { |
| 60 | + final stackTrace = Trace.parse(''' |
| 61 | +#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5) |
| 62 | +#1 _objectNoSuchMethod (dart:core-patch/object_patch.dart:85:9) |
| 63 | +#2 ParameterizedTestImpl.call.<anonymous closure>.<anonymous closure> (package:parameterized_test/src/parameterized_test.dart:162:33) |
| 64 | +#3 Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5) |
| 65 | +#4 _objectNoSuchMethod (dart:core-patch/object_patch.dart:85:9) |
| 66 | +#5 ParameterizedTestImpl.call.<anonymous closure>.<anonymous closure> (package:parameterized_test/src/parameterized_test.dart:162:33) |
| 67 | + '''); |
| 68 | + |
| 69 | + final result = stackTrace.isInsideTestBody; |
| 70 | + |
| 71 | + expect(result, isFalse); |
| 72 | + }, |
| 73 | + ); |
| 74 | + |
| 75 | + test( |
| 76 | + 'StackTrace with no parameterized_test call', |
| 77 | + () { |
| 78 | + final stackTrace = Trace.parse(''' |
| 79 | +#0 ParameterizedTestImpl.call.<anonymous closure>.<anonymous closure> (package:parameterized_test/src/parameterized_test.dart:162:33) |
| 80 | +#1 ParameterizedTestImpl.call.<anonymous closure>.<anonymous closure> (package:parameterized_test/src/parameterized_test.dart:162:33) |
| 81 | +'''); |
| 82 | + |
| 83 | + final result = stackTrace.isInsideTestBody; |
| 84 | + |
| 85 | + expect(result, isFalse); |
| 86 | + }, |
| 87 | + ); |
| 88 | + |
| 89 | + test( |
| 90 | + 'StackTrace with other call then core or parameterized_test ' |
| 91 | + 'before function.apply', |
| 92 | + () { |
| 93 | + final stackTrace = Trace.parse(''' |
| 94 | +#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5) |
| 95 | +#1 _objectNoSuchMethod (dart:core-patch/object_patch.dart:85:9) |
| 96 | +#2 main.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (file:///parameterized_test/test/parameterized_test_test.dart:490:31) |
| 97 | +#3 Function._apply (dart:core-patch/function_patch.dart:11:71) |
| 98 | +#4 Function.apply (dart:core-patch/function_patch.dart:35:12) |
| 99 | +#5 ParameterizedTestImpl.call.<anonymous closure>.<anonymous closure> (package:parameterized_test/src/parameterized_test.dart:162:33) |
| 100 | + '''); |
| 101 | + |
| 102 | + final result = stackTrace.isInsideTestBody; |
| 103 | + |
| 104 | + expect(result, isTrue); |
| 105 | + }, |
| 106 | + ); |
| 107 | + |
| 108 | + test( |
| 109 | + 'StackTrace with multiple other call then core or parameterized_test ' |
| 110 | + 'before function.apply', |
| 111 | + () { |
| 112 | + final stackTrace = Trace.parse(''' |
| 113 | +#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5) |
| 114 | +#1 main.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (file:///parameterized_test/test/parameterized_test_test.dart:490:31) |
| 115 | +#2 _objectNoSuchMethod (dart:core-patch/object_patch.dart:85:9) |
| 116 | +#3 main.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (file:///parameterized_test/test/parameterized_test_test.dart:490:31) |
| 117 | +#4 Function._apply (dart:core-patch/function_patch.dart:11:71) |
| 118 | +#5 Function.apply (dart:core-patch/function_patch.dart:35:12) |
| 119 | +#6 ParameterizedTestImpl.call.<anonymous closure>.<anonymous closure> (package:parameterized_test/src/parameterized_test.dart:162:33) |
| 120 | + '''); |
| 121 | + |
| 122 | + final result = stackTrace.isInsideTestBody; |
| 123 | + |
| 124 | + expect(result, isTrue); |
| 125 | + }, |
| 126 | + ); |
| 127 | + |
| 128 | + test( |
| 129 | + 'StackTrace with multiple other call then core or parameterized_test ' |
| 130 | + 'before function.apply', |
| 131 | + () { |
| 132 | + final stackTrace = Trace.parse(''' |
| 133 | +#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5) |
| 134 | +#1 main.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (file:///parameterized_test/test/parameterized_test_test.dart:490:31) |
| 135 | +#2 Function._apply (dart:core-patch/function_patch.dart:11:71) |
| 136 | +#3 Function.apply (dart:core-patch/function_patch.dart:35:12) |
| 137 | +#4 _objectNoSuchMethod (dart:core-patch/object_patch.dart:85:9) |
| 138 | +#5 main.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (file:///parameterized_test/test/parameterized_test_test.dart:490:31) |
| 139 | +#6 Function._apply (dart:core-patch/function_patch.dart:11:71) |
| 140 | +#7 Function.apply (dart:core-patch/function_patch.dart:35:12) |
| 141 | +#8 ParameterizedTestImpl.call.<anonymous closure>.<anonymous closure> (package:parameterized_test/src/parameterized_test.dart:162:33) |
| 142 | + '''); |
| 143 | + |
| 144 | + final result = stackTrace.isInsideTestBody; |
| 145 | + |
| 146 | + expect(result, isTrue); |
| 147 | + }, |
| 148 | + ); |
| 149 | + |
| 150 | + test( |
| 151 | + 'StackTrace with multiple other call then core or parameterized_test ' |
| 152 | + 'after function.apply', |
| 153 | + () { |
| 154 | + final stackTrace = Trace.parse(''' |
| 155 | +#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5) |
| 156 | +#1 _objectNoSuchMethod (dart:core-patch/object_patch.dart:85:9) |
| 157 | +#2 Function._apply (dart:core-patch/function_patch.dart:11:71) |
| 158 | +#3 Function.apply (dart:core-patch/function_patch.dart:35:12) |
| 159 | +#4 ParameterizedTestImpl.call.<anonymous closure>.<anonymous closure> (package:parameterized_test/src/parameterized_test.dart:162:33) |
| 160 | +#5 main.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (file:///parameterized_test/test/parameterized_test_test.dart:490:31) |
| 161 | +#6 main.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (file:///parameterized_test/test/parameterized_test_test.dart:490:31) |
| 162 | + '''); |
| 163 | + |
| 164 | + final result = stackTrace.isInsideTestBody; |
| 165 | + |
| 166 | + expect(result, isFalse); |
| 167 | + }, |
| 168 | + ); |
| 169 | + |
| 170 | + test('empty stack trace', () { |
| 171 | + const stackTrace = StackTrace.empty; |
| 172 | + |
| 173 | + final result = stackTrace.isInsideTestBody; |
| 174 | + |
| 175 | + expect(result, isFalse); |
| 176 | + }); |
| 177 | +} |
0 commit comments