         it 'allows compilers to return an array of functions to call when the compiled element is destroyed', asyncSpec (next) ->
           destructor1 = jasmine.createSpy('destructor1')
           destructor2 = jasmine.createSpy('destructor2')
-          up.$compiler '.child', ($element) ->
+          up.compiler '.child', (element) ->
             [ destructor1, destructor2 ]
 
-          up.hello(affix('.container .child'))
+          up.hello(affix('.container .child')[0])
 
           next =>
             expect(destructor1).not.toHaveBeenCalled()


        it 'runs compilers with higher priority first', ->
          traces = []
          up.$compiler '.element', { priority: 1 }, -> traces.push('foo')
          up.$compiler '.element', { priority: 2 }, -> traces.push('bar')
          up.$compiler '.element', { priority: 0 }, -> traces.push('baz')
          up.$compiler '.element', { priority: 3 }, -> traces.push('bam')
          up.$compiler '.element', { priority: -1 }, -> traces.push('qux')
          up.hello(affix('.element'))
          expect(traces).toEqual ['bam', 'bar', 'foo', 'baz', 'qux']

        it 'considers priority-less compilers to be priority zero', ->
          traces = []
          up.$compiler '.element', { priority: 1 }, -> traces.push('foo')
          up.$compiler '.element', -> traces.push('bar')
          up.$compiler '.element', { priority: -1 }, -> traces.push('baz')
          up.hello(affix('.element'))
          expect(traces).toEqual ['foo', 'bar', 'baz']

        it 'runs two compilers with the same priority in the order in which they were registered', ->
          traces = []
          up.$compiler '.element', { priority: 1 }, -> traces.push('foo')
          up.$compiler '.element', { priority: 1 }, -> traces.push('bar')
          up.hello(affix('.element'))
          expect(traces).toEqual ['foo', 'bar']

    describe 'up.$macro', ->

      it 'registers compilers that are run before other compilers', ->
        traces = []
        up.$compiler '.element', { priority: 10 }, -> traces.push('foo')
        up.$compiler '.element', { priority: -1000 }, -> traces.push('bar')
        up.$macro '.element', -> traces.push('baz')
        up.hello(affix('.element'))
        expect(traces).toEqual ['baz', 'foo' , 'bar']

      it 'allows to macros to have priorities of their own', ->
        traces = []
        up.$macro '.element', { priority: 1 }, -> traces.push('foo')
        up.$macro '.element', { priority: 2 }, -> traces.push('bar')
        up.$macro '.element', { priority: 0 }, -> traces.push('baz')
        up.$macro '.element', { priority: 3 }, -> traces.push('bam')
        up.$macro '.element', { priority: -1 }, -> traces.push('qux')
        up.$compiler '.element', { priority: 999 }, -> traces.push('ccc')
        up.hello(affix('.element'))
        expect(traces).toEqual ['bam', 'bar', 'foo', 'baz', 'qux', 'ccc']

      it 'runs two macros with the same priority in the order in which they were registered', ->
        traces = []
        up.$macro '.element', { priority: 1 }, -> traces.push('foo')
        up.$macro '.element', { priority: 1 }, -> traces.push('bar')
        up.hello(affix('.element'))
        expect(traces).toEqual ['foo', 'bar']

      it 'allows users to use the built-in [up-expand] from their own macros', ->
        up.$macro '.element', ($element) ->
          $element.attr('up-expand', '')
        $element = affix('.element a[href="/foo"][up-target=".target"]')
        up.hello($element)
        expect($element.attr('up-target')).toEqual('.target')
        expect($element.attr('up-href')).toEqual('/foo')

      it 'allows users to use the built-in [up-dash] from their own macros', ->
        up.$macro '.element', ($element) ->
          $element.attr('up-dash', '.target')
        $element = affix('a.element[href="/foo"]')
        up.hello($element)
        expect($element.attr('up-target')).toEqual('.target')

        it "does not consider a returned array to be a destructor unless it's comprised entirely of functions", asyncSpec (next) ->
          value1 = jasmine.createSpy('non-destructor')
          value2 = 'two'
          up.compiler '.child', (element) ->
            [ value1, value2 ]

          up.hello(affix('.container .child'))
