f7
f7 is a spreadsheet formula execution library
git clone https://git.vogt.world/f7.git
Log | Files | README.md | LICENSE.md
← All files
name: src/test/js/execution/ExecutorNumberTest.ts
-rw-r--r--
2575
 1import { runner, it, describe } from "../testutils/TestUtils";
 2
 3describe("Executor.execute - Number", function () {
 4  it("should work with integers", function () {
 5    runner().addCell("Alpha", "A1", "= 0").addExpectedValue("Alpha", "A1", 0.0).run();
 6    runner().addCell("Alpha", "A1", "= 1").addExpectedValue("Alpha", "A1", 1.0).run();
 7    runner().addCell("Alpha", "A1", "= 2738281").addExpectedValue("Alpha", "A1", 2738281.0).run();
 8    runner().addCell("Alpha", "A1", "= 0001776").addExpectedValue("Alpha", "A1", 1776.0).run();
 9  });
10
11  it("should work with decimals", function () {
12    runner().addCell("Alpha", "A1", "= 0.0").addExpectedValue("Alpha", "A1", 0.0).run();
13    runner().addCell("Alpha", "A1", "= 0.187328").addExpectedValue("Alpha", "A1", 0.187328).run();
14    runner()
15      .addCell("Alpha", "A1", "= 38133.09128901")
16      .addExpectedValue("Alpha", "A1", 38133.09128901)
17      .run();
18    runner()
19      .addCell("Alpha", "A1", "= 4.00000000000001")
20      .addExpectedValue("Alpha", "A1", 4.00000000000001)
21      .run();
22    runner()
23      .addCell("Alpha", "A1", "= 33.0000000000000")
24      .addExpectedValue("Alpha", "A1", 33.0)
25      .run();
26  });
27
28  it("should work with inferred positive scientific notation", function () {
29    runner().addCell("Alpha", "A1", "= 12387e0").addExpectedValue("Alpha", "A1", 12387.0).run();
30    runner().addCell("Alpha", "A1", "= 12387e1").addExpectedValue("Alpha", "A1", 123870.0).run();
31    runner().addCell("Alpha", "A1", "= 1.0e4").addExpectedValue("Alpha", "A1", 10000.0).run();
32    runner().addCell("Alpha", "A1", "= 0.0009e4").addExpectedValue("Alpha", "A1", 9.0).run();
33  });
34
35  it("should work with positive scientific notation", function () {
36    runner().addCell("Alpha", "A1", "= 12387e+0").addExpectedValue("Alpha", "A1", 12387.0).run();
37    runner().addCell("Alpha", "A1", "= 12387e+1").addExpectedValue("Alpha", "A1", 123870.0).run();
38    runner().addCell("Alpha", "A1", "= 1.0e+4").addExpectedValue("Alpha", "A1", 10000.0).run();
39    runner().addCell("Alpha", "A1", "= 0.0009e+4").addExpectedValue("Alpha", "A1", 9.0).run();
40  });
41
42  it("should work with negative scientific notation", function () {
43    runner().addCell("Alpha", "A1", "= 12387e-0").addExpectedValue("Alpha", "A1", 12387).run();
44    runner().addCell("Alpha", "A1", "= 12387e-1").addExpectedValue("Alpha", "A1", 12387e-1).run();
45    runner().addCell("Alpha", "A1", "= 1.0e-4").addExpectedValue("Alpha", "A1", 1.0e-4).run();
46    runner().addCell("Alpha", "A1", "= 0.0009e-4").addExpectedValue("Alpha", "A1", 0.0009e-4).run();
47  });
48});