1package ui23import (4 "regexp"5 "strings"6 "testing"7)89// File > Settings > Decimal arithmetic toggles the setting with a ✓ in10// the menu and "decimal" on the status line, marks the file modified,11// and Ctrl+Z turns it back off.12func TestDecimalSetting(t *testing.T) {13 m := newModel()14 press(t, m, "=0.1+0.2-0.3=0", "<enter>")15 value := func() string { return m.sheet.Value(addr("A1")).String() }16 if value() != "FALSE" {17 t.Fatalf("binary: A1 = %s", value())18 }19 press(t, m, "<alt+f>")20 press(t, m, "<up>", "<up>", "<right>")21 if s := screen(m); !strings.Contains(s, "Decimal arithmetic") || strings.Contains(s, "✓") {22 t.Fatalf("settings submenu:\n%s", s)23 }24 press(t, m, "<enter>")25 if value() != "TRUE" || !strings.Contains(line(m, contextLine), "Decimal arithmetic on") {26 t.Fatalf("on: A1 = %s, context %q", value(), line(m, contextLine))27 }28 last := line(m, m.height-1)29 if !strings.Contains(last, "modified decimal") {30 t.Errorf("status line: %q", last)31 }32 press(t, m, "<alt+f>", "<up>", "<up>", "<right>")33 if !regexp.MustCompile(`Decimal arithmetic +✓`).MatchString(screen(m)) {34 t.Errorf("no check mark:\n%s", screen(m))35 }36 press(t, m, "<esc>", "<esc>", "<ctrl+z>")37 if value() != "FALSE" || m.sheet.Decimal() || strings.Contains(line(m, m.height-1), "decimal") {38 t.Errorf("undo: A1 = %s, decimal %v, status %q", value(), m.sheet.Decimal(), line(m, m.height-1))39 }40}