cat / 012
clone

a spreadsheet for the terminal: lotus 1-2-3 looks, google sheets keys and formulas, one go binary

main
012 / e2e / arrays_test.go
arrays_test.go 1.8K
1package e2e23import (4 "strings"5 "testing"6)78// An array formula spills, its spilled cells refuse edits and say where9// they come from, a cell in the way makes it #REF! until cleared, and the10// file keeps only the formula, which spills again when it opens.11func TestArraySpill(t *testing.T) {12 t.Parallel()13 dir := t.TempDir()14 s := start(t, dir)15 s.keys("pear", "<enter>", "apple", "<enter>", "fig", "<enter>")16 s.keys("<ctrl+home>", "<right>", "=SORT(A1:A3)", "<enter>")17 s.eventually("the sorted spill", func() bool {18 return strings.Contains(s.line(gridRow1), "apple") && strings.Contains(s.line(gridRow1+1), "fig") &&19 strings.Contains(s.line(gridRow1+2), "pear")20 })21 s.keys("<down>") // B3, a spilled cell22 s.waitFor("Spilled from B1")23 s.keys("x")24 s.waitFor("B3 shows part of the array B1 spills")2526 // A cell in the way blocks the array, and clearing it lets it spill.27 s.keys("<esc>", "<f5>", "B1", "<enter>", "=SORT(A1:A4)", "<enter>")28 s.keys("<f5>", "A4", "<enter>", "kiwi", "<enter>")29 s.eventually("four sorted", func() bool { return strings.Contains(s.line(gridRow1+3), "pear") })30 s.keys("<f5>", "B6", "<enter>", "stop", "<enter>", "<f5>", "B5", "<enter>", "=SEQUENCE(2)", "<enter>", "<up>")31 s.waitFor("would overwrite data in B6")32 s.keys("<down>", "<delete>", "<up>")33 s.eventually("spilled once cleared", func() bool { return strings.Contains(s.line(gridRow1+5), "2") })3435 // The file keeps the formulas; their arrays spill again on opening.36 s.keys("<ctrl+s>", "fruit", "<enter>")37 s.eventually("saved", func() bool { return s.title() == "012 - fruit.012" })38 s.keys("<ctrl+q>")39 s.waitExit()40 r := start(t, dir, "fruit.012")41 r.eventually("spill after reopening", func() bool {42 return strings.Contains(r.line(gridRow1), "apple") && strings.Contains(r.line(gridRow1+2), "kiwi")43 })44}