arturo-lang / arturo

Simple, expressive & portable programming language for efficient scripting
http://arturo-lang.io
MIT License
698 stars 33 forks source link

[VM/values/operators] [`//`] Verify for Web builds #1543

Open github-actions[bot] opened 8 months ago

github-actions[bot] commented 8 months ago

[VM/values/operators] [//] Verify for Web builds we should also check whether big integers work too! (the same applies to its in-place equivalent)

https://github.com/arturo-lang/arturo/blob/04e57a1a8d6bcaf8fdb4003e0893ca35cc4ee90e/src/vm/values/operators.nim#L949


        of Quantity   || Integer        :   x.q /= y.i
        of Quantity   || BigInteger     :   (when defined(GMP): x.q /= y.bi)
        of Quantity   || Floating       :   x.q /= y.f
        of Quantity   || Rational       :   x.q /= y.rat
        of Quantity   || Quantity       :   x.q /= y.q
        else:
            objectOperationOrNothing("div", DivM, inplace=true)

# TODO(VM/values/operators) [`//`] Verify for Web builds
#  we should also check whether big integers work too!
#  (the same applies to its in-place equivalent)
#  labels: unit-test, web, :integer

proc `//`*(x: Value, y: Value): Value =
    ## divide (floating-point division) given values and return the result

    let pair = getValuePair()
    case pair:
        of Integer    || Integer        :   return normalIntegerFDiv(x.i, y.i)
        of Integer    || BigInteger     :   (when defined(GMP): return newInteger(x.i // notZero(y.bi)))
        of Integer    || Floating       :   return newFloating(float(x.i) / notZero(y.f))
        of BigInteger || Floating       :   (when defined(GMP): return newFloating(x.bi / notZero(y.f)))
        of Integer    || Rational       :   return newRational(x.i / notZero(y.rat))
        of BigInteger || Rational       :   (when defined(GMP): return newRational(x.bi / notZero(y.rat)))

        of Floating   || Integer        :   return newFloating(x.f / float(notZero(y.i)))
        of Floating   || BigInteger     :   (when defined(GMP): return newFloating(x.f / notZero(y.bi)))
        of Floating   || Floating       :   return newFloating(x.f / notZero(y.f))
        of Floating   || Rational       :   return newRational(toRational(x.f) / notZero(y.rat))

        of Rational   || Integer        :   return newRational(x.rat / notZero(y.i))
        of Rational   || BigInteger     :   (when defined(GMP): return newRational(x.rat / toRational(notZero(y.bi))))
        of Rational   || Floating       :   return newRational(x.rat / toRational(notZero(y.f)))
        of Rational   || Rational       :   return newRational(x.rat / notZero(y.rat))

        of Quantity   || Integer        :   return newQuantity(x.q // y.i)
        of Quantity   || BigInteger     :   (when defined(GMP): return newQuantity(x.q // y.bi))
        of Quantity   || Floating       :   return newQuantity(x.q // y.f)
        of Quantity   || Rational       :   return newQuantity(x.q // y.rat)
        of Quantity   || Quantity       :   return newQuantity(x.q // y.q)

f710ab2687745665c6ffa03f2bc65c347835f175

stale[bot] commented 1 week ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.