66 lines
1.5 KiB
YAML
66 lines
1.5 KiB
YAML
desc: Tests for basic usage of the add operation
|
|
tests:
|
|
- cd: r.add(1, 1)
|
|
ot: 2
|
|
|
|
- js: r(1).add(1)
|
|
py:
|
|
- r.expr(1) + 1
|
|
- 1 + r.expr(1)
|
|
- r.expr(1).add(1)
|
|
rb:
|
|
- r(1) + 1
|
|
- r(1).add(1)
|
|
ot: 2
|
|
|
|
- py: r.expr(-1) + 1
|
|
js: r(-1).add(1)
|
|
rb: (r -1) + 1
|
|
ot: 0
|
|
|
|
- py: r.expr(1.75) + 8.5
|
|
js: r(1.75).add(8.5)
|
|
rb: (r 1.75) + 8.5
|
|
ot: 10.25
|
|
|
|
# Add is polymorphic on strings
|
|
- py: r.expr('') + ''
|
|
js: r('').add('')
|
|
rb: (r '') + ''
|
|
ot: ''
|
|
|
|
- py: r.expr('abc') + 'def'
|
|
js: r('abc').add('def')
|
|
rb: (r 'abc') + 'def'
|
|
ot: 'abcdef'
|
|
|
|
# Add is polymorphic on arrays
|
|
- cd: r.expr([1,2]) + [3] + [4,5] + [6,7,8]
|
|
js: r([1,2]).add([3]).add([4,5]).add([6,7,8])
|
|
ot: [1,2,3,4,5,6,7,8]
|
|
|
|
# All arithmetic operations (except mod) actually support arbitrary arguments
|
|
# but this feature can't be accessed in Python because it's operators are binary
|
|
- js: r(1).add(2,3,4,5)
|
|
ot: 15
|
|
|
|
- js: r('a').add('b', 'c', 'd')
|
|
ot: 'abcd'
|
|
|
|
# Type errors
|
|
- cd: r(1).add('a')
|
|
py: r.expr(1) + 'a'
|
|
rb: r(1) + 'a'
|
|
ot: err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.", [1])
|
|
|
|
- cd: r('a').add(1)
|
|
py: r.expr('a') + 1
|
|
rb: r('a') + 1
|
|
ot: err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.", [1])
|
|
|
|
- cd: r([]).add(1)
|
|
py: r.expr([]) + 1
|
|
rb: r([]) + 1
|
|
ot: err("ReqlQueryLogicError", "Expected type ARRAY but found NUMBER.", [1])
|
|
|