<commit_before>desc: Test the arity of every function
tests:

    # TODO: add test for slice (should require one or 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: partial({'tables_created':1})
    - def: tbl = db.table('test1')

    - ot: err("ReqlCompileError", "Expected 0 arguments but found 1.", [])
      cd: r.db_list(1)

    - ot: err("ReqlCompileError", "Expected 1 argument but found 2.", [])
      cd:
      - tbl.zip(1)
      - tbl.is_empty(1)
      - obj.keys(1)

    - cd: tbl.distinct(1)
      ot:
        cd: err("ReqlCompileError", "Expected 1 argument but found 2.", [])
        js: err("ReqlDriverError", "Expected 0 arguments (not including options) but found 1.", [])

    - cd: tbl.delete(1)
      ot:
        js: err("ReqlDriverError", "Expected 0 arguments (not including options) but found 1.", [])
        cd: err("ReqlCompileError", "Expected 1 argument but found 2.", [])

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

    - ot: err("ReqlCompileError", "Expected 1 argument but found 0.", [])
      cd:
      - r.db_create()
      - r.db_drop()
      - r.db()
      - r.floor()
      - r.ceil()
      - r.round()

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

    - cd: r.js()
      ot:
        cd: err("ReqlCompileError", "Expected 1 argument but found 0.", [])
        js: err("ReqlDriverError", "Expected 1 argument (not including options) but found 0.", [])

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

    - ot: err("ReqlCompileError", "Expected 2 arguments but found 1.", [])
      cd:
      - 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.offsets_of()
    - ot: err("ReqlCompileError", "Expected 1 argument but found 2.", [])
      cd:
      - r.db_create(1,2)
      - r.db_drop(1,2)
      - r.db(1,2)
      - r.floor(1, 2)
      - r.ceil(1, 2)
      - r.round(1, 2)

    - cd: tbl.filter()
      ot:
        js: err("ReqlDriverError", "Expected 1 argument (not including options) but found 0.", [])
        cd: err("ReqlCompileError", "Expected 2 arguments but found 1.", [])

    - cd: r.error(1, 2)
      ot: err("ReqlCompileError", "Expected between 0 and 1 arguments but found 2.", [])

    - cd: db.table_drop()
      ot: err("ReqlQueryLogicError", "Expected type DATUM but found DATABASE:", [])


    - cd: db.table_create()
      ot:
        cd: err("ReqlQueryLogicError", "Expected type DATUM but found DATABASE:", [])
        js: err("ReqlDriverError", "Expected 1 argument (not including options) but found 0.", [])

    - cd: r.js(1,2)
      ot:
        cd: err("ReqlCompileError", "Expected 1 argument but found 2.", [])
        js: err("ReqlDriverError", "Expected 1 argument (not including options) but found 2.", [])

    - ot: err("ReqlCompileError", "Expected 2 arguments but found 3.", [])
      cd:
      - 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.offsets_of(1,2)

    - cd: tbl.filter(1,2,3)
      ot:
        cd: err("ReqlCompileError", "Expected 2 arguments but found 4.", [])
        js: err("ReqlDriverError", "Expected 1 argument (not including options) but found 3.", [])

    - cd: db.table_drop(1,2)
      ot: err("ReqlCompileError", "Expected between 1 and 2 arguments but found 3.", [])

    - cd: r.expr([]).delete_at()
      ot: err("ReqlCompileError", "Expected between 2 and 3 arguments but found 1.", [])

    - cd: db.table_create(1,2)
      ot:
        cd: err("ReqlCompileError", "Expected between 1 and 2 arguments but found 3.", [])
        js: err("ReqlDriverError", "Expected 1 argument (not including options) but found 2.", [])

    - cd: tbl.count(1,2)
      ot: err("ReqlCompileError", "Expected between 1 and 2 arguments but found 3.", [])

    - ot:
        cd: err("ReqlCompileError", "Expected 2 arguments but found 1.", [])
        js: err("ReqlDriverError", "Expected 1 argument (not including options) but found 0.", [])
      cd:
      - tbl.update()
      - tbl.replace()
      - tbl.insert()
      - db.table()

    - cd: tbl.reduce()
      ot: err("ReqlCompileError", "Expected 2 arguments but found 1.", [])

    - cd: tbl.eq_join()
      ot:
        cd: err("ReqlCompileError", "Expected 3 arguments but found 1.", [])
        js: err("ReqlDriverError", "Expected 2 arguments (not including options) but found 0.", [])

    - ot: err("ReqlCompileError", "Expected 3 arguments but found 1.", [])
      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:
        cd: err("ReqlCompileError", "Expected 3 arguments but found 2.", [])
        js: err("ReqlDriverError", "Expected 2 arguments (not including options) but found 1.", [])

    - ot: err("ReqlCompileError", "Expected 3 arguments but found 2.", [])
      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:
        cd: err("ReqlCompileError", "Expected 3 arguments but found 5.", [])
        js: err("ReqlDriverError", "Expected 2 arguments (not including options) but found 4.", [])

    - ot: err("ReqlCompileError", "Expected 3 arguments but found 4.", [])
      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: err('ReqlCompileError', "Expected 2 or more arguments but found 1.", [])
      cd: tbl.get_all()

    - cd: tbl.map()
      ot:
        cd: err('ReqlCompileError', "Expected 2 or more arguments but found 1.", [])
        js: err('ReqlDriverError', "Expected 1 or more arguments but found 0.", [])

    - ot: err("ReqlCompileError", "Expected 3 arguments but found 2.", [])
      cd: r.branch(1,2)
    - ot: err("ReqlCompileError", "Expected 3 arguments but found 4.", [])
      cd: r.branch(1,2,3,4)

    - cd: r.expr({})[1,2]
      js: r.expr({})(1,2)
      ot:
        js: err('ReqlDriverError', "Expected 1 argument but found 2.", [])
        py: err('ReqlCompileError', 'Expected NUMBER or STRING as second argument to `bracket` but found ARRAY.')
        rb: err('ArgumentError', 'wrong number of arguments (2 for 1)')

    - cd: tbl.insert([{'id':0},{'id':1},{'id':2},{'id':3},{'id':4},{'id':5},{'id':6},{'id':7},{'id':8},{'id':9}]).get_field('inserted')
      ot: 10

    - cd: tbl.get_all(0, 1, 2).get_field('id')
      ot: bag([0, 1, 2])

    - cd: tbl.get_all(r.args([]), 0, 1, 2).get_field('id')
      ot: bag([0, 1, 2])

    - cd: tbl.get_all(r.args([0]), 1, 2).get_field('id')
      ot: bag([0, 1, 2])

    - cd: tbl.get_all(r.args([0, 1]), 2).get_field('id')
      ot: bag([0, 1, 2])

    - cd: tbl.get_all(r.args([0, 1, 2])).get_field('id')
      ot: bag([0, 1, 2])

    - cd: tbl.get_all(r.args([0]), 1, r.args([2])).get_field('id')
      ot: bag([0, 1, 2])
