core_testing3/postfix_test3.scala
changeset 474 b528d1d3d3c3
parent 401 9471c3b7ea02
equal deleted inserted replaced
473:ac79c2e534bd 474:b528d1d3d3c3
       
     1 
       
     2 
       
     3 def urbanmain() = {
       
     4   import C3b._
       
     5 
       
     6 
       
     7   assert(syard(split("3 + 4 * ( 2 - 1 )")) == List("3", "4", "2", "1", "-", "*", "+"))
       
     8   assert(syard(split("( ( ( 3 ) ) + ( ( 4 + ( 5 ) ) ) )")) == List("3", "4", "5", "+", "+"))
       
     9   assert(syard(split("5 + 7 / 2")) == List("5", "7", "2", "/", "+"))
       
    10   assert(syard(split("5 * 7 / 2")) == List("5", "7", "*", "2", "/"))
       
    11   assert(syard(split("3 + 4 * 8 / ( 5 - 1 ) ^ 2 ^ 3")) == List("3", "4", "8", "*", "5", "1", "-", "2", "3", "^", "^", "/", "+"))
       
    12 
       
    13   assert(compute(syard(split("3 + 4 * ( 2 - 1 )"))) == 7)
       
    14   assert(compute(syard(split("10 + 12 * 33"))) == 406)
       
    15   assert(compute(syard(split("( 5 + 7 ) * 2"))) == 24)
       
    16   assert(compute(syard(split("5 + 7 / 2"))) == 8)
       
    17   assert(compute(syard(split("5 * 7 / 2"))) == 17)
       
    18   assert(compute(syard(split("9 + 24 / ( 7 - 3 )"))) == 15)
       
    19   assert(compute(syard(split("4 ^ 3 ^ 2"))) == 262144)
       
    20   assert(compute(syard(split("4 ^ ( 3 ^ 2 )"))) == 262144)
       
    21   assert(compute(syard(split("( 4 ^ 3 ) ^ 2"))) == 4096)
       
    22   assert(compute(syard(split("( 3 + 1 ) ^ 2 ^ 3"))) == 65536)
       
    23 }