1package sheet23import "testing"45// Formulas reading blank cells of a column, row or sheet whose format6// changes infer their format again at once, not at the next recalc.7func TestLineFormatReinfers(t *testing.T) {8 w := NewBook()9 s := w.Sheets()[0]10 s.Set(at("D1"), "=B5*2")11 s.Set(at("D2"), "=SUM(B7:B9)")12 s.Set(at("D3"), "=C4")13 o, _ := w.AddSheet("Other", 1)14 o.Set(at("A1"), "=Sheet1!B6")15 s.SetFormat(col(1), Preset(FmtCurrency))16 for _, c := range []struct {17 s *Sheet18 a string19 }{{s, "D1"}, {s, "D2"}, {o, "A1"}} {20 if f := c.s.DisplayFormat(at(c.a)); f.Kind != FmtCurrency {21 t.Errorf("%s shows %v after formatting column B, want currency", c.a, f.Kind)22 }23 }24 if f := s.DisplayFormat(at("D3")); !f.IsZero() {25 t.Errorf("D3 shows %v, reading column C", f.Kind)26 }27 s.SetFormat(rowRect(3, 3), Preset(FmtPercent))28 if f := s.DisplayFormat(at("D3")); f.Kind != FmtPercent {29 t.Errorf("D3 shows %v after formatting row 4, want percent", f.Kind)30 }31 s.Undo()32 if f := s.DisplayFormat(at("D3")); !f.IsZero() {33 t.Errorf("D3 shows %v after undo", f.Kind)34 }35 s.SetFormat(Rect{To: Addr{Col: MaxCols - 1, Row: MaxRows - 1}}, Preset(FmtPercent))36 if f := s.DisplayFormat(at("D3")); f.Kind != FmtPercent {37 t.Errorf("D3 shows %v after formatting the sheet, want percent", f.Kind)38 }39}