Home / File/ transform-prevent-infinite-loops-test.js — react Source File

transform-prevent-infinite-loops-test.js — react Source File

Architecture documentation for transform-prevent-infinite-loops-test.js, a javascript file in the react codebase.

Entity Profile

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
'use strict';

describe('transform-prevent-infinite-loops', () => {
  // Note: instead of testing the transform by applying it,
  // we assume that it *is* already applied. Since we expect
  // it to be applied to all our tests.

  it('fails the test for `while` loops', () => {
    expect(global.infiniteLoopError).toBe(null);
    expect(() => {
      while (true) {
        // do nothing
      }
    }).toThrow(RangeError);
    // Make sure this gets set so the test would fail regardless.
    expect(global.infiniteLoopError).not.toBe(null);
    // Clear the flag since otherwise *this* test would fail.
    global.infiniteLoopError = null;
  });

  it('fails the test for `for` loops', () => {
    expect(global.infiniteLoopError).toBe(null);
    expect(() => {
      for (;;) {
        // do nothing
      }
    }).toThrow(RangeError);
    // Make sure this gets set so the test would fail regardless.
    expect(global.infiniteLoopError).not.toBe(null);
    // Clear the flag since otherwise *this* test would fail.
    global.infiniteLoopError = null;
  });
});

Frequently Asked Questions

What does transform-prevent-infinite-loops-test.js do?
transform-prevent-infinite-loops-test.js is a source file in the react codebase, written in javascript.
Where is transform-prevent-infinite-loops-test.js in the architecture?
transform-prevent-infinite-loops-test.js is located at scripts/babel/__tests__/transform-prevent-infinite-loops-test.js (directory: scripts/babel/__tests__).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free