arturo icon indicating copy to clipboard operation
arturo copied to clipboard

[VM/values/operators] [`-`] Verify for Web builds

Open github-actions[bot] opened this issue 1 year ago • 0 comments

[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#L585

            objectOperationOrNothing("inc", IncM, oneparam=true, 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 = 
    ## subtract given values and return the result

    let pair = getValuePair()
    case pair:
        of Integer    || Integer        :   return normalIntegerSub(x.i, y.i)
        of Integer    || BigInteger     :   (when BignumSupport: return newInteger(toBig(x.i) - y.bi))
        of BigInteger || Integer        :   (when BignumSupport: return newInteger(x.bi - toBig(y.i)))
        of BigInteger || BigInteger     :   (when BignumSupport: return newInteger(x.bi - y.bi))
        of Integer    || Floating       :   return newFloating(x.i - y.f)
        of BigInteger || Floating       :   (when defined(GMP): return newFloating(x.bi - y.f))
        of Integer    || Rational       :   return newRational(x.i - y.rat)
        of BigInteger || Rational       :   (when defined(GMP): return newRational(x.bi - y.rat))
        of Integer    || Complex        :   return newComplex(float(x.i) - y.z)

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

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

cdba73c6f61eb3e0269c2fcfae72305f9f194907

github-actions[bot] avatar Jan 19 '24 17:01 github-actions[bot]