aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2021-10-07 18:24:48 +0200
committerJulien Dessaux2021-10-07 18:24:48 +0200
commit8daf3d58fc8d989940ed8f8a96dd3a93fe8c0793 (patch)
treea7e25e3025f4edd569eed9d08cf030d1b08756af
parentFixed tricky field loading bug (diff)
downloadnimfunge98-8daf3d58fc8d989940ed8f8a96dd3a93fe8c0793.tar.gz
nimfunge98-8daf3d58fc8d989940ed8f8a96dd3a93fe8c0793.tar.bz2
nimfunge98-8daf3d58fc8d989940ed8f8a96dd3a93fe8c0793.zip
Added submodules with the spec and the mycology test suite
-rw-r--r--.gitmodules6
m---------mycology0
m---------spec0
-rw-r--r--src/field.nim8
-rw-r--r--tests/mycology.nim14
5 files changed, 24 insertions, 4 deletions
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
+Subproject 3787e42c3d4f0b735a09129a205e3e4df848558
diff --git a/spec b/spec
new file mode 160000
+Subproject 7b4330df1a624c464f01c80090b60621ce5a330
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