name:
src/test/js/execution/ExecutorProjectionTest.ts
-rw-r--r--
4704
1import { RefException } from "../../../main/js/errors/RefException";
2import { runner, it, describe } from "../testutils/TestUtils";
3
4describe("Executor.execute - Projection", function () {
5 it("should project row of size 1", function () {
6 runner().addCell("Alpha", "A1", "= {1}").addExpectedValue("Alpha", "A1", 1.0).run();
7 });
8
9 it("should project row of size 2", function () {
10 runner()
11 .addCell("Alpha", "A1", "= {1, 2}")
12 .addCell("Alpha", "Z99", "Setting grid size to be large enough.")
13 .addExpectedValue("Alpha", "A1", 1.0)
14 .addExpectedValue("Alpha", "B1", 2.0)
15 .run();
16 });
17
18 it("should project row of size N", function () {
19 runner()
20 .addCell("Alpha", "A1", "= {1, 2, 3, 4, 5, 6}")
21 .addCell("Alpha", "Z99", "Setting grid size to be large enough.")
22 .addExpectedValue("Alpha", "A1", 1.0)
23 .addExpectedValue("Alpha", "B1", 2.0)
24 .addExpectedValue("Alpha", "C1", 3.0)
25 .addExpectedValue("Alpha", "D1", 4.0)
26 .addExpectedValue("Alpha", "E1", 5.0)
27 .run();
28 });
29
30 it("should project column of size 1", function () {
31 runner().addCell("Alpha", "A1", "= {1}").addExpectedValue("Alpha", "A1", 1.0).run();
32 });
33
34 it("should project column of size 2", function () {
35 runner()
36 .addCell("Alpha", "A1", "= {1;2}")
37 .addCell("Alpha", "Z99", "Setting grid size to be large enough.")
38 .addExpectedValue("Alpha", "A1", 1.0)
39 .addExpectedValue("Alpha", "A2", 2.0)
40 .run();
41 });
42
43 it("should project column of size N", function () {
44 runner()
45 .addCell("Alpha", "A1", "= {1;2;3;4;5;6}")
46 .addCell("Alpha", "Z99", "Setting grid size to be large enough.")
47 .addExpectedValue("Alpha", "A1", 1.0)
48 .addExpectedValue("Alpha", "A2", 2.0)
49 .addExpectedValue("Alpha", "A3", 3.0)
50 .addExpectedValue("Alpha", "A4", 4.0)
51 .addExpectedValue("Alpha", "A5", 5.0)
52 .addExpectedValue("Alpha", "A6", 6.0)
53 .run();
54 });
55
56 it("should project column and row, full grid, column by row", function () {
57 runner()
58 .addCell("Alpha", "A1", "= {{1;2;3},{4;5;6},{7;8;9}}")
59 .addCell("Alpha", "Z99", "Setting grid size to be large enough.")
60 .addExpectedValue("Alpha", "A1", 1.0)
61 .addExpectedValue("Alpha", "A2", 2.0)
62 .addExpectedValue("Alpha", "A3", 3.0)
63 .addExpectedValue("Alpha", "B1", 4.0)
64 .addExpectedValue("Alpha", "B2", 5.0)
65 .addExpectedValue("Alpha", "B3", 6.0)
66 .addExpectedValue("Alpha", "C1", 7.0)
67 .addExpectedValue("Alpha", "C2", 8.0)
68 .addExpectedValue("Alpha", "C3", 9.0)
69 .run();
70 });
71
72 it("should project column and row, full grid, row by column", function () {
73 runner()
74 .addCell("Alpha", "A1", "= {{1,2,3};{4,5,6};{7,8,9}}")
75 .addCell("Alpha", "Z99", "Setting grid size to be large enough.")
76 .addExpectedValue("Alpha", "A1", 1.0)
77 .addExpectedValue("Alpha", "A2", 4.0)
78 .addExpectedValue("Alpha", "A3", 7.0)
79 .addExpectedValue("Alpha", "B1", 2.0)
80 .addExpectedValue("Alpha", "B2", 5.0)
81 .addExpectedValue("Alpha", "B3", 8.0)
82 .addExpectedValue("Alpha", "C1", 3.0)
83 .addExpectedValue("Alpha", "C2", 6.0)
84 .addExpectedValue("Alpha", "C3", 9.0)
85 .run();
86 });
87
88 it("should do projection from a range", function () {
89 runner()
90 .addCell("Alpha", "A1", "= 11.1")
91 .addCell("Alpha", "A2", "= 22.2")
92 .addCell("Alpha", "A3", "= 33.3")
93 .addCell("Alpha", "M1", "= {A1:A3}")
94 .addCell("Alpha", "Z99", "Setting grid size to be large enough.")
95 .addExpectedValue("Alpha", "M1", 11.1)
96 .addExpectedValue("Alpha", "M2", 22.2)
97 .addExpectedValue("Alpha", "M3", 33.3)
98 .run();
99 });
100
101 it("should return REF error if projection would collide with existing values", function () {
102 runner()
103 .addCell("Alpha", "A1", "= {1, 2}")
104 .addCell("Alpha", "B1", '= "Don\'t tread on me."')
105 .addExpectedValue("Alpha", "A1", new RefException())
106 .addExpectedValue("Alpha", "B1", "Don't tread on me.")
107 .run();
108 runner()
109 .addCell("Alpha", "A1", "= {{1,2,3};{4,5,6};{7,8,9}}")
110 .addCell("Alpha", "B2", '= "Don\'t tread on me."')
111 .addCell("Alpha", "Z99", "Setting grid size to be large enough.")
112 .addExpectedValue("Alpha", "A1", new RefException())
113 .addExpectedEmptyValue("Alpha", "A2")
114 .addExpectedEmptyValue("Alpha", "A3")
115 .addExpectedEmptyValue("Alpha", "B1")
116 .addExpectedValue("Alpha", "B2", "Don't tread on me.")
117 .addExpectedEmptyValue("Alpha", "B3")
118 .addExpectedEmptyValue("Alpha", "C1")
119 .addExpectedEmptyValue("Alpha", "C2")
120 .addExpectedEmptyValue("Alpha", "c3")
121 .run();
122 });
123});