<commit_before>var Ticker = require('./')
var test = require('tape')
var array = require('tween-array')

test('operates on obejcts', function(t) {
    var element = { x: 5, value: [1, 0] }

    var ticker = Ticker()
    var tween

    tween = ticker.to(element, { duration: 1, x: 10, delay: 1, value: [2, 4] })

    t.deepEqual(element, { x: 5, value: [1, 0] }, 'does not change until ticking')

    ticker.tick(1)
    t.deepEqual(element, { x: 5, value: [1, 0] }, 'delay is taken into account')

    ticker.tick(1)
    t.deepEqual(element, { x: 10, value: [2, 4] }, 'lerps arrays and numbers')


    //push a tween, animating A to B
    var target = {
        position: [0, 0],
        opacity: 0
    }
    tween = ticker.to(target, { position: [2, 4], opacity: 1, duration: 1 })
    ticker.tick(0.5)
    t.deepEqual(target, { opacity: 0.5, position: [ 1, 2 ] })

    t.end()
})

test('ducktypes tweens', function(t) {
    var start = [10, 10], end = [20, 50]
    var tween = array(start, end, 2.0)
    var ticker = Ticker()

    var obj = { x: 0 }<commit_msg>adding test for getter/setter<commit_after>var Ticker = require('./')
var test = require('tape')
var array = require('tween-array')

test('operates on obejcts', function(t) {
    var element = { x: 5, value: [1, 0] }

    var ticker = Ticker()
    var tween

    tween = ticker.to(element, { duration: 1, x: 10, delay: 1, value: [2, 4] })

    t.deepEqual(element, { x: 5, value: [1, 0] }, 'does not change until ticking')

    ticker.tick(1)
    t.deepEqual(element, { x: 5, value: [1, 0] }, 'delay is taken into account')

    ticker.tick(1)
    t.deepEqual(element, { x: 10, value: [2, 4] }, 'lerps arrays and numbers')


    //push a tween, animating A to B
    var target = {
        position: [0, 0],
        opacity: 0
    }
    tween = ticker.to(target, { position: [2, 4], opacity: 1, duration: 1 })
    ticker.tick(0.5)
    t.deepEqual(target, { opacity: 0.5, position: [ 1, 2 ] })

    t.end()
})


test('operates on getters/setters', function(t) {
    var element = { value: [1, 0] }
    var x = 5
    Object.defineProperty(element, 'x', {
        get: function() {
            return x
        },
        set: function(val) {
            x = val
        }
    })

    var ticker = Ticker()
    var tween

    tween = ticker.to(element, { duration: 1, x: 10, delay: 1, value: [2, 4] })

    t.equal(element.x, 5, 'does not change until ticking')

    ticker.tick(1)
    t.equal(element.x, 5, 'delay is taken into account')

    ticker.tick(1)
    t.equal(element.x, 10, 'lerps arrays and getter/setter')

    t.end()
})

test('ducktypes tweens', function(t) {
    var start = [10, 10], end = [20, 50]
    var tween = array(start, end, 2.0)
    var ticker = Ticker()

    var obj = { x: 0 }
{'fraction_non_alphanumeric': 0.16871832005792903, 'fraction_numerical': 0.03801593048515568, 'mean_word_length': 2.551413881748072, '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': '688263', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1021, 'n_words': 310}