<commit_before>﻿namespace PreviewTween
{
    using System.Collections;
    using NUnit.Framework;
    using UnityEngine;
    using UnityEngine.TestTools;

    public sealed class TestTween : TweenBase
    {
        private float _start;
        private float _end;
        private float _value;

        public float start
        {
            get { return _start; }
            set { _start = value; }
        }

        public float end
        {
            get { return _end; }
            set { _end = value; }
        }

        public float value { get { return _value; } }

        public override void RecordStart()
        {
            // Used by the editor so it doesnt matter here
        }

        public override void RecordEnd()
        {
            // Used by the editor so it doesnt matter here
        }

        protected override void UpdateValue(float smoothTime)
        {
            _value = Mathf.LerpUnclamped(start, end, smoothTime);
        }
    }

    public sealed class TweenBaseTests
    {
        private GameObject _tweenObject;
        private TestTween _tween;

        [SetUp]
        public void SetUp()
        {
            _tweenObject = new GameObject("Tween");
            _tween = _tweenObject.AddComponent<TestTween>();
        }

        [TearDown]
        public void TearDown()
        {
            Object.DestroyImmediate(_tweenObject);
        }

        [Test]
        public void Apply_ProgressZero_HasStartValue()
        {
            _tween.start = 10f;
            _tween.end = 25f;
            _tween.Apply();

            Assert.AreEqual(10f, _tween.value);
        }

        [Test]
        public void Apply_ProgressHalf_HasMiddleValue()
        {
            _tween.start = 10f;
            _tween.end = 20f;
            _tween.progress = 0.5f;
            _tween.Apply();

            Assert.AreEqual(15f, _tween.value);
        }

        [Test]
        public void Apply_ProgressOne_HasEndValue()
        {
            _tween.start = 10f;
            _tween.end = 25f;
            _tween.progress = 1f;
            _tween.Apply();

            Assert.AreEqual(25f, _tween.value);
        }

        [Test]
        public void Play_ImmediatelyHasStartValue()
        {
            _tween.start = 10f;
            _tween.end = 20f;

            _tween.Play();

            Assert.AreEqual(10f, _tween.value);
        }

        [UnityTest]
        public IEnumerator Play_DefaultDuration_SetsValueToEnd()
        {
            _tween.start = 10f;
            _tween.end = 20f;

            _tween.Play();
            Assert.IsTrue(_tween.isPlaying);
            yield return new WaitForSeconds(1f);

            Assert.IsFalse(_tween.isPlaying);

            Assert.AreEqual(20f, _tween.value);
        }

        [UnityTest]
        public IEnumerator Play_CallingMoreThanOnce_DoesntEndFaster()
        {
            _tween.start = 10f;
            _tween.end = 20f;

            _tween.Play();
            _tween.Play();
            _tween.Play();
            _tween.Play();

            Assert.IsTrue(_tween.isPlaying);
            yield return new WaitForSeconds(0.5f);
            Assert.IsTrue(_tween.isPlaying);
            yield return new WaitForSeconds(0.5f);

            Assert.IsFalse(_tween.isPlaying);
<commit_msg>Added a test for going backwards<commit_after>﻿namespace PreviewTween
{
    using System.Collections;
    using NUnit.Framework;
    using UnityEngine;
    using UnityEngine.TestTools;

    public sealed class TestTween : TweenBase
    {
        private float _start;
        private float _end;
        private float _value;

        public float start
        {
            get { return _start; }
            set { _start = value; }
        }

        public float end
        {
            get { return _end; }
            set { _end = value; }
        }

        public float value { get { return _value; } }

        public override void RecordStart()
        {
            // Used by the editor so it doesnt matter here
        }

        public override void RecordEnd()
        {
            // Used by the editor so it doesnt matter here
        }

        protected override void UpdateValue(float smoothTime)
        {
            _value = Mathf.LerpUnclamped(start, end, smoothTime);
        }
    }

    public sealed class TweenBaseTests
    {
        private GameObject _tweenObject;
        private TestTween _tween;

        [SetUp]
        public void SetUp()
        {
            _tweenObject = new GameObject("Tween");
            _tween = _tweenObject.AddComponent<TestTween>();
        }

        [TearDown]
        public void TearDown()
        {
            Object.DestroyImmediate(_tweenObject);
        }

        [Test]
        public void Apply_ProgressZero_HasStartValue()
        {
            _tween.start = 10f;
            _tween.end = 25f;
            _tween.Apply();

            Assert.AreEqual(10f, _tween.value);
        }

        [Test]
        public void Apply_ProgressHalf_HasMiddleValue()
        {
            _tween.start = 10f;
            _tween.end = 20f;
            _tween.progress = 0.5f;
            _tween.Apply();

            Assert.AreEqual(15f, _tween.value);
        }

        [Test]
        public void Apply_ProgressOne_HasEndValue()
        {
            _tween.start = 10f;
            _tween.end = 25f;
            _tween.progress = 1f;
            _tween.Apply();

            Assert.AreEqual(25f, _tween.value);
        }

        [Test]
        public void Play_ImmediatelyHasStartValue()
        {
            _tween.start = 10f;
            _tween.end = 20f;

            _tween.Play();

            Assert.AreEqual(10f, _tween.value);
        }

        [UnityTest]
        public IEnumerator Play_DefaultDuration_SetsValueToEnd()
        {
            _tween.start = 10f;
            _tween.end = 20f;

            _tween.Play();
            Assert.IsTrue(_tween.isPlaying);
            yield return new WaitForSeconds(1f);

            Assert.IsFalse(_tween.isPlaying);

            Assert.AreEqual(20f, _tween.value);
        }

        [UnityTest]
        public IEnumerator Play_NegativeDirection_GoesToStart()
        {
            _tween.start = 10f;
            _tween.end = 20f;

            _tween.progress = 0.25f;
            _tween.direction = -1;

            _tween.Play();
            Assert.IsTrue(_tween.isPlaying);
            yield return new WaitForSeconds(0.25f);

            Assert.IsFalse(_tween.isPlaying);

            Assert.AreEqual(10f, _tween.value);
            Assert.AreEqual(0f, _tween.progress);
        }

        [UnityTest]
        public IEnumerator Play_CallingMoreThanOnce_DoesntEndFaster()
        {
            _tween.start = 10f;
            _tween.end = 20f;

            _tween.Play();
            _tween.Play();
            _tween.Play();
            _tween.Play();

            Assert.IsTrue(_tween.isPlaying);
            yield return new WaitForSeconds(0.5f);
            Assert.IsTrue(_tween.isPlaying);
            yield return new WaitForSeconds(0.5f);

            Assert.IsFalse(_tween.isPlaying);

{'fraction_non_alphanumeric': 0.08450308815272319, 'fraction_numerical': 0.013756316676024706, 'mean_word_length': 1.458592132505176, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6330519', 'n_tokens_mistral': 2179, 'n_tokens_neox': 2028, 'n_words': 418}