aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets/bun-jsc.test.js
blob: 975003b775a82aa9b9c33243d7a8c6916dc7aa1f (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { describe, expect, it } from "bun:test";
import {
  describe as jscDescribe,
  describeArray,
  gcAndSweep,
  fullGC,
  edenGC,
  heapSize,
  heapStats,
  memoryUsage,
  getRandomSeed,
  setRandomSeed,
  isRope,
  callerSourceOrigin,
  noFTL,
  noOSRExitFuzzing,
  optimizeNextInvocation,
  numberOfDFGCompiles,
  releaseWeakRefs,
  totalCompileTime,
  reoptimizationRetryCount,
  drainMicrotasks,
} from "bun:jsc";

describe("bun:jsc", () => {
  function count() {
    var j = 0;
    for (var i = 0; i < 999999; i++) {
      j += i + 2;
    }

    return j;
  }

  it("describe", () => {
    jscDescribe([]);
  });
  it("describeArray", () => {
    describeArray([1, 2, 3]);
  });
  it("gcAndSweep", () => {
    gcAndSweep();
  });
  it("fullGC", () => {
    fullGC();
  });
  it("edenGC", () => {
    edenGC();
  });
  it("heapSize", () => {
    expect(heapSize() > 0).toBe(true);
  });
  it("heapStats", () => {
    heapStats();
  });
  it("memoryUsage", () => {
    memoryUsage();
  });
  it("getRandomSeed", () => {
    getRandomSeed(2);
  });
  it("setRandomSeed", () => {
    setRandomSeed(2);
  });
  it("isRope", () => {
    expect(isRope("a" + 123 + "b")).toBe(true);
    expect(isRope("abcdefgh")).toBe(false);
  });
  it("callerSourceOrigin", () => {
    expect(callerSourceOrigin()).toBe(import.meta.url);
  });
  it("noFTL", () => {});
  it("noOSRExitFuzzing", () => {});
  it("optimizeNextInvocation", () => {
    count();
    optimizeNextInvocation(count);
    count();
  });
  it("numberOfDFGCompiles", () => {
    expect(numberOfDFGCompiles(count) > 0).toBe(true);
  });
  it("releaseWeakRefs", () => {
    releaseWeakRefs();
  });
  it("totalCompileTime", () => {
    totalCompileTime(count);
  });
  it("reoptimizationRetryCount", () => {
    reoptimizationRetryCount(count);
  });
  it("drainMicrotasks", () => {
    drainMicrotasks();
  });
});