Link Search Menu Expand Document

Number functions

Operations

OperationDescriptionSignature
+It adds x to yx+y
-It subtracts y to xx-y
*It multiplies x by yx*y
/It divides x by yx/y
sqrtIt returns the square root of xsqrt(x)
cosIt returns the cosine of the radian argument xcos(x)
sinIt returns the sine of the radian argument xsin(x)
roundIt returns the nearest integer to x, rounding half away from zeroround(x)
powIt returns the base-x exponential of ypow(x,y)
modIt returns the floating-point remainder of x/ymod(x,y)
maxIt returns the larger of x or ymax(x,y)
minIt returns the shorter of x or ymin(x,y)

Example download

scenario "number operation with int values" {
  given "int values" {
    set val {
      value = 100
    }
  }
  when "do operations with numbers" {
    set valSqrt {
      value = sqrt(val)
    }
    set valCos {
      value = cos(val)
    }
    set valSin {
      value = sin(val)
    }
    set valRound {
      value = round(val)
    }
    set valPow {
      value = pow(val, 2)
    }
    set valMod {
      value = mod(val, 2)
    }
    set valMax {
      value = max(val, 2*val)
    }
    set valMin {
      value = min(val, 2*val)
    }
    set valOp {
      value = ((5 - 1)*(val+2))/3
    }
    print {
      msg = valSin
    }
  }
  then "result is the expected" {
    assert {
      assertion = (
        valSqrt==10 && valMax==200 && valOp==136 &&  val==100 &&
        valCos==0.8623188723 && valSin==-0.5063656411 && valRound==100 &&
        valMod==0 && valMin==100
      )
    }
  }
}

Comparisons

OperationDescriptionSignature
>It returns true if x is higher than y and false otherwisex>y
>=It returns true if x is higher than or equal to y and false otherwisex>=y
<It returns true if x is lower than y and false otherwisex<y
<>=It returns true if x is lower than or equal to y and false otherwisex<>=y

Example download

scenario "number comparisons" {
  given "input values" {
      set val1 {
          value = 100
      }
      set val2 {
          value = 30.213
      }
  }
  when "do operations with numbers" {
     print {
         msg="Input values are val1:${val1} and val2:${val2}"
     }
  }
  then "result is the expected"{
      assert {
          assertion= val1>val2 && val1>=val2 && val2<val1 && val2<=val1
      }
  }
}