<commit_msg>fix rql_test/src/arity.yaml for branch()<commit_after>desc: Test the arity of every function
tests:

    # TODO: add test for slice (should require one or 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: partial({'tables_created':1})
    - def: tbl = db.table('test1')

    - ot: err("ReqlCompileError", "Expected 0 arguments but found 1.", [])
      cd: r.db_list(1)

    - ot: err("ReqlCompileError", "Expected 1 argument but found 2.", [])
      cd:
      - tbl.zip(1)
      - tbl.is_empty(1)
      - obj.keys(1)

    - cd: tbl.distinct(1)
      ot:
        cd: err("ReqlCompileError", "Expected 1 argument but found 2.", [])
        js: err("ReqlDriverError", "Expected 0 arguments (not including options) but found 1.", [])

    - cd: tbl.delete(1)
      ot:
        js: err("ReqlDriverError", "Expected 0 arguments (not including options) but found 1.", [])
        cd: err("ReqlCompileError", "Expected 1 argument but found 2.", [])

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

    - ot: err("ReqlCompileError", "Expected 1 argument but found 0.", [])
      cd:
      - r.db_create()
      - r.db_drop()
      - r.db()
      - r.floor()
      - r.ceil()
      - r.round()

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

    - cd: r.js()
      ot:
        cd: err("ReqlCompileError", "Expected 1 argument but found 0.", [])
        js: err("ReqlDriverError", "Expected 1 argument (not including options) but found 0.", [])

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

    - ot: err("ReqlCompileError", "Expected 2 arguments but found 1.", [])
      cd:
      - 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.offsets_of()
    - ot: err("ReqlCompileError", "Expected 1 argument but found 2.", [])
      cd:
      - r.db_create(1,2)
      - r.db_drop(1,2)
      - r.db(1,2)
      - r.floor(1, 2)
      - r.ceil(1, 2)
      - r.round(1, 2)

    - cd: tbl.filter()
      ot:
        js: err("ReqlDriverError", "Expected 1 argument (not including options) but found 0.", [])
        cd: err("ReqlCompileError", "Expected 2 arguments but found 1.", [])

    - cd: r.error(1, 2)
      ot: err("ReqlCompileError", "Expected between 0 and 1 arguments but found 2.", [])

    - cd: db.table_drop()
      ot: err("ReqlQueryLogicError", "Expected type DATUM but found DATABASE:", [])


    - cd: db.table_create()
      ot:
        cd: err("ReqlQueryLogicError", "Expected type DATUM but found DATABASE:", [])
        js: err("ReqlDriverError", "Expected 1 argument (not including options) but found 0.", [])

    - cd: r.js(1,2)
      ot:
        cd: err("ReqlCompileError", "Expected 1 argument but found 2.", [])
        js: err("ReqlDriverError", "Expected 1 argument (not including options) but found 2.", [])

    - ot: err("ReqlCompileError", "Expected 2 arguments but found 3.", [])
      cd:
      - 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.offsets_of(1,2)

    - cd: tbl.filter(1,2,3)
      ot:
        cd: err("ReqlCompileError", "Expected 2 arguments but found 4.", [])
        js: err("ReqlDriverError", "Expected 1 argument (not including options) but found 3.", [])

    - cd: db.table_drop(1,2)
      ot: err("ReqlCompileError", "Expected between 1 and 2 arguments but found 3.", [])

    - cd: r.expr([]).delete_at()
      ot: err("ReqlCompileError", "Expected between 2 and 3 arguments but found 1.", [])

    - cd: db.table_create(1,2)
      ot:
        cd: err("ReqlCompileError", "Expected between 1 and 2 arguments but found 3.", [])
        js: err("ReqlDriverError", "Expected 1 argument (not including options) but found 2.", [])

    - cd: tbl.count(1,2)
      ot: err("ReqlCompileError", "Expected between 1 and 2 arguments but found 3.", [])

    - ot:
        cd: err("ReqlCompileError", "Expected 2 arguments but found 1.", [])
        js: err("ReqlDriverError", "Expected 1 argument (not including options) but found 0.", [])
      cd:
      - tbl.update()
      - tbl.replace()
      - tbl.insert()
      - db.table()

    - cd: tbl.reduce()
      ot: err("ReqlCompileError", "Expected 2 arguments but found 1.", [])

    - cd: tbl.eq_join()
      ot:
        cd: err("ReqlCompileError", "Expected 3 arguments but found 1.", [])
        js: err("ReqlDriverError", "Expected 2 arguments (not including options) but found 0.", [])

    - ot: err("ReqlCompileError", "Expected 3 arguments but found 1.", [])
      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:
        cd: err("ReqlCompileError", "Expected 3 arguments but found 2.", [])
        js: err("ReqlDriverError", "Expected 2 arguments (not including options) but found 1.", [])

    - ot: err("ReqlCompileError", "Expected 3 arguments but found 2.", [])
      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:
        cd: err("ReqlCompileError", "Expected 3 arguments but found 5.", [])
        js: err("ReqlDriverError", "Expected 2 arguments (not including options) but found 4.", [])

    - ot: err("ReqlCompileError", "Expected 3 arguments but found 4.", [])
      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: err('ReqlCompileError', "Expected 2 or more arguments but found 1.", [])
      cd: tbl.get_all()

    - cd: tbl.map()
      ot:
        cd: err('ReqlCompileError', "Expected 2 or more arguments but found 1.", [])
        js: err('ReqlDriverError', "Expected 1 or more arguments but found 0.", [])

    - cd: r.branch(1,2)
      ot: err("ReqlCompileError", "Expected 3 or more arguments but found 2.", [])
    - cd: r.branch(1,2,3,4)
      ot: err("ReqlQueryLogicError", "Cannot call `branch` term with an even number of arguments.", [])

    - cd: r.expr({})[1,2]
      js: r.expr({})(1,2)
      ot:
        js: err('ReqlDriverError', "Expected 1 argument but found 2.", [])
        py: err('ReqlCompileError', 'Expected NUMBER or STRING as second argument to `bracket` but found ARRAY.')
        rb: err('ArgumentError', 'wrong number of arguments (2 for 1)')

    - cd: tbl.insert([{'id':0},{'id':1},{'id':2},{'id':3},{'id':4},{'id':5},{'id':6},{'id':7},{'id':8},{'id':9}]).get_field('inserted')
      ot: 10

    - cd: tbl.get_all(0, 1, 2).get_field('id')
      ot: bag([0, 1, 2])

    - cd: tbl.get_all(r.args([]), 0, 1, 2).get_field('id')
      ot: bag([0, 1, 2])

    - cd: tbl.get_all(r.args([0]), 1, 2).get_field('id')
      ot: bag([0, 1, 2])

    - cd: tbl.get_all(r.args([0, 1]), 2).get_field('id')
      ot: bag([0, 1, 2])

    - cd: tbl.get_all(r.args([0, 1, 2])).get_field('id')
      ot: bag([0, 1, 2])

    - cd: tbl.get_all(r.args([0]), 1, r.args([2])).get_field('id')
      ot: bag([0, 1, 2])

{'fraction_non_alphanumeric': 0.18448776943569872, 'fraction_numerical': 0.031000242189392103, 'mean_word_length': 2.456162377066332, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3924000', 'n_tokens_mistral': 6229, 'n_tokens_neox': 5683, 'n_words': 1506}