Revert "Refactoring to test the feel of changing a value object to a ref object in nim"
I hated the debug made more difficult and less intuitive, and the need
to use echo repr(XXX) to see something.
This reverts commit 4ea0083ffc
.
This commit is contained in:
parent
4517aba8eb
commit
a551d5980e
2 changed files with 69 additions and 73 deletions
|
@ -1,5 +1,5 @@
|
||||||
type
|
type
|
||||||
Line = ref object
|
Line = object
|
||||||
x: int
|
x: int
|
||||||
columns: seq[int]
|
columns: seq[int]
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ type
|
||||||
func Blank*(f: var Field, x, y: int) =
|
func Blank*(f: var Field, x, y: int) =
|
||||||
if y < f.y or y >= f.y+f.ly: # outside the field
|
if y < f.y or y >= f.y+f.ly: # outside the field
|
||||||
return
|
return
|
||||||
var l = f.lines[y-f.y]
|
var l = addr f.lines[y-f.y]
|
||||||
if x < l.x or x >= l.x+l.columns.len: # outside the field
|
if x < l.x or x >= l.x+l.columns.len: # outside the field
|
||||||
return
|
return
|
||||||
if x > l.x and x < l.x+l.columns.len-1: # just set the value
|
if x > l.x and x < l.x+l.columns.len-1: # just set the value
|
||||||
|
@ -20,14 +20,14 @@ func Blank*(f: var Field, x, y: int) =
|
||||||
if l.columns.len == 1: # this was the last character on the line
|
if l.columns.len == 1: # this was the last character on the line
|
||||||
if y == f.y: # we need to trim the leading lines
|
if y == f.y: # we need to trim the leading lines
|
||||||
var i = 1
|
var i = 1
|
||||||
while f.lines[i] == nil or f.lines[i].columns.len == 0:
|
while f.lines[i].columns.len == 0:
|
||||||
inc i
|
inc i
|
||||||
f.y += i
|
f.y += i
|
||||||
f.lines = f.lines[i..<f.ly]
|
f.lines = f.lines[i..<f.ly]
|
||||||
f.ly -= i
|
f.ly -= i
|
||||||
elif y == f.y+f.ly-1: # we need to trim the trailing lines
|
elif y == f.y+f.ly-1: # we need to trim the trailing lines
|
||||||
var i = f.ly-2
|
var i = f.ly-2
|
||||||
while f.lines[i] == nil or f.lines[i].columns.len == 0:
|
while f.lines[i].columns.len == 0:
|
||||||
dec i
|
dec i
|
||||||
f.ly = i+1
|
f.ly = i+1
|
||||||
f.lines = f.lines[0..<f.ly]
|
f.lines = f.lines[0..<f.ly]
|
||||||
|
@ -48,7 +48,7 @@ func Blank*(f: var Field, x, y: int) =
|
||||||
f.x = f.lines[0].x
|
f.x = f.lines[0].x
|
||||||
var x2 = f.lines[0].columns.len + f.lines[0].x
|
var x2 = f.lines[0].columns.len + f.lines[0].x
|
||||||
for i in 1..<f.ly:
|
for i in 1..<f.ly:
|
||||||
if f.lines[i] == nil or f.lines[i].columns.len == 0:
|
if f.lines[i].columns.len == 0:
|
||||||
continue
|
continue
|
||||||
if f.x > f.lines[i].x:
|
if f.x > f.lines[i].x:
|
||||||
f.x = f.lines[i].x
|
f.x = f.lines[i].x
|
||||||
|
@ -71,8 +71,10 @@ proc Load*(filename: string): ref Field =
|
||||||
if not open(file, filename):
|
if not open(file, filename):
|
||||||
return nil
|
return nil
|
||||||
defer: file.close()
|
defer: file.close()
|
||||||
var f = new(Field)
|
var f: ref Field
|
||||||
var l = new(Line)
|
new(f)
|
||||||
|
var l : ptr Line
|
||||||
|
var leadingSpaces = 0
|
||||||
var trailingSpaces = 0
|
var trailingSpaces = 0
|
||||||
var data: array[4096, char]
|
var data: array[4096, char]
|
||||||
var lastReadIsCR = false
|
var lastReadIsCR = false
|
||||||
|
@ -80,13 +82,12 @@ proc Load*(filename: string): ref Field =
|
||||||
let n = file.readChars(data, 0, 4096)
|
let n = file.readChars(data, 0, 4096)
|
||||||
if n <= 0:
|
if n <= 0:
|
||||||
if f.ly == 0:
|
if f.ly == 0:
|
||||||
if l.columns.len == 0: # we got en empty file!
|
if l == nil: # we got en empty file!
|
||||||
return nil
|
return nil
|
||||||
f.x = l.x
|
f.x = l.x
|
||||||
if l.columns.len > 0:
|
if l != nil:
|
||||||
if f.lx < l.columns.len+l.x-f.x:
|
if f.lx < l.columns.len+l.x-f.x:
|
||||||
f.lx = l.columns.len+l.x-f.x
|
f.lx = l.columns.len+l.x-f.x
|
||||||
f.lines.add(l)
|
|
||||||
inc f.ly
|
inc f.ly
|
||||||
break
|
break
|
||||||
var i = 0
|
var i = 0
|
||||||
|
@ -100,17 +101,18 @@ proc Load*(filename: string): ref Field =
|
||||||
continue
|
continue
|
||||||
if data[i] == '\n' or data[i] == '\r':
|
if data[i] == '\n' or data[i] == '\r':
|
||||||
if f.ly == 0:
|
if f.ly == 0:
|
||||||
if l.columns.len == 0:
|
if l == nil:
|
||||||
return nil
|
return nil
|
||||||
f.x = l.x
|
f.x = l.x
|
||||||
if l.columns.len > 0:
|
if l != nil:
|
||||||
if f.x > l.x:
|
if f.x > l.x:
|
||||||
f.x = l.x
|
f.x = l.x
|
||||||
if f.lx < l.columns.len+l.x-f.x:
|
if f.lx < l.columns.len+l.x-f.x:
|
||||||
f.lx = l.columns.len+l.x-f.x
|
f.lx = l.columns.len+l.x-f.x
|
||||||
|
else:
|
||||||
|
f.lines.add(Line())
|
||||||
inc f.ly
|
inc f.ly
|
||||||
f.lines.add(l)
|
l = nil
|
||||||
l = new(Line)
|
|
||||||
trailingSpaces = 0
|
trailingSpaces = 0
|
||||||
if data[i] == '\r':
|
if data[i] == '\r':
|
||||||
if i+1 < n and data[i+1] == '\n':
|
if i+1 < n and data[i+1] == '\n':
|
||||||
|
@ -119,11 +121,16 @@ proc Load*(filename: string): ref Field =
|
||||||
lastReadIsCR = true
|
lastReadIsCR = true
|
||||||
else:
|
else:
|
||||||
if data[i] == ' ':
|
if data[i] == ' ':
|
||||||
if l.columns.len == 0: # trim leading spaces
|
if l == nil: # trim leading spaces
|
||||||
inc l.x
|
inc leadingSpaces
|
||||||
else:
|
else:
|
||||||
inc trailingSpaces
|
inc trailingSpaces
|
||||||
else:
|
else:
|
||||||
|
if l == nil:
|
||||||
|
f.lines.add(Line())
|
||||||
|
l = addr f.lines[^1]
|
||||||
|
l.x = leadingSpaces
|
||||||
|
leadingSpaces = 0
|
||||||
if trailingSpaces > 0:
|
if trailingSpaces > 0:
|
||||||
let oldL = l.columns.len
|
let oldL = l.columns.len
|
||||||
l.columns.setlen(oldL+trailingSpaces+1)
|
l.columns.setlen(oldL+trailingSpaces+1)
|
||||||
|
@ -134,6 +141,7 @@ proc Load*(filename: string): ref Field =
|
||||||
else:
|
else:
|
||||||
l.columns.add(int(data[i]))
|
l.columns.add(int(data[i]))
|
||||||
inc i
|
inc i
|
||||||
|
f.lines = f.lines[0..<f.ly]
|
||||||
return f
|
return f
|
||||||
|
|
||||||
func Set*(f: var Field, x, y, v: int) =
|
func Set*(f: var Field, x, y, v: int) =
|
||||||
|
@ -141,13 +149,10 @@ func Set*(f: var Field, x, y, v: int) =
|
||||||
f.Blank(x, y)
|
f.Blank(x, y)
|
||||||
elif y >= f.y:
|
elif y >= f.y:
|
||||||
if y < f.y+f.ly: # the line exists
|
if y < f.y+f.ly: # the line exists
|
||||||
var l = f.lines[y-f.y]
|
var l = addr f.lines[y-f.y]
|
||||||
if l == nil or l.columns.len == 0: # An empty line is a special case
|
if l.columns.len == 0: # An empty line is a special case
|
||||||
if l == nil:
|
|
||||||
new(l)
|
|
||||||
l.x = x
|
l.x = x
|
||||||
l.columns = @[v]
|
l.columns = @[v]
|
||||||
f.lines[y-f.y] = l
|
|
||||||
if f.x > x:
|
if f.x > x:
|
||||||
f.lx = f.lx+f.x-x
|
f.lx = f.lx+f.x-x
|
||||||
f.x = x
|
f.x = x
|
||||||
|
|
|
@ -2,109 +2,100 @@ import unittest
|
||||||
|
|
||||||
include ../src/field
|
include ../src/field
|
||||||
|
|
||||||
func `==`(a, b: Field): bool =
|
func `==`(a, b: Line): bool = a.x == b.x and a.columns == b.columns
|
||||||
if a.x == b.x and a.lx == b.lx and a.y == b.y and a.ly == b.ly:
|
func `==`(a, b: Field): bool = a.x == b.x and a.lx == b.lx and a.y == b.y and a.ly == b.ly and a.lines == b.lines
|
||||||
for i in 0..<a.ly:
|
|
||||||
if a.lines[i] == nil and b.lines[i] == nil:
|
|
||||||
continue
|
|
||||||
if a.lines[i] == nil xor b.lines[i] == nil:
|
|
||||||
return false
|
|
||||||
if a.lines[i].x != b.lines[i].x or a.lines[i].columns != b.lines[i].columns:
|
|
||||||
return false
|
|
||||||
return true
|
|
||||||
return false
|
|
||||||
|
|
||||||
func cols(a: openarray[char]): seq[int] =
|
func cols(a: openarray[char]): seq[int] =
|
||||||
result.setlen(a.len)
|
result.setlen(a.len)
|
||||||
for i in 0..<a.len:
|
for i in 0..<a.len:
|
||||||
result[i] = a[i].int()
|
result[i] = a[i].int()
|
||||||
|
|
||||||
let minimal = Field(x: 0, y: 0, lx: 1, ly: 1, lines: @[Line(x: 0, columns: @[int('@')])])
|
const minimal = Field(x: 0, y: 0, lx: 1, ly: 1, lines: @[Line(x: 0, columns: @[int('@')])])
|
||||||
|
|
||||||
suite "Field":
|
suite "Field":
|
||||||
test "Blank":
|
test "Blank":
|
||||||
var f = Field(x: -7, y: -5, lx: 17, ly: 10, lines: @[
|
var f = Field(x: -7, y: -5, lx: 17, ly: 10, lines: @[
|
||||||
Line(x: -5, columns: @[int('x')]),
|
Line(x: -5, columns: @[int('x')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: 8, columns: @[int('u')]),
|
Line(x: 8, columns: @[int('u')]),
|
||||||
Line(x: 9, columns: @[int('e')]),
|
Line(x: 9, columns: @[int('e')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: -2, columns: @[int('l'), 32, int('@'), int('z'), 32, 32, int('r')]),
|
Line(x: -2, columns: @[int('l'), 32, int('@'), int('z'), 32, 32, int('r')]),
|
||||||
Line(x: -3, columns: @[int('f')]),
|
Line(x: -3, columns: @[int('f')]),
|
||||||
Line(x: 5, columns: @[int('d')]),
|
Line(x: 5, columns: @[int('d')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: -7, columns: @[int('y')]),
|
Line(x: -7, columns: @[int('y')]),
|
||||||
])
|
])
|
||||||
let moinsz = Field(x: -7, y: -5, lx: 17, ly: 10, lines: @[
|
const moinsz = Field(x: -7, y: -5, lx: 17, ly: 10, lines: @[
|
||||||
Line(x: -5, columns: @[int('x')]),
|
Line(x: -5, columns: @[int('x')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: 8, columns: @[int('u')]),
|
Line(x: 8, columns: @[int('u')]),
|
||||||
Line(x: 9, columns: @[int('e')]),
|
Line(x: 9, columns: @[int('e')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
||||||
Line(x: -3, columns: @[int('f')]),
|
Line(x: -3, columns: @[int('f')]),
|
||||||
Line(x: 5, columns: @[int('d')]),
|
Line(x: 5, columns: @[int('d')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: -7, columns: @[int('y')]),
|
Line(x: -7, columns: @[int('y')]),
|
||||||
])
|
])
|
||||||
f.Blank(1, 0)
|
f.Blank(1, 0)
|
||||||
check f == moinsz
|
check f == moinsz
|
||||||
let moinsy = Field(x: -5, y: -5, lx: 15, ly: 8, lines: @[
|
const moinsy = Field(x: -5, y: -5, lx: 15, ly: 8, lines: @[
|
||||||
Line(x: -5, columns: @[int('x')]),
|
Line(x: -5, columns: @[int('x')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: 8, columns: @[int('u')]),
|
Line(x: 8, columns: @[int('u')]),
|
||||||
Line(x: 9, columns: @[int('e')]),
|
Line(x: 9, columns: @[int('e')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
||||||
Line(x: -3, columns: @[int('f')]),
|
Line(x: -3, columns: @[int('f')]),
|
||||||
Line(x: 5, columns: @[int('d')]),
|
Line(x: 5, columns: @[int('d')]),
|
||||||
])
|
])
|
||||||
f.Blank(-7, 4)
|
f.Blank(-7, 4)
|
||||||
check f == moinsy
|
check f == moinsy
|
||||||
let moinsx = Field(x: -3, y: -3, lx: 13, ly: 6, lines: @[
|
const moinsx = Field(x: -3, y: -3, lx: 13, ly: 6, lines: @[
|
||||||
Line(x: 8, columns: @[int('u')]),
|
Line(x: 8, columns: @[int('u')]),
|
||||||
Line(x: 9, columns: @[int('e')]),
|
Line(x: 9, columns: @[int('e')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
||||||
Line(x: -3, columns: @[int('f')]),
|
Line(x: -3, columns: @[int('f')]),
|
||||||
Line(x: 5, columns: @[int('d')]),
|
Line(x: 5, columns: @[int('d')]),
|
||||||
])
|
])
|
||||||
f.Blank(-5, -5)
|
f.Blank(-5, -5)
|
||||||
check f == moinsx
|
check f == moinsx
|
||||||
let moinsf = Field(x: -2, y: -3, lx: 12, ly: 6, lines: @[
|
const moinsf = Field(x: -2, y: -3, lx: 12, ly: 6, lines: @[
|
||||||
Line(x: 8, columns: @[int('u')]),
|
Line(x: 8, columns: @[int('u')]),
|
||||||
Line(x: 9, columns: @[int('e')]),
|
Line(x: 9, columns: @[int('e')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
||||||
Line(x: -3, columns: @[]),
|
Line(x: -3, columns: @[]),
|
||||||
Line(x: 5, columns: @[int('d')]),
|
Line(x: 5, columns: @[int('d')]),
|
||||||
])
|
])
|
||||||
f.Blank(-3, 1)
|
f.Blank(-3, 1)
|
||||||
check f == moinsf
|
check f == moinsf
|
||||||
let moinse = Field(x: -2, y: -3, lx: 11, ly: 6, lines: @[
|
const moinse = Field(x: -2, y: -3, lx: 11, ly: 6, lines: @[
|
||||||
Line(x: 8, columns: @[int('u')]),
|
Line(x: 8, columns: @[int('u')]),
|
||||||
Line(x: 9, columns: @[]),
|
Line(x: 9, columns: @[]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
||||||
Line(x: -3, columns: @[]),
|
Line(x: -3, columns: @[]),
|
||||||
Line(x: 5, columns: @[int('d')]),
|
Line(x: 5, columns: @[int('d')]),
|
||||||
])
|
])
|
||||||
f.Blank(9, -2)
|
f.Blank(9, -2)
|
||||||
check f == moinse
|
check f == moinse
|
||||||
let moinsu = Field(x: -2, y: 0, lx: 8, ly: 3, lines: @[
|
const moinsu = Field(x: -2, y: 0, lx: 8, ly: 3, lines: @[
|
||||||
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
||||||
Line(x: -3, columns: @[]),
|
Line(x: -3, columns: @[]),
|
||||||
Line(x: 5, columns: @[int('d')]),
|
Line(x: 5, columns: @[int('d')]),
|
||||||
])
|
])
|
||||||
f.Blank(8, -3)
|
f.Blank(8, -3)
|
||||||
check f == moinsu
|
check f == moinsu
|
||||||
let moinsd = Field(x: -2, y: 0, lx: 7, ly: 1, lines: @[Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')])])
|
const moinsd = Field(x: -2, y: 0, lx: 7, ly: 1, lines: @[Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')])])
|
||||||
f.Blank(5, 2)
|
f.Blank(5, 2)
|
||||||
check f == moinsd
|
check f == moinsd
|
||||||
let moinsl = Field(x: 0, y: 0, lx: 5, ly: 1, lines: @[Line(x: 0, columns: @[int('@'), 32, 32, 32, int('r')])])
|
const moinsl = Field(x: 0, y: 0, lx: 5, ly: 1, lines: @[Line(x: 0, columns: @[int('@'), 32, 32, 32, int('r')])])
|
||||||
f.Blank(-2, 0)
|
f.Blank(-2, 0)
|
||||||
check f == moinsl
|
check f == moinsl
|
||||||
let moinsr = Field(x: 0, y: 0, lx: 1, ly: 1, lines: @[Line(x: 0, columns: @[int('@')])])
|
const moinsr = Field(x: 0, y: 0, lx: 1, ly: 1, lines: @[Line(x: 0, columns: @[int('@')])])
|
||||||
f.Blank(4, 0)
|
f.Blank(4, 0)
|
||||||
check f == moinsr
|
check f == moinsr
|
||||||
test "Get":
|
test "Get":
|
||||||
|
@ -146,71 +137,71 @@ suite "Field":
|
||||||
check f == minimal
|
check f == minimal
|
||||||
f.Set(1, 0, int(' '))
|
f.Set(1, 0, int(' '))
|
||||||
check f == minimal
|
check f == minimal
|
||||||
let xappend = Field(x: 0, y: 0, lx: 5, ly: 1, lines: @[Line(x: 0, columns: @[int('@'), 32, 32, 32, int('r')])])
|
const xappend = Field(x: 0, y: 0, lx: 5, ly: 1, lines: @[Line(x: 0, columns: @[int('@'), 32, 32, 32, int('r')])])
|
||||||
f.Set(4, 0, int('r'))
|
f.Set(4, 0, int('r'))
|
||||||
check f == xappend
|
check f == xappend
|
||||||
let xprepend = Field(x: -2, y: 0, lx: 7, ly: 1, lines: @[Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')])])
|
const xprepend = Field(x: -2, y: 0, lx: 7, ly: 1, lines: @[Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')])])
|
||||||
f.Set(-2, 0, int('l'))
|
f.Set(-2, 0, int('l'))
|
||||||
check f == xprepend
|
check f == xprepend
|
||||||
let yappend = Field(x: -2, y: 0, lx: 8, ly: 3, lines: @[
|
const yappend = Field(x: -2, y: 0, lx: 8, ly: 3, lines: @[
|
||||||
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: 5, columns: @[int('d')]),
|
Line(x: 5, columns: @[int('d')]),
|
||||||
])
|
])
|
||||||
f.Set(5, 2, int('d'))
|
f.Set(5, 2, int('d'))
|
||||||
check f == yappend
|
check f == yappend
|
||||||
let yprepend = Field(x: -2, y: -3, lx: 11, ly: 6, lines: @[
|
const yprepend = Field(x: -2, y: -3, lx: 11, ly: 6, lines: @[
|
||||||
Line(x: 8, columns: @[int('u')]),
|
Line(x: 8, columns: @[int('u')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: 5, columns: @[int('d')]),
|
Line(x: 5, columns: @[int('d')]),
|
||||||
])
|
])
|
||||||
f.Set(8, -3, int('u'))
|
f.Set(8, -3, int('u'))
|
||||||
check f == yprepend
|
check f == yprepend
|
||||||
let xappendEmptyline = Field(x: -2, y: -3, lx: 12, ly: 6, lines: @[
|
const xappendEmptyline = Field(x: -2, y: -3, lx: 12, ly: 6, lines: @[
|
||||||
Line(x: 8, columns: @[int('u')]),
|
Line(x: 8, columns: @[int('u')]),
|
||||||
Line(x: 9, columns: @[int('e')]),
|
Line(x: 9, columns: @[int('e')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: 5, columns: @[int('d')]),
|
Line(x: 5, columns: @[int('d')]),
|
||||||
])
|
])
|
||||||
f.Set(9, -2, int('e'))
|
f.Set(9, -2, int('e'))
|
||||||
check f == xappendEmptyline
|
check f == xappendEmptyline
|
||||||
let xprependEmptyline = Field(x: -3, y: -3, lx: 13, ly: 6, lines: @[
|
const xprependEmptyline = Field(x: -3, y: -3, lx: 13, ly: 6, lines: @[
|
||||||
Line(x: 8, columns: @[int('u')]),
|
Line(x: 8, columns: @[int('u')]),
|
||||||
Line(x: 9, columns: @[int('e')]),
|
Line(x: 9, columns: @[int('e')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
||||||
Line(x: -3, columns: @[int('f')]),
|
Line(x: -3, columns: @[int('f')]),
|
||||||
Line(x: 5, columns: @[int('d')]),
|
Line(x: 5, columns: @[int('d')]),
|
||||||
])
|
])
|
||||||
f.Set(-3, 1, int('f'))
|
f.Set(-3, 1, int('f'))
|
||||||
check f == xprependEmptyline
|
check f == xprependEmptyline
|
||||||
let xprependyprepend = Field(x: -5, y: -5, lx: 15, ly: 8, lines: @[
|
const xprependyprepend = Field(x: -5, y: -5, lx: 15, ly: 8, lines: @[
|
||||||
Line(x: -5, columns: @[int('x')]),
|
Line(x: -5, columns: @[int('x')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: 8, columns: @[int('u')]),
|
Line(x: 8, columns: @[int('u')]),
|
||||||
Line(x: 9, columns: @[int('e')]),
|
Line(x: 9, columns: @[int('e')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
||||||
Line(x: -3, columns: @[int('f')]),
|
Line(x: -3, columns: @[int('f')]),
|
||||||
Line(x: 5, columns: @[int('d')]),
|
Line(x: 5, columns: @[int('d')]),
|
||||||
])
|
])
|
||||||
f.Set(-5, -5, int('x'))
|
f.Set(-5, -5, int('x'))
|
||||||
check f == xprependyprepend
|
check f == xprependyprepend
|
||||||
let xprependyappend = Field(x: -7, y: -5, lx: 17, ly: 10, lines: @[
|
const xprependyappend = Field(x: -7, y: -5, lx: 17, ly: 10, lines: @[
|
||||||
Line(x: -5, columns: @[int('x')]),
|
Line(x: -5, columns: @[int('x')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: 8, columns: @[int('u')]),
|
Line(x: 8, columns: @[int('u')]),
|
||||||
Line(x: 9, columns: @[int('e')]),
|
Line(x: 9, columns: @[int('e')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
Line(x: -2, columns: @[int('l'), 32, int('@'), 32, 32, 32, int('r')]),
|
||||||
Line(x: -3, columns: @[int('f')]),
|
Line(x: -3, columns: @[int('f')]),
|
||||||
Line(x: 5, columns: @[int('d')]),
|
Line(x: 5, columns: @[int('d')]),
|
||||||
nil,
|
Line(x: 0, columns: @[]),
|
||||||
Line(x: -7, columns: @[int('y')]),
|
Line(x: -7, columns: @[int('y')]),
|
||||||
])
|
])
|
||||||
f.Set(-7, 4, int('y'))
|
f.Set(-7, 4, int('y'))
|
||||||
|
|
Reference in a new issue