From 52be0d0d1eaf4b6f8956e72f5c4a425e793a36cc Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sat, 2 Oct 2021 20:37:24 +0200 Subject: Finished implementing the funge space field --- tests/testField.nim | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/testField.nim b/tests/testField.nim index 7c49149..c1def19 100644 --- a/tests/testField.nim +++ b/tests/testField.nim @@ -2,8 +2,12 @@ import unittest include field -proc `==`(a, b: Line): bool = a.x == b.x and a.l == b.l and a.columns == b.columns -proc `==`(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 +func `==`(a, b: Line): bool = a.x == b.x and a.l == b.l and a.columns == b.columns +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 +func cols(a: openarray[char]): seq[int] = + result.setlen(a.len) + for i in 0..', ':', '#', ',', '_', '@'].cols)]) + check hello1A.load("examples/hello.b98") == true + check hello1A == hello1B + var rn: Field + check rn.load("examples/rn.b98") == true + check rn == hello1B + var hello2A: Field; var hello2B = Field(x: 1, lx: 33, ly: 2,lines: @[ + Line(x:33, l:1, columns: @['v'].cols), + Line(x:1, l:33, columns: @['@', ' ', '>', ' ', '#', ';', '>', ':', '#', ',', '_', 'e', '-', 'j', ';', ' ', '"', 'H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!', '"', 'd', 'a', '<'].cols) + ]) + check hello2A.load("examples/hello2.b98") == true + check hello2A == hello2B + var factorial2A: Field; var factorial2B = Field(x: 0, lx: 15, ly: 2,lines: @[ + Line(x:0, l:15, columns: @['&', '>', ':', '1', '-', ':', 'v', ' ', 'v', ' ', '*', '_', '$', '.', '@'].cols), + Line(x:1, l:11, columns: @['^', ' ', ' ', ' ', ' ', '_', '$', '>', '\\', ':', '^'].cols) + ]) + check factorial2A.load("examples/factorial.b98") == true + check factorial2A == factorial2B + var dna2A: Field; var dna2B = Field(x: 0, lx: 7, ly: 8,lines: @[ + Line(x:0, l:7, columns: @['7', '^', 'D', 'N', '>', 'v', 'A'].cols), + Line(x:0, l:7, columns: @['v', '_', '#', 'v', '?', ' ', 'v'].cols), + Line(x:0, l:7, columns: @['7', '^', '<', '"', '"', '"', '"'].cols), + Line(x:0, l:7, columns: @['3', ' ', ' ', 'A', 'C', 'G', 'T'].cols), + Line(x:0, l:7, columns: @['9', '0', '!', '"', '"', '"', '"'].cols), + Line(x:0, l:7, columns: @['4', '*', ':', '>', '>', '>', 'v'].cols), + Line(x:0, l:7, columns: @['+', '8', '^', '-', '1', ',', '<'].cols), + Line(x:0, l:7, columns: @['>', ' ', ',', '+', ',', '@', ')'].cols), + ]) + check dna2A.load("examples/dna.b98") == true + check dna2A == dna2B test "Field.set": - var f = Field(x: 0, y: 0, lx: 1, ly: 1, lines: @[Line(x: 0, l: 1, columns: @[int('>')])]) + var f = Field(x: 0, y: 0, lx: 1, ly: 1, lines: @[Line(x: 0, l: 1, columns: @['>'].cols)]) f.set(0,0,int('@')) check f == minimal f.set(1,0,int(' ')) -- cgit v1.2.3