function-nesting.js 423 B

123456789101112131415
  1. test("issue #6766, nested functions should not leak to global object", () => {
  2. function foo() {
  3. function bar() {
  4. function baz() {
  5. return 42;
  6. }
  7. return baz();
  8. }
  9. return bar();
  10. }
  11. expect(foo()).toBe(42);
  12. expect(globalThis.foo).toBeUndefined();
  13. expect(globalThis.bar).toBeUndefined();
  14. expect(globalThis.baz).toBeUndefined();
  15. });