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/ExecutorConcatenationTest.ts
-rw-r--r--
2400
 1import { DivException } from "../../../main/js/errors/DivException";
 2import { runner, it, describe } from "../testutils/TestUtils";
 3
 4describe("Executor.execute - Concatenation", function () {
 5  it("should work with strings", function () {
 6    runner()
 7      .addCell("Alpha", "A1", '= "Hello" & "There"')
 8      .addExpectedValue("Alpha", "A1", "HelloThere")
 9      .run();
10    runner()
11      .addCell("Alpha", "A1", '= "Hello" & ""')
12      .addExpectedValue("Alpha", "A1", "Hello")
13      .run();
14    runner().addCell("Alpha", "A1", '= "" & ""').addExpectedValue("Alpha", "A1", "").run();
15    runner()
16      .addCell("Alpha", "A1", '= "   " & "   "')
17      .addExpectedValue("Alpha", "A1", "      ")
18      .run();
19  });
20
21  it("should work with numbers", function () {
22    runner().addCell("Alpha", "A1", "= 0 & 1").addExpectedValue("Alpha", "A1", "01").run();
23    runner().addCell("Alpha", "A1", "= 0 & 0").addExpectedValue("Alpha", "A1", "00").run();
24    runner()
25      .addCell("Alpha", "A1", "= 131238 & 99281")
26      .addExpectedValue("Alpha", "A1", "13123899281")
27      .run();
28    runner()
29      .addCell("Alpha", "A1", "= 13.1238 & 99281")
30      .addExpectedValue("Alpha", "A1", "13.123899281")
31      .run();
32    runner()
33      .addCell("Alpha", "A1", "= 0.001 & 1.0")
34      .addExpectedValue("Alpha", "A1", "0.0011")
35      .run();
36  });
37
38  it("should work with booleans", function () {
39    runner()
40      .addCell("Alpha", "A1", "= TRUE & TRUE")
41      .addExpectedValue("Alpha", "A1", "TRUETRUE")
42      .run();
43    runner()
44      .addCell("Alpha", "A1", "= TRUE & FALSE")
45      .addExpectedValue("Alpha", "A1", "TRUEFALSE")
46      .run();
47    runner()
48      .addCell("Alpha", "A1", "= FALSE & FALSE")
49      .addExpectedValue("Alpha", "A1", "FALSEFALSE")
50      .run();
51  });
52
53  it("should return errors when encountered", function () {
54    runner()
55      .addCell("Alpha", "A1", "= 1 & #DIV/0!")
56      .addExpectedValue("Alpha", "A1", new DivException())
57      .run();
58  });
59
60  it("should work with array literals", function () {
61    runner().addCell("Alpha", "A1", "= {1} & {2}").addExpectedValue("Alpha", "A1", "12").run();
62    runner()
63      .addCell("Alpha", "A1", "= {1, 2, 3} & {4, 5, 6}")
64      .addExpectedValue("Alpha", "A1", "14")
65      .run();
66    runner()
67      .addCell("Alpha", "A1", "= {1, #NUM!} & {4, #REF!}")
68      .addExpectedValue("Alpha", "A1", "14")
69      .run();
70  });
71});