main_testing5/bf_test4.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Fri, 26 Apr 2024 17:35:36 +0100
changeset 486 9c03b5e89a2a
parent 475 59e005dcf163
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
475
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 404
diff changeset
     1
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 404
diff changeset
     2
def urbanmain() = {
235
c989f50da5de updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
475
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 404
diff changeset
     4
  import M5a._
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 404
diff changeset
     5
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 404
diff changeset
     6
  assert(run("[-]", Map(0 -> 100)) == Map(0 -> 0))
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 404
diff changeset
     7
  assert(run("[->+<]", Map(0 -> 10)) == Map(0 -> 0, 1 -> 10))
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 404
diff changeset
     8
  assert(run("[>>+>>+<<<<-]", Map(0 -> 42)) == Map(0 -> 0, 2 -> 42, 4 -> 42))
404
bf20a9fa5c29 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 348
diff changeset
     9
340
9eeab89d0671 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 329
diff changeset
    10
9eeab89d0671 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 329
diff changeset
    11
235
c989f50da5de updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
475
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 404
diff changeset
    13
  val hw_urban = """+++++[->++++++++++<]>--<+++[->>++++++++++
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 404
diff changeset
    14
                    <<]>>++<<----------[+>.>.<+<]"""
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 404
diff changeset
    15
  assert(run(hw_urban) == Map(0 -> 0, 1 -> 58, 2 -> 32))
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 404
diff changeset
    16
}