126 lines
2.5 KiB
YAML
126 lines
2.5 KiB
YAML
# desc will be included in a comment to help identify test groups
|
|
desc: Tests of conversion to and from the RQL number type
|
|
tests:
|
|
|
|
# Simple integers
|
|
- cd: r.expr(1)
|
|
js:
|
|
- r(1)
|
|
- r.expr(1)
|
|
rb:
|
|
- r 1
|
|
- r(1)
|
|
- r.expr(1)
|
|
ot: 1
|
|
- cd: r.expr(-1)
|
|
js:
|
|
- r(-1)
|
|
- r.expr(-1)
|
|
rb:
|
|
- r -1
|
|
- r(-1)
|
|
- r.expr(-1)
|
|
ot: -1
|
|
- cd: r.expr(0)
|
|
js:
|
|
- r(0)
|
|
- r.expr(0)
|
|
rb:
|
|
- r 0
|
|
- r(0)
|
|
- r.expr(0)
|
|
ot: 0
|
|
|
|
# Floats
|
|
- cd: r.expr(1.0)
|
|
js:
|
|
- r(1.0)
|
|
- r.expr(1.0)
|
|
rb:
|
|
- r 1.0
|
|
- r(1.0)
|
|
- r.expr(1.0)
|
|
ot: 1.0
|
|
- cd: r.expr(1.5)
|
|
js:
|
|
- r(1.5)
|
|
- r.expr(1.5)
|
|
rb:
|
|
- r 1.5
|
|
- r(1.5)
|
|
- r.expr(1.5)
|
|
ot: 1.5
|
|
- cd: r.expr(-0.5)
|
|
js:
|
|
- r(-0.5)
|
|
- r.expr(-0.5)
|
|
rb:
|
|
- r -0.5
|
|
- r(-0.5)
|
|
- r.expr(-0.5)
|
|
ot: -0.5
|
|
- cd: r.expr(67498.89278)
|
|
js:
|
|
- r(67498.89278)
|
|
- r.expr(67498.89278)
|
|
rb:
|
|
- r 67498.89278
|
|
- r(67498.89278)
|
|
- r.expr(67498.89278)
|
|
ot: 67498.89278
|
|
|
|
# Big numbers
|
|
- cd: r.expr(1234567890)
|
|
js:
|
|
- r(1234567890)
|
|
- r.expr(1234567890)
|
|
rb:
|
|
- r 1234567890
|
|
- r(1234567890)
|
|
- r.expr(1234567890)
|
|
ot: 1234567890
|
|
|
|
- cd: r.expr(-73850380122423)
|
|
js:
|
|
- r.expr(-73850380122423)
|
|
- r(-73850380122423)
|
|
rb:
|
|
- r -73850380122423
|
|
- r.expr(-73850380122423)
|
|
- r(-73850380122423)
|
|
ot: -73850380122423
|
|
|
|
# Test that numbers round-trip correctly
|
|
- py:
|
|
cd: r.expr(1234567890123456789012345678901234567890)
|
|
ot: float(1234567890123456789012345678901234567890)
|
|
js:
|
|
cd: r.expr(1234567890123456789012345678901234567890)
|
|
ot: 1234567890123456789012345678901234567890
|
|
- cd: r.expr(123.4567890123456789012345678901234567890)
|
|
ot: 123.4567890123456789012345678901234567890
|
|
|
|
- cd: r.expr(1).type_of()
|
|
ot: 'NUMBER'
|
|
|
|
# test coercions
|
|
- cd: r.expr(1).coerce_to('string')
|
|
ot: '1'
|
|
|
|
- cd: r.expr(1).coerce_to('number')
|
|
ot: 1
|
|
|
|
# The drivers now convert to an int (where relevant) if we think the result
|
|
# looks like an int (result % 1.0 == 0.0)
|
|
- py: r.expr(1.0)
|
|
rb: r 1.0
|
|
ot: int_cmp(1)
|
|
|
|
- py: r.expr(45)
|
|
rb: r 45
|
|
ot: int_cmp(45)
|
|
|
|
- py: r.expr(1.2)
|
|
rb: r 1.2
|
|
ot: float_cmp(1.2)
|