<commit_before>﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using Xunit;

namespace Microsoft.VisualBasic.Tests
{
    public class FinancialTests
    {
        // The accuracy to which we can validate some numeric test cases depends on the platform.
        private static readonly int s_precision = PlatformDetection.IsAlpine ? 12 :
            PlatformDetection.IsFullFramework || PlatformDetection.IsArmOrArm64Process ? 14 : 15;

        [Theory]
        [InlineData(0, 1.0, 1.0, 1.0, 1.0, 0, 0)]
        [InlineData(2000.0, 500.0, 2.0, 1.0, 2.0, 1500.0, -4)]
        [InlineData(10000.0, 4350.0, 84.0, 35.0, 2.0, 57.32680635388748, -2)]
        [InlineData(15006.0, 6350.0, 81.0, 23.0, 1.5, 184.19489836666187, -3)]
        [InlineData(11606.0, 6350.0, 74.0, 17.0, 2.1, 207.79010936598854, -3)]
        [InlineData(11606.0, 16245.0, 71.0, 17.0, 2.0, 0, -1)] // cost < salvage
        [InlineData(10100.0, 10100.0, 70.0, 20.0, 2.0, 0, -1)] // cost = salvage
        public void DDB(double Cost, double Salvage, double Life, double Period, double Factor, double expected, int relativePrecision)
        {
            Assert.Equal(expected, Financial.DDB(Cost, Salvage, Life, Period, Factor), s_precision + relativePrecision);
        }

        [Fact]
        public void DDB_Default()
        {
            Assert.Equal(57.32680635388748, Financial.DDB(10000.0, 4350.0, 84.0, 35.0), s_precision - 2);
        }

        [Theory]
        [InlineData(-10000, 5211, -81, 35, 2)]
        public void DDB_Invalid(double Cost, double Salvage, double Life, double Period, double Factor)
        {
            Assert.Throws<ArgumentException>(() => Financial.DDB(Cost, Salvage, Life, Period, Factor));
        }

        [Theory]
        [InlineData(0, 0, 0, 0, DueDate.EndOfPeriod, 0, 0)]
        [InlineData(0.02 / 12, 12.0, -100.0, -100.0, DueDate.BegOfPeriod, 1315.0982120264073, -4)]
        [InlineData(0.0083, 15, 263.0, 0, DueDate.EndOfPeriod, -4182.657291138164, -4)]
        [InlineData(0.013, 90, 81.0, 5000.0, DueDate.BegOfPeriod, -29860.905154180855, -5)]
        [InlineData(0.01, 37, 100.0, 0, DueDate.BegOfPeriod, -4495.2723614177185, -4)]
        [InlineData(-0.0083, 15, 263.0, 0, DueDate.EndOfPeriod, -3723.837650080481, -4)] // rate < 0
        [InlineData(0, 15, 263, 0, DueDate.EndOfPeriod, -3945, -4)] // rate = 0
        [InlineData(0.0083, 15, 263.0, 0, (DueDate)8, -4217.37334665461, -4)] // type <> 0 and type <> 1
        [InlineData(1e+25, 12, 1797, 0, (DueDate)1, -1.797000000000002e+303, -10)] // overFlow
        public void FV(double Rate, double NPer, double Pmt, double PV, DueDate Due, double expected, int relativePrecision)
        {
            Assert.Equal(expected, Financial.FV(Rate, NPer, Pmt, PV, Due), s_precision + relativePrecision);
        }

        [Fact]
        public void FV_Default()
        {<commit_msg>Disable FinancialTest.FV test on arm64 (#40246)<commit_after>﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using Xunit;

namespace Microsoft.VisualBasic.Tests
{
    public class FinancialTests
    {
        // The accuracy to which we can validate some numeric test cases depends on the platform.
        private static readonly int s_precision = PlatformDetection.IsAlpine ? 12 :
            PlatformDetection.IsFullFramework || PlatformDetection.IsArmOrArm64Process ? 14 : 15;

        [Theory]
        [InlineData(0, 1.0, 1.0, 1.0, 1.0, 0, 0)]
        [InlineData(2000.0, 500.0, 2.0, 1.0, 2.0, 1500.0, -4)]
        [InlineData(10000.0, 4350.0, 84.0, 35.0, 2.0, 57.32680635388748, -2)]
        [InlineData(15006.0, 6350.0, 81.0, 23.0, 1.5, 184.19489836666187, -3)]
        [InlineData(11606.0, 6350.0, 74.0, 17.0, 2.1, 207.79010936598854, -3)]
        [InlineData(11606.0, 16245.0, 71.0, 17.0, 2.0, 0, -1)] // cost < salvage
        [InlineData(10100.0, 10100.0, 70.0, 20.0, 2.0, 0, -1)] // cost = salvage
        public void DDB(double Cost, double Salvage, double Life, double Period, double Factor, double expected, int relativePrecision)
        {
            Assert.Equal(expected, Financial.DDB(Cost, Salvage, Life, Period, Factor), s_precision + relativePrecision);
        }

        [Fact]
        public void DDB_Default()
        {
            Assert.Equal(57.32680635388748, Financial.DDB(10000.0, 4350.0, 84.0, 35.0), s_precision - 2);
        }

        [Theory]
        [InlineData(-10000, 5211, -81, 35, 2)]
        public void DDB_Invalid(double Cost, double Salvage, double Life, double Period, double Factor)
        {
            Assert.Throws<ArgumentException>(() => Financial.DDB(Cost, Salvage, Life, Period, Factor));
        }

        [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArm64Process))] // [ActiveIssue(40245)]
        [InlineData(0, 0, 0, 0, DueDate.EndOfPeriod, 0, 0)]
        [InlineData(0.02 / 12, 12.0, -100.0, -100.0, DueDate.BegOfPeriod, 1315.0982120264073, -4)]
        [InlineData(0.0083, 15, 263.0, 0, DueDate.EndOfPeriod, -4182.657291138164, -4)]
        [InlineData(0.013, 90, 81.0, 5000.0, DueDate.BegOfPeriod, -29860.905154180855, -5)]
        [InlineData(0.01, 37, 100.0, 0, DueDate.BegOfPeriod, -4495.2723614177185, -4)]
        [InlineData(-0.0083, 15, 263.0, 0, DueDate.EndOfPeriod, -3723.837650080481, -4)] // rate < 0
        [InlineData(0, 15, 263, 0, DueDate.EndOfPeriod, -3945, -4)] // rate = 0
        [InlineData(0.0083, 15, 263.0, 0, (DueDate)8, -4217.37334665461, -4)] // type <> 0 and type <> 1
        [InlineData(1e+25, 12, 1797, 0, (DueDate)1, -1.797000000000002e+303, -10)] // overFlow
        public void FV(double Rate, double NPer, double Pmt, double PV, DueDate Due, double expected, int relativePrecision)
        {
            Assert.Equal(expected, Financial.FV(Rate, NPer, Pmt, PV, Due), s_precision + relativePrecision);
        }

        [Fact]
        public void FV_Default()
        {
{'fraction_non_alphanumeric': 0.14191259474278342, 'fraction_numerical': 0.15610385421706177, 'mean_word_length': 2.667652276759314, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '3830126', 'n_tokens_mistral': 2834, 'n_tokens_neox': 2207, 'n_words': 577}