name:
src/test/java/io/protobase/f7/spreadsheet/GeneralDependencyCheckingTest.java
-rw-r--r--
2752
1package io.protobase.f7.spreadsheet;
2
3import io.protobase.f7.errors.RefException;
4import io.protobase.f7.testutils.TestExecution;
5import org.junit.Test;
6
7public class GeneralDependencyCheckingTest extends TestExecution {
8 @Test
9 public void test_CycleFromSelfReferenceLoop() {
10 runner()
11 .addCell("Alpha", "J2", "= J2 + 10")
12 .addExpectedValue("Alpha", "J2", new RefException())
13 .run();
14 }
15
16 @Test
17 public void test_CycleFromDirectLoopback() {
18 runner()
19 .addCell("Alpha", "A1", "= J2 + 1")
20 .addCell("Alpha", "J2", "= A1 + 1")
21 .addExpectedValue("Alpha", "A1", new RefException())
22 .addExpectedValue("Alpha", "J2", new RefException())
23 .run();
24 }
25
26 @Test
27 public void test_CycleFromIndirectLoopback() {
28 runner()
29 .addCell("Alpha", "A1", "= J2 + 1")
30 .addCell("Alpha", "J2", "= D8 + 1")
31 .addCell("Alpha", "D8", "= A1 + 1")
32 .addExpectedValue("Alpha", "A1", new RefException())
33 .addExpectedValue("Alpha", "J2", new RefException())
34 .addExpectedValue("Alpha", "D8", new RefException())
35 .run();
36 runner()
37 .addCell("Alpha", "D4", "= A1 + 1")
38 .addCell("Alpha", "A2", "= D4 + 1")
39 .addCell("Alpha", "A1", "= A2 + 1")
40 .addExpectedValue("Alpha", "D4", new RefException())
41 .addExpectedValue("Alpha", "A2", new RefException())
42 .addExpectedValue("Alpha", "A1", new RefException())
43 .run();
44 }
45
46 @Test
47 public void test_CycleFromDirectLoopbackWithNamedGrid() {
48 runner()
49 .addCell("Alpha", "A1", "= Beta!J2 + 1")
50 .addCell("Beta", "J2", "= Alpha!A1 + 1")
51 .addExpectedValue("Alpha", "A1", new RefException())
52 .addExpectedValue("Beta", "J2", new RefException())
53 .run();
54 }
55
56 @Test
57 public void test_CycleFromIndirectLoopbackWithNamedGrid() {
58 runner()
59 .addCell("Alpha", "A1", "= Beta!J2 + 1")
60 .addCell("Beta", "J2", "= Charlie!D8 + 1")
61 .addCell("Charlie", "D8", "= Alpha!A1 + 1")
62 .addExpectedValue("Alpha", "A1", new RefException())
63 .addExpectedValue("Beta", "J2", new RefException())
64 .addExpectedValue("Charlie", "D8", new RefException())
65 .run();
66 }
67
68 @Test
69 public void test_CycleFromRangeThatContainsSelf() {
70 runner()
71 .addCell("Alpha", "A4", "= {A1:A8}")
72 .addExpectedValue("Alpha", "A4", new RefException())
73 .run();
74 }
75
76 @Test
77 public void test_CycleFromRangeThatContainsIndirectDependency() {
78 runner()
79 .addCell("Alpha", "A1", "= D10")
80 .addCell("Alpha", "D10", "= {A1:A2}")
81 .addExpectedValue("Alpha", "A1", new RefException())
82 .addExpectedValue("Alpha", "D10", new RefException())
83 .run();
84 }
85}