core_testing3/postfix_test3.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Sun, 15 Sep 2024 12:57:59 +0100
changeset 493 244df77507c2
parent 474 b528d1d3d3c3
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
300
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 249
diff changeset
     1
249
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
474
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
     3
def urbanmain() = {
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
     4
  import C3b._
249
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
474
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
     7
  assert(syard(split("3 + 4 * ( 2 - 1 )")) == List("3", "4", "2", "1", "-", "*", "+"))
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
     8
  assert(syard(split("( ( ( 3 ) ) + ( ( 4 + ( 5 ) ) ) )")) == List("3", "4", "5", "+", "+"))
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
     9
  assert(syard(split("5 + 7 / 2")) == List("5", "7", "2", "/", "+"))
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
    10
  assert(syard(split("5 * 7 / 2")) == List("5", "7", "*", "2", "/"))
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
    11
  assert(syard(split("3 + 4 * 8 / ( 5 - 1 ) ^ 2 ^ 3")) == List("3", "4", "8", "*", "5", "1", "-", "2", "3", "^", "^", "/", "+"))
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
    12
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
    13
  assert(compute(syard(split("3 + 4 * ( 2 - 1 )"))) == 7)
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
    14
  assert(compute(syard(split("10 + 12 * 33"))) == 406)
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
    15
  assert(compute(syard(split("( 5 + 7 ) * 2"))) == 24)
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
    16
  assert(compute(syard(split("5 + 7 / 2"))) == 8)
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
    17
  assert(compute(syard(split("5 * 7 / 2"))) == 17)
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
    18
  assert(compute(syard(split("9 + 24 / ( 7 - 3 )"))) == 15)
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
    19
  assert(compute(syard(split("4 ^ 3 ^ 2"))) == 262144)
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
    20
  assert(compute(syard(split("4 ^ ( 3 ^ 2 )"))) == 262144)
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
    21
  assert(compute(syard(split("( 4 ^ 3 ) ^ 2"))) == 4096)
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
    22
  assert(compute(syard(split("( 3 + 1 ) ^ 2 ^ 3"))) == 65536)
b528d1d3d3c3 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 401
diff changeset
    23
}