Implement NTH.
[muddle-interpreter.git] / src / test_sequences
1 #!/bin/sh
2
3 # Copyright (C) 2018 Keziah Wesley
4
5 # You can redistribute and/or modify this file under the terms of the
6 # GNU Affero General Public License as published by the Free Software
7 # Foundation, either version 3 of the License, or (at your option) any
8 # later version.
9
10 # This file is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Affero General Public License for more details.
14
15 # You should have received a copy of the GNU Affero General Public
16 # License along with this file. If not, see
17 # <http://www.gnu.org/licenses/>.
18
19 assert_eq () {
20     [ "$1" = "$2" ] || ( echo Assertion failed: "\"$1\"" = "\"$2\""; exit 1 )
21 }
22
23 assert_eq '1' "$(echo '<NTH 0 <LIST 1 2 3>>' | ./muddle)"
24 assert_eq '1' "$(echo '<NTH 0 (1 2 3)>' | ./muddle)"
25 assert_eq '1' "$(echo '<0 (1 2 3)>' | ./muddle)"
26 assert_eq '1' "$(echo '<1 (0 1)>' | ./muddle)"
27 assert_eq '(1 7)' "$(echo '(<SETG BAZ 1> <BAZ (4 7)>)' | ./muddle)"