                 that.index++
                 that.test()
                 return false
-        is_state_1: (query, cursor, expected_result, that) =>
-            @results = []
-            cursor.next (data) =>
-                if data?
-                    @results.push data
-                    return true
-                @display _.isEqual(demo_server.dbs, state[1]), query, @results
-                that.index++
-                that.test()
-                return false
         is_doc_1: (query, cursor, expected_result, that) =>
             @results = []
             cursor.next (data) =>

# TODO
# Refactor the test functions

state =
    1:
        test:
            test:
                data:
                    "N1":
                        id: 1
                    "N2":
                        id: 2
                    "N3":
                        id: 3
    2:
        test:
            test:
                data:
                    "N1":
                        id: 1
                        key: 1
                    "N2":
                        id: 2
                        key: 2
                    "N3":
                        id: 3
                        key: 3
                options:
                    'primary_key': 'id'
    3:
        test:
            test:
                data:
                    "N2":
                        id: 2
                        key: 3
                    "N5":
                        id: 5
                        key: 3
                    "N4":
                        id: 4
                        key: 1
                    "N1":
                        id: 1
                        key: 1
                    "N3":
                        id: 3
                        key: 2

class Tests
    results: []

        query = @queries[@index]
        if query?
            console.log query.query
            if query.collection?
                r.dbDrop('test').run()
                r.dbCreate('test').run()
                r.db('test').tableCreate('test').run()
                for element in query.collection
                    r.db('test').table('test').insert(element).run()
                
            cursor = eval(query.query)
            @callback()[query.callback_name](query.query, cursor, query.expected_result, @)

    display: (success, query, results) ->
        if success is true
