'use strict'

/*!
 * imports.
 */

var test = require('tape-catch')

/*!
 * imports (local).
 */

var appendUntil = require('./')

/*!
 * helper functions.
 */

function len (length) {
  return (list) => list.length === length
}

function incrementBy (val) {
  return (list) => list.pop() + val
}

/*!
 * tests.
 */

test('appendUntil()', function (t) {
  t.deepEqual(appendUntil(5, len(1)), [5], 'Defaults to empty array')
  t.deepEqual(appendUntil(3, len(3), []), [3, 3, 3], 'Static')
  t.deepEqual(appendUntil(incrementBy(5), len(4), [5]), [5, 10, 15, 20], 'Generator')
  t.throws(appendUntil.bind(null, 7, 47), 'Throws on bad predicate')
  t.end()
})

@@ -183,33 +183,52 @@
  %7B%0A  return 
-(list) =%3E
+function (list) %7B%0A    return
  list.length
@@ -239,16 +239,20 @@
  length%0A
+  %7D%0A
 %7D%0A%0Afunct
@@ -288,17 +288,36 @@
 urn 
-(list) =%3E
+function (list) %7B%0A    return
  lis
@@ -330,16 +330,20 @@
 ) + val%0A
+  %7D%0A
 %7D%0A%0A/*!%0A 

Fix test helpers such that they do not use arrow functions.