aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets/microtask.test.js
blob: 18956b1e5a6d3dc34d06f9d5944bed383893bcdd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { it } from "bun:test";

it("queueMicrotask", async () => {
  // You can verify this test is correct by copy pasting this into a browser's console and checking it doesn't throw an error.
  var run = 0;

  await new Promise((resolve, reject) => {
    queueMicrotask(() => {
      if (run++ != 0) {
        reject(new Error("Microtask execution order is wrong: " + run));
      }
      queueMicrotask(() => {
        if (run++ != 3) {
          reject(new Error("Microtask execution order is wrong: " + run));
        }
      });
    });
    queueMicrotask(() => {
      if (run++ != 1) {
        reject(new Error("Microtask execution order is wrong: " + run));
      }
      queueMicrotask(() => {
        if (run++ != 4) {
          reject(new Error("Microtask execution order is wrong: " + run));
        }

        queueMicrotask(() => {
          if (run++ != 6) {
            reject(new Error("Microtask execution order is wrong: " + run));
          }
        });
      });
    });
    queueMicrotask(() => {
      if (run++ != 2) {
        reject(new Error("Microtask execution order is wrong: " + run));
      }
      queueMicrotask(() => {
        if (run++ != 5) {
          reject(new Error("Microtask execution order is wrong: " + run));
        }

        queueMicrotask(() => {
          if (run++ != 7) {
            reject(new Error("Microtask execution order is wrong: " + run));
          }
          resolve(true);
        });
      });
    });
  });

  {
    var passed = false;
    try {
      queueMicrotask(1234);
    } catch (exception) {
      passed = exception instanceof TypeError;
    }

    if (!passed)
      throw new Error(
        "queueMicrotask should throw a TypeError if the argument is not a function"
      );
  }

  {
    var passed = false;
    try {
      queueMicrotask();
    } catch (exception) {
      passed = exception instanceof TypeError;
    }

    if (!passed)
      throw new Error(
        "queueMicrotask should throw a TypeError if the argument is empty"
      );
  }
});
23-09-01Fix background colorGravatar Ashcon Partovi 1-2/+3 2023-09-01Allow older versions of VSCodeGravatar Ashcon Partovi 2-6/+5 2023-09-01Fix README for extensionGravatar Ashcon Partovi 2-7/+12 2023-09-01Update VSCode extensionGravatar Ashcon Partovi 1-3/+4 2023-09-01Fix breakpoint on entry for extensionGravatar Ashcon Partovi 5-18/+15 2023-09-01Add Bun.canReload event to inspectorGravatar Ashcon Partovi 2-0/+17 2023-08-31JavaScript Debug Terminal == Bun TerminalGravatar Ashcon Partovi 1-0/+32 2023-08-31fix(runtime): `fs.cp` edge cases (#4439)Gravatar dave caruso 2-8/+44 * yippee * enable cpSync tests * much better * that doesnt actually do anything * lose 2023-08-31only set initial debugger breakpoint once (#4441)Gravatar Dylan Conway 1-2/+11 * unset `set_breakpoint_on_first_line` on reload * move to `module_loader.zig` 2023-08-31Make breakpoints faster in VSCode extensionGravatar Ashcon Partovi 1-241/+327 2023-08-31`bun install` correctly join dependency URLs (#4421)Gravatar Julian 6-64/+243 * use WTF to join registry strings * show dependency error messages, better join error We actually report errors when enqueuing dependencies now. I also made the join URLs error message read better. It'd be cleaner to handle it all in one place, but there's currently no way to propagate the data up. * starting on registry URL tests * added more registry URL tests * [install] prevent optional/peer deps from failing builds Couldn't get the peer dependency test to work, but the code is there. * ran prettier * changed error note to use realname, updated tests * ran prettier again... 2023-08-31get name if not provided in `FormData.append` (#4434)Gravatar Dylan Conway 4-5/+45 * get file name from blob if not provided * add test * another test * format 2023-08-31Fix vscode debug terminalGravatar Ashcon Partovi 1-21/+0