arturo
arturo copied to clipboard
[VM/values/operators] [`+`] Verify for Web builds
[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#L461
#=======================================
# 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 =
## add given values and return the result
let pair = getValuePair()
case pair:
of Integer || Integer : return normalIntegerAdd(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)
7f3eb0b9d74712733ed82ac2505f1d6b81a690d4