<commit_before>describe 'acceptance', ->
  Given -> @v = require '../lib'
  Given -> @cb = sinon.spy()

  describe 'type syntax', ->
    context 'all types match', ->
      Given -> @fn = sinon.spy()
      Given -> @wrapped = @v Array, Function, @cb
      When -> @wrapped [1,2], @fn
      Then -> expect(@cb).to.have.been.calledWith [1,2], @fn

    context 'first type matches', ->
      Given -> @wrapped = @v Array, Function, @cb
      When -> @wrapped [1,2]
      Then -> expect(@cb).to.have.been.calledWith [1,2], undefined

    context 'second type matches', ->
      Given -> @fn = sinon.spy()
      Given -> @wrapped = @v Array, Function, @cb
      When -> @wrapped @fn
      Then -> expect(@cb).to.have.been.calledWith undefined, @fn

    context 'with a default', ->
      Given -> @v.populate 'Array', ['foo', 'bar']
      Given -> @fn = sinon.spy()
      Given -> @wrapped = @v Array, Function, @cb
      When -> @wrapped @fn
      Then -> expect(@cb).to.have.been.calledWith ['foo', 'bar'], @fn

    context 'with a custom type', ->
      Given -> @Foo = class Foo
      Given -> @wrapped = @v Array, @Foo, @cb
      Given -> @foo = new @Foo()
      When -> @wrapped [], @foo
      Then -> expect(@cb).to.have.been.calledWith [], @foo

    context 'custom type with a default', ->
      Given -> @Foo = class Foo
        constructor: (key, val) ->
          @[key] = val
      Given -> @v.populate 'Foo', new @Foo('foo', 'bar')
      Given -> @wrapped = @v @Foo, @cb
      When -> @wrapped()
      And -> @fooArg = @cb.getCall(0).args[0]
      Then -> expect(@fooArg.foo).to.equal 'bar'

  describe 'array syntax', ->
    context 'all types match', ->
      Given -> @fn = sinon.spy()
      Given -> @wrapped = @v ['array', 'function'], @cb
      When -> @wrapped [1,2], @fn
      Then -> expect(@cb).to.have.been.calledWith [1,2], @fn

    context 'first type matches', ->
      Given -> @wrapped = @v ['array', 'function'], @cb
      When -> @wrapped [1,2]
      Then -> expect(@cb).to.have.been.calledWith [1,2], undefined

    context 'second type matches', ->
      Given -> @fn = sinon.spy()
      Given -> @wrapped = @v ['array', 'function'], @cb
      When -> @wrapped @fn
      Then -> expect(@cb).to.have.been.calledWith undefined, @fn

    context 'with a default', ->
      Given -> @v.populate 'Array', ['foo', 'bar']
      Given -> @fn = sinon.spy()
      Given -> @wrapped = @v ['array', 'function'], @cb
      When -> @wrapped @fn
      Then -> expect(@cb).to.have.been.calledWith ['foo', 'bar'], @fn

    context 'with a custom type', ->
      Given -> @Foo = class Foo
      Given -> @wrapped = @v ['Array', 'Foo'], @cb
      Given -> @foo = new @Foo()
      When -> @wrapped [1], @foo
      Then -> expect(@cb).to.have.been.calledWith [1], @foo

  describe 'letter syntax', ->
    context 'all types match', ->
      Given -> @fn = sinon.spy()
      Given -> @wrapped = @v 'af', @cb
      When -> @wrapped [1,2], @fn
      Then -> expect(@cb).to.have.been.calledWith [1,2], @fn

    context 'first type matches', ->
      Given -> @wrapped = @v 'af', @cb
      When -> @wrapped [1,2]
      Then -> expect(@cb).to.have.been.calledWith [1,2], undefined

    context 'second type matches', ->
      Given -> @fn = sinon.spy()
      Given -> @wrapped = @v 'af', @cb
      When -> @wrapped @fn
      Then -> expect(@cb).to.have.been.calledWith undefined, @fn

    context 'with -', ->
      Given -> @wrapped = @v '-oo', @cb
      When -> @wrapped {}
      Then -> expect(@cb).to.have.been.calledWith undefined, {}

    context 'with +', ->
      Given -> @wrapped = @v '+a+o', @cb
      When -> @wrapped()
      Then -> expect(@cb).to.have.been.calledWith [], {}

    context 'with _', ->
      Given -> @v.defaults 'Array', [1,2]
      Given -> @wrapped = @v '_as', @cb
      When -> @wrapped [], 'string'
      Then -> expect(@cb).to.have.been.calledWith [1,2], 'string'

    context 'with &', ->
      Given -> @v.extend 'Object', { foo: 'bar' }
      Given -> @v.extend 'Array', [3, 4]
      Given -> @v.extend 'String', 'world'
      Given -> @v.extend 'Function', (name) -> name.split('').reverse().join('')
      Given -> @wrapped = @v '&o&a&s&f', @cb
      When -> @wrapped { baz: 'quux' }, [1, 2], 'hello', (rev) -> rev.split('').join(' ')
      Then -> expect(@cb).to.have.been.calledWith
        foo: 'bar'
        baz: 'quux'<commit_msg>Fix bug with 'defaults' being changed<commit_after>describe 'acceptance', ->
  Given -> @v = require '../lib'
  Given -> @cb = sinon.spy()

  describe 'type syntax', ->
    context 'all types match', ->
      Given -> @fn = sinon.spy()
      Given -> @wrapped = @v Array, Function, @cb
      When -> @wrapped [1,2], @fn
      Then -> expect(@cb).to.have.been.calledWith [1,2], @fn

    context 'first type matches', ->
      Given -> @wrapped = @v Array, Function, @cb
      When -> @wrapped [1,2]
      Then -> expect(@cb).to.have.been.calledWith [1,2], undefined

    context 'second type matches', ->
      Given -> @fn = sinon.spy()
      Given -> @wrapped = @v Array, Function, @cb
      When -> @wrapped @fn
      Then -> expect(@cb).to.have.been.calledWith undefined, @fn

    context 'with a default', ->
      Given -> @v.populate 'Array', ['foo', 'bar']
      Given -> @fn = sinon.spy()
      Given -> @wrapped = @v Array, Function, @cb
      When -> @wrapped @fn
      Then -> expect(@cb).to.have.been.calledWith ['foo', 'bar'], @fn

    context 'with a custom type', ->
      Given -> @Foo = class Foo
      Given -> @wrapped = @v Array, @Foo, @cb
      Given -> @foo = new @Foo()
      When -> @wrapped [], @foo
      Then -> expect(@cb).to.have.been.calledWith [], @foo

    context 'custom type with a default', ->
      Given -> @Foo = class Foo
        constructor: (key, val) ->
          @[key] = val
      Given -> @v.populate 'Foo', new @Foo('foo', 'bar')
      Given -> @wrapped = @v @Foo, @cb
      When -> @wrapped()
      And -> @fooArg = @cb.getCall(0).args[0]
      Then -> expect(@fooArg.foo).to.equal 'bar'

  describe 'array syntax', ->
    context 'all types match', ->
      Given -> @fn = sinon.spy()
      Given -> @wrapped = @v ['array', 'function'], @cb
      When -> @wrapped [1,2], @fn
      Then -> expect(@cb).to.have.been.calledWith [1,2], @fn

    context 'first type matches', ->
      Given -> @wrapped = @v ['array', 'function'], @cb
      When -> @wrapped [1,2]
      Then -> expect(@cb).to.have.been.calledWith [1,2], undefined

    context 'second type matches', ->
      Given -> @fn = sinon.spy()
      Given -> @wrapped = @v ['array', 'function'], @cb
      When -> @wrapped @fn
      Then -> expect(@cb).to.have.been.calledWith undefined, @fn

    context 'with a default', ->
      Given -> @v.populate 'Array', ['foo', 'bar']
      Given -> @fn = sinon.spy()
      Given -> @wrapped = @v ['array', 'function'], @cb
      When -> @wrapped @fn
      Then -> expect(@cb).to.have.been.calledWith ['foo', 'bar'], @fn

    context 'with a custom type', ->
      Given -> @Foo = class Foo
      Given -> @wrapped = @v ['Array', 'Foo'], @cb
      Given -> @foo = new @Foo()
      When -> @wrapped [1], @foo
      Then -> expect(@cb).to.have.been.calledWith [1], @foo

  describe 'letter syntax', ->
    context 'all types match', ->
      Given -> @fn = sinon.spy()
      Given -> @wrapped = @v 'af', @cb
      When -> @wrapped [1,2], @fn
      Then -> expect(@cb).to.have.been.calledWith [1,2], @fn

    context 'first type matches', ->
      Given -> @wrapped = @v 'af', @cb
      When -> @wrapped [1,2]
      Then -> expect(@cb).to.have.been.calledWith [1,2], undefined

    context 'second type matches', ->
      Given -> @fn = sinon.spy()
      Given -> @wrapped = @v 'af', @cb
      When -> @wrapped @fn
      Then -> expect(@cb).to.have.been.calledWith undefined, @fn

    context 'with -', ->
      Given -> @wrapped = @v '-oo', @cb
      When -> @wrapped {}
      Then -> expect(@cb).to.have.been.calledWith undefined, {}

    context 'with +', ->
      Given -> @wrapped = @v '+a+o', @cb
      When -> @wrapped()
      Then -> expect(@cb).to.have.been.calledWith [], {}

    context 'called more than once with +', ->
      Given -> @wrapped = @v '+os', (@obj, foo) =>
        @obj.foo = @obj.foo || foo
      When -> @wrapped('bar')
      And -> @wrapped('baz')
      Then -> expect(@obj.foo).to.equal 'baz'

    context 'with _', ->
      Given -> @v.defaults 'Array', [1,2]
      Given -> @wrapped = @v '_as', @cb
      When -> @wrapped [], 'string'
      Then -> expect(@cb).to.have.been.calledWith [1,2], 'string'

    context 'with &', ->
      Given -> @v.extend 'Object', { foo: 'bar' }
      Given -> @v.extend 'Array', [3, 4]
      Given -> @v.extend 'String', 'world'
      Given -> @v.extend 'Function', (name) -> name.split('').reverse().join('')
      Given -> @wrapped = @v '&o&a&s&f', @cb
      When -> @wrapped { baz: 'quux' }, [1, 2], 'hello', (rev) -> rev.split('').join(' ')
      Then -> expect(@cb).to.have.been.calledWith
        foo: 'bar'
        baz: 'quux'
{'fraction_non_alphanumeric': 0.2062770322723744, 'fraction_numerical': 0.007984917378285461, 'mean_word_length': 2.226475849731664, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 215, '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': '624394', 'n_tokens_mistral': 3136, 'n_tokens_neox': 3025, 'n_words': 844}