From 8daf3d58fc8d989940ed8f8a96dd3a93fe8c0793 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Thu, 7 Oct 2021 18:24:48 +0200 Subject: Added submodules with the spec and the mycology test suite --- .gitmodules | 6 ++++++ mycology | 1 + spec | 1 + src/field.nim | 8 ++++---- tests/mycology.nim | 14 ++++++++++++++ 5 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 .gitmodules create mode 160000 mycology create mode 160000 spec create mode 100644 tests/mycology.nim diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..efdb3a1 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "spec"] + path = spec + url = https://github.com/catseye/Funge-98 +[submodule "mycology"] + path = mycology + url = https://github.com/Deewiant/Mycology diff --git a/mycology b/mycology new file mode 160000 index 0000000..3787e42 --- /dev/null +++ b/mycology @@ -0,0 +1 @@ +Subproject commit 3787e42c3d4f0b735a09129a205e3e4df848558c diff --git a/spec b/spec new file mode 160000 index 0000000..7b4330d --- /dev/null +++ b/spec @@ -0,0 +1 @@ +Subproject commit 7b4330df1a624c464f01c80090b60621ce5a330e diff --git a/src/field.nim b/src/field.nim index 47c94b5..e63a64e 100644 --- a/src/field.nim +++ b/src/field.nim @@ -116,11 +116,11 @@ proc Load*(filename: string): ref Field = f.lines.add(Line()) l = addr f.lines[^1] trailingSpaces = 0 - if i+1 < n: - if data[i] == '\r' and data[i+1] == '\n': + if data[i] == '\r': + if i+1 < n and data[i+1] == '\n': inc i - else: - lastReadIsCR = true + else: + lastReadIsCR = true else: if data[i] == ' ': if l.l == 0: # trim leading spaces diff --git a/tests/mycology.nim b/tests/mycology.nim new file mode 100644 index 0000000..54650a2 --- /dev/null +++ b/tests/mycology.nim @@ -0,0 +1,14 @@ +import ../src/field +import ../src/interpreter +import ../src/pointer + +import unittest + +suite "Mycology": + const filename = "mycology/mycology.b98" + var f = Load(filename) + check f != nil + let argv = @[filename] + var p = NewPointer(argv = argv) + let v = NewInterpreter(f, p)[].Run() + check v == 15 -- cgit v1.2.3