cat / 012
clone

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

cat/module-path
012 / e2e / settings_test.go
settings_test.go 1.5K
1package e2e23import "testing"45// money types a few amounts where binary floating point is off by a6// hair: whole cents of $4.35 come to 434, $0.10 plus $0.20 less 0.3 isn't 0,7// and the difference shows in General format.8func money(s *session) {9 s.keys("Coffee", "<tab>", "$4.35", "<enter>")10 s.keys("Tip", "<tab>", "$0.10", "<enter>")11 s.keys("Fee", "<tab>", "$0.20", "<enter>")12 s.keys("Cents", "<tab>", "=INT(B1*100)", "<enter>")13 s.keys("Is 0.30?", "<tab>", "=B2+B3-0.3=0", "<enter>")14 s.keys("Residue", "<tab>", "=0.1+0.2-0.3", "<enter>")15 s.waitForBar("A7", "")16}1718// Decimal arithmetic from the palette recalculates at once, shows on the19// status line, and is saved with the file.20func TestDecimalArithmeticSetting(t *testing.T) {21 t.Parallel()22 dir := t.TempDir()23 s := start(t, dir)24 money(s)25 s.waitForLine(gridRow1+3, " 4 Cents $434.00")26 s.waitForLine(gridRow1+4, " 5 Is 0.30? FALSE")27 s.waitForLine(gridRow1+5, " 6 Residue 5.551E-17")28 s.keys("<ctrl+k>", "decimal", "<enter>")29 s.waitFor("Decimal arithmetic on")30 s.waitForLine(gridRow1+3, " 4 Cents $435.00")31 s.waitForLine(gridRow1+4, " 5 Is 0.30? TRUE")32 s.waitForLine(gridRow1+5, " 6 Residue 0")33 s.waitFor("modified decimal")3435 s.keys("<ctrl+s>", "money", "<enter>")36 s.eventually("saved", func() bool { return s.title() == "012 - money.012" })37 s.keys("<ctrl+q>")38 s.waitExit()3940 r := start(t, dir, "money.012")41 r.waitForLine(gridRow1+3, " 4 Cents $435.00")42 r.waitFor("money.012 decimal")43}