main_testing5/bf_test4.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Mon, 08 Nov 2021 01:03:09 +0000
changeset 401 9471c3b7ea02
parent 348 b5b6ed38c2f2
child 404 bf20a9fa5c29
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
286
5c57c407e27b updated
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
     1
import CW10a._
235
c989f50da5de updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
236
e461b5325b5e updated
Christian Urban <urbanc@in.tum.de>
parents: 235
diff changeset
     3
assert(run("[-]", Map(0 -> 100)) == Map(0 -> 0))
e461b5325b5e updated
Christian Urban <urbanc@in.tum.de>
parents: 235
diff changeset
     4
assert(run("[->+<]", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10))
e461b5325b5e updated
Christian Urban <urbanc@in.tum.de>
parents: 235
diff changeset
     5
assert(run("[>>+>>+<<<<-]", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42))
340
9eeab89d0671 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 329
diff changeset
     6
assert(run("++++++++++#>+***#") == Map(0 -> 10, 1 -> 1000))
9eeab89d0671 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 329
diff changeset
     7
assert(run("+++>+@+@+@+@+@") == Map(0 -> 3, 1 -> 7, 4 -> 3, 5 -> 3, 6 -> 3, 7 -> 3))
9eeab89d0671 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 329
diff changeset
     8
9eeab89d0671 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 329
diff changeset
     9
235
c989f50da5de updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
340
9eeab89d0671 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 329
diff changeset
    11
val hw_urban = """+++++[->++++++++++<]>--<+++[->>++++++++++
9eeab89d0671 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 329
diff changeset
    12
                  <<]>>++<<----------[+>.>.<+<]"""
9eeab89d0671 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 329
diff changeset
    13
assert(run(hw_urban) == Map(0 -> 0, 1 -> 58, 2 -> 32))
9eeab89d0671 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 329
diff changeset
    14