• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1describe("unittests:: evaluation:: updateExpressionInModule", () => {
2    // only run BigInt tests if BigInt is supported in the host environment
3    const itIfBigInt = typeof BigInt === "function" ? it : it.skip;
4
5    it("pre-increment in commonjs using Number", () => {
6        const result = evaluator.evaluateTypeScript({
7            files: {
8                "/.src/main.ts": `
9                let a = 1;
10                export { a };
11                export const b = ++a;
12                `
13            },
14            rootFiles: ["/.src/main.ts"],
15            main: "/.src/main.ts"
16        }, { module: ts.ModuleKind.CommonJS });
17        assert.equal(result.a, 2);
18        assert.equal(result.b, 2);
19    });
20    it("pre-increment in System using Number", () => {
21        const result = evaluator.evaluateTypeScript({
22            files: {
23                "/.src/main.ts": `
24                let a = 1;
25                export { a };
26                export const b = ++a;
27                `
28            },
29            rootFiles: ["/.src/main.ts"],
30            main: "/.src/main.ts"
31        }, { module: ts.ModuleKind.System });
32        assert.equal(result.a, 2);
33        assert.equal(result.b, 2);
34    });
35    itIfBigInt("pre-increment in commonjs using BigInt", () => {
36        const result = evaluator.evaluateTypeScript({
37            files: {
38                "/.src/main.ts": `
39                let a = BigInt(1);
40                export { a };
41                export const b = ++a;
42                `
43            },
44            rootFiles: ["/.src/main.ts"],
45            main: "/.src/main.ts"
46        }, { module: ts.ModuleKind.CommonJS }, { BigInt });
47        assert.equal(result.a, BigInt(2));
48        assert.equal(result.b, BigInt(2));
49    });
50    itIfBigInt("pre-increment in System using BigInt", () => {
51        const result = evaluator.evaluateTypeScript({
52            files: {
53                "/.src/main.ts": `
54                let a = BigInt(1);
55                export { a };
56                export const b = ++a;
57                `
58            },
59            rootFiles: ["/.src/main.ts"],
60            main: "/.src/main.ts"
61        }, { module: ts.ModuleKind.System }, { BigInt });
62        assert.equal(result.a, BigInt(2));
63        assert.equal(result.b, BigInt(2));
64    });
65    it("post-increment in commonjs using Number", () => {
66        const result = evaluator.evaluateTypeScript({
67            files: {
68                "/.src/main.ts": `
69                let a = 1;
70                export { a };
71                export const b = a++;
72                `
73            },
74            rootFiles: ["/.src/main.ts"],
75            main: "/.src/main.ts"
76        }, { module: ts.ModuleKind.CommonJS });
77        assert.equal(result.a, 2);
78        assert.equal(result.b, 1);
79    });
80    it("post-increment in System using Number", () => {
81        const result = evaluator.evaluateTypeScript({
82            files: {
83                "/.src/main.ts": `
84                let a = 1;
85                export { a };
86                export const b = a++;
87                `
88            },
89            rootFiles: ["/.src/main.ts"],
90            main: "/.src/main.ts"
91        }, { module: ts.ModuleKind.System });
92        assert.equal(result.a, 2);
93        assert.equal(result.b, 1);
94    });
95    itIfBigInt("post-increment in commonjs using BigInt", () => {
96        const result = evaluator.evaluateTypeScript({
97            files: {
98                "/.src/main.ts": `
99                let a = BigInt(1);
100                export { a };
101                export const b = a++;
102                `
103            },
104            rootFiles: ["/.src/main.ts"],
105            main: "/.src/main.ts"
106        }, { module: ts.ModuleKind.CommonJS }, { BigInt });
107        assert.equal(result.a, BigInt(2));
108        assert.equal(result.b, BigInt(1));
109    });
110    itIfBigInt("post-increment in System using BigInt", () => {
111        const result = evaluator.evaluateTypeScript({
112            files: {
113                "/.src/main.ts": `
114                let a = BigInt(1);
115                export { a };
116                export const b = a++;
117                `
118            },
119            rootFiles: ["/.src/main.ts"],
120            main: "/.src/main.ts"
121        }, { module: ts.ModuleKind.System }, { BigInt });
122        assert.equal(result.a, BigInt(2));
123        assert.equal(result.b, BigInt(1));
124    });
125});