desc: Test the arity of every function
tests:

    # TODO: add test for slice (should require two arguments)

    # Set up some data
    - def: db = r.db('test')
    - def: obj = r.expr({'a':1})
    - def: array = r.expr([1])
    - cd: db.table_create('test1')
      ot: ({'created':1})
      def: tbl = db.table('test1')

    - ot:
        js: err("RqlDriverError", "Expected 0 argument(s) but found 1.", [])
        rb: err("RqlCompileError", "Expected 0 argument(s) but found 1.", [])
        py: err_regex("TypeError", ".* takes no arguments \(1 given\)", [])
      cd:
      - r.db_list(1)

    - ot:
        js: err("RqlDriverError", "Expected 0 argument(s) but found 1.", [])
        rb: err("RqlCompileError", "Expected 1 argument(s) but found 2.", [])
        py: err_regex("TypeError", ".* takes exactly 1 argument \(2 given\)", [])
      cd:
      - tbl.zip(1)
      - tbl.distinct(1)
      - tbl.is_empty(1)
      - obj.keys(1)

    - ot:
        js: err("RqlDriverError", "Expected 0 argument(s) but found 1.", [])
        rb: err("RqlCompileError", "Expected 1 argument(s) but found 2.", [])
        py: err_regex("RqlRuntimeError", u'Expected type STRING but found NUMBER.')
      cd:
      - tbl.delete(1)

    - rb: db.table_list(1)
      ot: err("RqlCompileError", "Expected between 0 and 1 arguments but found 2.", [])


    - ot:
        js: err("RqlDriverError", "Expected 1 argument(s) but found 0.", [])
        rb: err("RqlCompileError", "Expected 1 argument(s) but found 0.", [])
        py: err_regex('TypeError', ".*takes exactly 1 argument \(0 given\)", [])
      cd:
      - r.db_create()
      - r.db_drop()
      - r.db()

    - cd: r.error()
      ot: err("RqlRuntimeError", "Empty ERROR term outside a default block.", [])

    - cd: r.js()
      ot:
        js: err("RqlDriverError", "Expected 1 argument(s) but found 0.", [])
        rb: err("RqlCompileError", "Expected 1 argument(s) but found 0.", [])
        py: err_regex('TypeError', ".*takes at least 1 argument \(0 given\)", [])

    - cd: r.expr()
      ot:
        py: err_regex('TypeError', ".*takes at least 1 argument \(0 given\)", [])
        js: err("RqlDriverError", "Expected between 1 and 2 argument(s) but found 0.", [])
        rb: err_regex("ArgumentError", '.*wrong number of arguments \(0 for 1.*\)', [])

    - ot:
        js: err("RqlDriverError", "Expected 1 argument(s) but found 0.", [])
        rb: err("ArgumentError", "wrong number of arguments (0 for 1)", [])
        py: err_regex('TypeError', ".*takes exactly 1 argument \(0 given\)", [])
      cd:
      - r.sum()
      - r.avg()

    - ot:
        js: err("RqlDriverError", "Expected 1 argument(s) but found 0.", [])
        rb: err("RqlCompileError", "Expected 2 argument(s) but found 1.", [])
        py: err_regex('TypeError', ".*takes exactly 2 arguments \(1 given\)", [])
      cd:
      - tbl.map()
      - tbl.concat_map()
      - tbl.skip()
      - tbl.limit()
      - array.append()
      - array.prepend()
      - array.difference()
      - array.set_insert()
      - array.set_union()
      - array.set_intersection()
      - array.set_difference()
      - tbl.nth()
      - tbl.for_each()
      - tbl.get()
      - r.expr([]).sample()
      - tbl.indexes_of()
    - ot:
        js: err("RqlDriverError", "Expected 1 argument(s) but found 2.", [])
        rb: err("RqlCompileError", "Expected 1 argument(s) but found 2.", [])
        py: err_regex('TypeError', ".*takes exactly 1 argument \(2 given\)", [])
      cd:
      - r.db_create(1,2)
      - r.db_drop(1,2)
      - r.db(1,2)

    - ot:
        js: err("RqlDriverError", "Expected 1 argument(s) but found 0.", [])
        rb: err("RqlCompileError", "Expected 2 argument(s) but found 1.", [])
        py: err_regex('TypeError', ".*takes at least 2 arguments \(1 given\)", [])
      cd:
      - tbl.filter()

    - cd: r.error(1, 2)
      ot:
        rb: err("RqlCompileError", "Expected between 0 and 1 arguments but found 2.", [])
        py: err("RqlCompileError", "Expected between 0 and 1 arguments but found 2.", [])
        js: err("RqlDriverError", "Expected between 0 and 1 argument(s) but found 2.", [])

    - cd:
      - db.table_drop()
      ot:
        rb: err("RqlRuntimeError", "Expected type DATUM but found DATABASE.", [])
        js: err("RqlDriverError", "Expected 1 argument(s) but found 0.", [])
        py: err_regex('TypeError', ".*takes exactly 2 arguments \(1 given\)", [])


    - cd: db.table_create()
      ot:
        rb: err("RqlRuntimeError", "Expected type DATUM but found DATABASE.", [])
        js: err("RqlDriverError", "Expected 1 argument(s) but found 0.", [])
        py: err_regex('TypeError', ".*takes at least 2 arguments \(1 given\)", [])

    - cd: r.js(1,2)
      ot:
        js: err("RqlDriverError", "Expected 1 argument(s) but found 2.", [])
        rb: err("RqlCompileError", "Expected 1 argument(s) but found 2.", [])
        py: err('RqlRuntimeError', u"Expected type STRING but found NUMBER.", [])

    - ot:
        js: err("RqlDriverError", "Expected 1 argument(s) but found 2.", [])
        rb: err("ArgumentError", "wrong number of arguments (2 for 1)", [])
        py: err_regex('TypeError', ".*takes exactly 1 argument \(2 given\)", [])
      cd:
      - r.sum(1,2)
      - r.avg(1,2)
    - ot:
        js: err("RqlDriverError", "Expected 1 argument(s) but found 2.", [])
        rb: err("RqlCompileError", "Expected 2 argument(s) but found 3.", [])
        py: err_regex('TypeError', ".*takes exactly 2 arguments \(3 given\)", [])
      cd:
      - tbl.map(1,2)
      - tbl.concat_map(1,2)
      - tbl.skip(1,2)
      - tbl.limit(1,2)
      - array.append(1,2)
      - array.prepend(1,2)
      - array.difference([], [])
      - array.set_insert(1,2)
      - array.set_union([1],[2])
      - array.set_intersection([1],[2])
      - array.set_difference([1],[2])
      - tbl.nth(1,2)
      - tbl.for_each(1,2)
      - tbl.get(1,2)
      - r.expr([]).sample(1,2)
      - tbl.indexes_of(1,2)

    - ot:
        js: err("RqlDriverError", "Expected 1 argument(s) but found 3.", [])
        rb: err("RqlCompileError", "Expected 2 argument(s) but found 4.", [])
        py: err_regex('TypeError', ".*takes at most 3 arguments \(4 given\)", [])
      cd:
      - tbl.filter(1,2,3)

    - cd: db.table_drop(1,2)
      ot:
        rb: err("RqlCompileError", "Expected between 1 and 2 arguments but found 3.", [])
        js: err("RqlDriverError", "Expected 1 argument(s) but found 2.", [])
        py: err_regex('TypeError', ".*takes exactly 2 arguments \(3 given\)", [])

    - cd: r.expr([]).delete_at()
      ot:
        rb: err("RqlCompileError", "Expected between 2 and 3 arguments but found 1.", [])
        js: err("RqlDriverError", "Expected between 1 and 2 argument(s) but found 0.", [])
        py: err("RqlCompileError", "Expected between 2 and 3 arguments but found 1.", [])

    - cd: db.table_create(1,2)
      ot:
        rb: err("RqlCompileError", "Expected between 1 and 2 arguments but found 3.", [])
        js: err("RqlDriverError", "Expected 1 argument(s) but found 2.", [])
        py: err_regex('RqlRuntimeError', "Expected type STRING but found NUMBER", [])

    - cd: tbl.count(1,2)
      ot:
        rb: err("RqlCompileError", "Expected between 1 and 2 arguments but found 3.", [])
        js: err("RqlDriverError", "Expected between 0 and 1 argument(s) but found 2.", [])
        py: err("TypeError", "count() takes at most 2 arguments (3 given)", [])

    - ot:
        js: err("RqlDriverError", "Expected 1 argument(s) but found 0.", [])
        rb: err("RqlCompileError", "Expected 2 argument(s) but found 1.", [])
        py: err_regex('TypeError', ".*takes at least 2 arguments \(1 given\)", [])
      cd:
      - tbl.update()
      - tbl.replace()
      - tbl.insert()
      # - db.table() # TODO: theerror message for this in ruby is wrong

    - cd: tbl.reduce()
      ot: 
        js: err("RqlDriverError", "Expected between 1 and 2 argument(s) but found 0.", [])
        rb: err("RqlCompileError", "Expected 2 argument(s) but found 1.", [])
        py: err_regex('TypeError', ".*takes at least 2 arguments \(1 given\)", [])


    - cd: tbl.eq_join()
      ot:
        js: err("RqlDriverError", "Expected 2 argument(s) but found 0.", [])
        rb: err("RqlCompileError", "Expected 3 argument(s) but found 1.", [])
        py: err_regex('TypeError', ".*takes at least 3 arguments \(1 given\)", [])

    - ot:
        js: err("RqlDriverError", "Expected 2 argument(s) but found 0.", [])
        rb: err("RqlCompileError", "Expected 3 argument(s) but found 1.", [])
        py: err_regex('TypeError', ".*takes exactly 3 arguments \(1 given\)", [])
      cd:
      - tbl.inner_join()
      - tbl.outer_join()
      - r.expr([]).insert_at()
      - r.expr([]).splice_at()
      - r.expr([]).change_at()

    - cd:
      - tbl.eq_join(1)
      ot:
        js: err("RqlDriverError", "Expected 2 argument(s) but found 1.", [])
        rb: err("RqlCompileError", "Expected 3 argument(s) but found 2.", [])
        py: err_regex('TypeError', ".*takes at least 3 arguments \(2 given\)", [])

    - ot:
        js: err("RqlDriverError", "Expected 2 argument(s) but found 1.", [])
        rb: err("RqlCompileError", "Expected 3 argument(s) but found 2.", [])
        py: err_regex('TypeError', ".*takes exactly 3 arguments \(2 given\)", [])
      cd:
      - tbl.inner_join(1)
      - tbl.outer_join(1)
      - r.expr([]).insert_at(1)
      - r.expr([]).splice_at(1)
      - r.expr([]).change_at(1)

    - cd: tbl.eq_join(1,2,3,4)
      ot:
        js: err("RqlDriverError", "Expected 2 argument(s) but found 4.", [])
        rb: err("RqlCompileError", "Expected 3 argument(s) but found 5.", [])
        py: err_regex('TypeError', ".*takes at most 4 arguments \(5 given\)", [])

    - ot:
        js: err("RqlDriverError", "Expected 2 argument(s) but found 3.", [])
        rb: err("RqlCompileError", "Expected 3 argument(s) but found 4.", [])
        py: err_regex('TypeError', ".*takes exactly 3 arguments \(4 given\)", [])
      cd:
      - tbl.inner_join(1,2,3)
      - tbl.outer_join(1,2,3)
      - r.expr([]).insert_at(1, 2, 3)
      - r.expr([]).splice_at(1, 2, 3)
      - r.expr([]).change_at(1, 2, 3)

    - ot:
        js: err("RqlDriverError", "Expected 2 or more argument(s) but found 0.", [])
        rb: err("RqlCompileError", "Invalid aggregator for GROUPBY.", [])
        py: err_regex('TypeError', ".*takes at least 3 arguments \(1 given\)", [])
      cd:
      - tbl.group_by()

    - ot:
        js: err("RqlCompileError", "Expected 2 or more argument(s) but found 1.", [])
        rb: err("RqlCompileError", "Expected 2 or more argument(s) but found 1.", [])
        py: err('RqlCompileError', "Expected 2 or more argument(s) but found 1.", [])
      cd:
      - tbl.get_all()

    - ot:
        js: err("RqlDriverError", "Expected 3 argument(s) but found 2.", [])
        rb: err("RqlCompileError", "Expected 3 argument(s) but found 2.", [])
        py: err_regex('TypeError', ".*takes exactly 3 arguments \(2 given\)", [])
      cd: r.branch(1,2)
    - ot:
        js: err("RqlDriverError", "Expected 3 argument(s) but found 4.", [])
        rb: err("RqlCompileError", "Expected 3 argument(s) but found 4.", [])
        py: err_regex('TypeError', ".*takes exactly 3 arguments \(4 given\)", [])
      cd: r.branch(1,2,3,4)

    - ot:
        js: err("RqlDriverError", "Expected between 3 and 4 argument(s) but found 2.", [])
        rb: err("RqlCompileError", "Expected 4 argument(s) but found 2.", [])
        py: err_regex('TypeError', ".*takes at least 4 arguments \(3 given\)", [])
      cd: tbl.grouped_map_reduce(1,2)

    - ot: err("RqlDriverError", "Expected 1 argument(s) but found 2.", [])
      js: r.expr({})(1,2)
      py: []
      rb: []


    # TODO: Math and logic
    # TODO: Upper bound on optional arguments
    # TODO: between, merge, slice

    # Clean up
    - cd: db.table_drop('test1')
      ot: ({'dropped':1})
