Implement NTH.
[muddle-interpreter.git] / src / test_sequences
diff --git a/src/test_sequences b/src/test_sequences
new file mode 100755 (executable)
index 0000000..a0f96a6
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# Copyright (C) 2018 Keziah Wesley
+
+# You can redistribute and/or modify this file under the terms of the
+# GNU Affero General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any
+# later version.
+
+# This file is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public
+# License along with this file. If not, see
+# <http://www.gnu.org/licenses/>.
+
+assert_eq () {
+    [ "$1" = "$2" ] || ( echo Assertion failed: "\"$1\"" = "\"$2\""; exit 1 )
+}
+
+assert_eq '1' "$(echo '<NTH 0 <LIST 1 2 3>>' | ./muddle)"
+assert_eq '1' "$(echo '<NTH 0 (1 2 3)>' | ./muddle)"
+assert_eq '1' "$(echo '<0 (1 2 3)>' | ./muddle)"
+assert_eq '1' "$(echo '<1 (0 1)>' | ./muddle)"
+assert_eq '(1 7)' "$(echo '(<SETG BAZ 1> <BAZ (4 7)>)' | ./muddle)"