MCPcopy Index your code
hub / github.com/angular/angular / testFn

Function testFn

packages/zone.js/test/common/Error.spec.ts:220–303  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

218
219 rootZone.run(testFn);
220 function testFn() {
221 let outside: any;
222 let inside: any;
223 let outsideWithoutNew: any;
224 let insideWithoutNew: any;
225 try {
226 throw new Error('Outside');
227 } catch (e) {
228 outside = e;
229 }
230 try {
231 throw Error('Outside');
232 } catch (e) {
233 outsideWithoutNew = e;
234 }
235 innerZone.run(function insideRun() {
236 try {
237 throw new Error('Inside');
238 } catch (e) {
239 inside = e;
240 }
241 try {
242 throw Error('Inside');
243 } catch (e) {
244 insideWithoutNew = e;
245 }
246 });
247
248 if (policy === 'lazy') {
249 outside.stack = outside.zoneAwareStack;
250 outsideWithoutNew.stack = outsideWithoutNew.zoneAwareStack;
251 inside.stack = inside.zoneAwareStack;
252 insideWithoutNew.stack = insideWithoutNew.zoneAwareStack;
253 }
254
255 expect(outside.stack).toEqual(outside.zoneAwareStack);
256 expect(outsideWithoutNew.stack).toEqual(outsideWithoutNew.zoneAwareStack);
257 expect(inside!.stack).toEqual(inside!.zoneAwareStack);
258 expect(insideWithoutNew!.stack).toEqual(insideWithoutNew!.zoneAwareStack);
259 expect(typeof inside!.originalStack).toEqual('string');
260 expect(typeof insideWithoutNew!.originalStack).toEqual('string');
261 const outsideFrames = outside.stack!.split(/\n/);
262 const insideFrames = inside!.stack!.split(/\n/);
263 const outsideWithoutNewFrames = outsideWithoutNew!.stack!.split(/\n/);
264 const insideWithoutNewFrames = insideWithoutNew!.stack!.split(/\n/);
265
266 // throw away first line if it contains the error
267 if (/Outside/.test(outsideFrames[0])) {
268 outsideFrames.shift();
269 }
270 if (/Error /.test(outsideFrames[0])) {
271 outsideFrames.shift();
272 }
273
274 if (/Outside/.test(outsideWithoutNewFrames[0])) {
275 outsideWithoutNewFrames.shift();
276 }
277 if (/Error /.test(outsideWithoutNewFrames[0])) {

Callers 2

fnPromiseFunction · 0.50
testFunction · 0.50

Calls 3

ErrorInterface · 0.85
runMethod · 0.65
testMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…