Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/CSharpTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ jobs:
- name: Test if not to send
if: ${{ matrix.os != 'windows-latest' }}
run: |
dotnet test "Sources/Tests/UnitTests" -c Release -l GitHubActions /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
dotnet test "Sources/Tests/UnitTests" -c Release -l GitHubActions -l "trx;LogFileName=results.trx" --results-directory "Sources/Tests/UnitTests/TestResults" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover

# Where the suite's time goes, by the Area trait every test class carries, written to the
# job's summary. One leg is enough to see the breakdown, and running the tool builds the
# library once more. https://github.com/asc-community/AngouriMath/issues/1183
- name: 'Time by area'
if: ${{ always() && matrix.os == 'ubuntu-latest' }}
run: dotnet run AreaTimes
working-directory: Sources/Utils/Utils

- name: Test if to send
if: ${{ matrix.os == 'windows-latest' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace AngouriMath.Tests.Algebra
/// <c>x</c> satisfies it, and every <c>x</c> does whenever the two sides happen to be
/// equal. https://github.com/asc-community/AngouriMath/issues/278
/// </summary>
[Trait("Area", "Algebra")]
public sealed class EquationWithoutTheUnknownTest
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace AngouriMath.Tests.Algebra
/// <c>sin(x)^2 + sin(x) = 0</c> has always answered in arcsines. The mixed form simply
/// never became one.
/// </remarks>
[Trait("Area", "Algebra")]
public sealed class PythagoreanEquationRewriteTest
{
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions Sources/Tests/UnitTests/Calculus/BinomialIdentitiesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace AngouriMath.Tests.Calculus
/// second form), the parallel summation (Prob 8.9.19) and Vandermonde along the upper
/// indices (Prob 8.9.18). <see href="https://github.com/asc-community/AngouriMath/issues/1409"/>
/// </summary>
[Trait("Area", "Calculus")]
public sealed class BinomialIdentitiesTest
{
/// <summary>The closed form against the sum written out, at small bounds and one past the expansion's hundred terms.</summary>
Expand Down
1 change: 1 addition & 0 deletions Sources/Tests/UnitTests/Calculus/BinomialSumTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace AngouriMath.Tests.Calculus
/// https://github.com/asc-community/AngouriMath/issues/1212, question II.3: a binomial sum
/// with a power or a trigonometric weight is the binomial theorem read backwards.
/// </summary>
[Trait("Area", "Calculus")]
public sealed class BinomialSumTest
{
private const string Binomial = "N! / (k! * (N - k)!)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace AngouriMath.Tests.Calculus
/// through an antiderivative that holds the case or the step constant across them. Question
/// I.2 of https://github.com/asc-community/AngouriMath/issues/1212, and the review of #1215.
/// </summary>
[Trait("Area", "Calculus")]
public sealed class BreakpointIntegrationTest
{
// ---- a piecewise: finitely many breakpoints ---------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace AngouriMath.Tests.Calculus
/// gathering of two powers of one base turns <c>e^x * e^(-x)</c> into exactly this
/// shape -- but the defect predates it and is reachable by writing the exponent out.
/// </summary>
[Trait("Area", "Calculus")]
public sealed class ConstantRateIntegrandTest
{
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions Sources/Tests/UnitTests/Calculus/DivergentSeriesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace AngouriMath.Tests.Calculus
/// nth-term test, asked for on the review of
/// https://github.com/asc-community/AngouriMath/pull/1218.
/// </summary>
[Trait("Area", "Calculus")]
public sealed class DivergentSeriesTest
{
[Theory]
Expand Down
1 change: 1 addition & 0 deletions Sources/Tests/UnitTests/Calculus/ExponentialSeriesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace AngouriMath.Tests.Calculus
/// https://github.com/asc-community/AngouriMath/issues/1212, question I.1: a summation to
/// +oo of a polynomial times a power over a factorial of the index is a closed form in e.
/// </summary>
[Trait("Area", "Calculus")]
public sealed class ExponentialSeriesTest
{
private static void AgreesTo(string expected, Entity actual, int digits = 25)
Expand Down
1 change: 1 addition & 0 deletions Sources/Tests/UnitTests/Calculus/ExtremumTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace AngouriMath.Tests.Calculus
/// <c>max(f(t), t in S)</c>, <c>min</c>, <c>argmax</c> and <c>argmin</c>: the extremum of an
/// expression over a set, as binders. https://github.com/asc-community/AngouriMath/issues/1212
/// </summary>
[Trait("Area", "Calculus")]
public sealed class ExtremumTest
{
// The sheet's question I.6: the area of a projectile's flight is largest at pi/3.
Expand Down
1 change: 1 addition & 0 deletions Sources/Tests/UnitTests/Calculus/GeometricSeriesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace AngouriMath.Tests.Calculus
/// geometric series, to a bound or to <c>+oo</c>. Part of question I.2 of
/// https://github.com/asc-community/AngouriMath/issues/1212.
/// </summary>
[Trait("Area", "Calculus")]
public sealed class GeometricSeriesTest
{
[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace AngouriMath.Tests.Calculus
/// it to: it inner-simplifies its *input* and returns its output untouched, while the
/// definite overload has always inner-simplified the antiderivative.
/// </remarks>
[Trait("Area", "Calculus")]
public sealed class IntegralPiecewiseReducedTest
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace AngouriMath.Tests.Calculus
/// of it, which the exponential rules read: <c>x arsinh(a x)</c> is <c>u sinh(2u)/(2a^2)</c>.
/// <a href="https://github.com/asc-community/AngouriMath/issues/718">#718</a>
/// </summary>
[Trait("Area", "Calculus")]
public sealed class InverseHyperbolicSubstitutionTest
{
private static void DifferentiatesBack(string integrand, double[] points)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace AngouriMath.Tests.Calculus
/// Every answer is checked by differentiating it back and comparing at points: what
/// matters is that it is an antiderivative, not what form it is written in.
/// </summary>
[Trait("Area", "Calculus")]
public sealed class LinearityBeforeByPartsTest
{
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions Sources/Tests/UnitTests/Calculus/ModulusPhaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace AngouriMath.Tests.Calculus
/// with the wrong answer: a zero times a complex infinity evaluated to 0, a complex infinity
/// did not count as infinite, and the descent's unread 0 / abs(0) was returned as NaN.
/// </summary>
[Trait("Area", "Calculus")]
public sealed class ModulusPhaseTest
{
private static readonly Variable x = MathS.Var("x");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace AngouriMath.Tests.Calculus
/// <c>sum((-1)^(k - 1) k^2, k, 1, n) = (-1)^(n - 1) n (n + 1)/2</c>, is the row that asked
/// for it. <see href="https://github.com/asc-community/AngouriMath/issues/1409"/>
/// </summary>
[Trait("Area", "Calculus")]
public sealed class PolynomialGeometricSeriesTest
{
/// <summary>The closed form against the sum written out, at a bound past the expansion's hundred terms and at small ones.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace AngouriMath.Tests.Calculus
/// not run <c>PowerRules</c> at all, so even the sibling case was missed.
/// https://github.com/asc-community/AngouriMath/issues/781
/// </summary>
[Trait("Area", "Calculus")]
public sealed class PowersOfOneBaseMergedTest
{
/// <summary>Sample points, chosen to include negative x and to avoid the zeros of sin.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace AngouriMath.Tests.Calculus
/// testing the simplifier's reach rather than the integrator's answer.
/// </para>
/// </remarks>
[Trait("Area", "Calculus")]
public sealed class SymbolicQuadraticCoefficientTest
{
private const double RelativeTolerance = 1e-8;
Expand Down
52 changes: 52 additions & 0 deletions Sources/Tests/UnitTests/Common/AreaTraitTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// Copyright (c) 2019-2026 Angouri.
// AngouriMath is licensed under MIT.
// Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.
// Website: https://am.angouri.org.
//

using System;
using System.Linq;
using System.Reflection;
using Xunit;

namespace AngouriMath.Tests.Common
{
/// <summary>
/// Every test class says which area of the library it tests, with
/// <c>[Trait("Area", …)]</c>, so that a run can be filtered to an area and its time broken
/// down by area. A taxonomy is worth what its completeness is worth, and nothing else
/// notices a class without one: there were 22 such files when this was asked for and 37 a
/// fortnight later.
/// https://github.com/asc-community/AngouriMath/issues/1183
/// </summary>
[Trait("Area", "Common")]
public sealed class AreaTraitTest
{
[Fact]
public void EveryTestClassHasAnArea()
{
var missing = typeof(AreaTraitTest).Assembly.GetTypes()
.Where(static type => !type.IsAbstract && TestMethods(type).Any())
.Where(static type => !HasArea(type) && !TestMethods(type).All(HasArea))
.Select(static type => type.FullName)
.OrderBy(static name => name, StringComparer.Ordinal)
.ToList();
Assert.True(missing.Count == 0,
"These test classes say nothing about which area they test; give each a [Trait(\"Area\", …)]:\n "
+ string.Join("\n ", missing));
}

/// <summary>The methods xUnit runs as tests: a <see cref="TheoryAttribute"/> is a <see cref="FactAttribute"/>.</summary>
private static System.Collections.Generic.IEnumerable<MethodInfo> TestMethods(Type type)
=> type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static)
.Where(static method => method.IsDefined(typeof(FactAttribute), inherit: true));

/// <summary>Declared on the member itself or, for a class, on a class it derives from.</summary>
private static bool HasArea(MemberInfo member)
=> member.GetCustomAttributesData().Any(static attribute =>
attribute.AttributeType == typeof(TraitAttribute)
&& attribute.ConstructorArguments is [{ Value: "Area" }, _])
|| member is Type { BaseType: { } baseType } && baseType != typeof(object) && HasArea(baseType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace AngouriMath.Tests.Common
/// intersection of my own choosing was tested instead, and the maintainer said so on the
/// issue. This pins the reporter's expression, character for character.
/// </remarks>
[Trait("Area", "Common")]
public sealed class IntervalSimplificationTest
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace AngouriMath.Tests.Common
/// a logarithm of a rational literal that is a perfect power takes the exponent out, which
/// is longer on its own and is what lets two logarithms of related literals collect.
/// </summary>
[Trait("Area", "Common")]
public sealed class LogarithmOfAPerfectPowerTest
{
[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace AngouriMath.Tests.Common
/// change which value is taken.
/// </para>
/// </remarks>
[Trait("Area", "Common")]
public sealed class PiecewiseReachabilityTest
{
[Theory]
Expand Down
1 change: 1 addition & 0 deletions Sources/Tests/UnitTests/Convenience/SpellingsAtRiskTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace AngouriMath.Tests.Convenience
/// with it.
/// </para>
/// </remarks>
[Trait("Area", "Convenience")]
public sealed class SpellingsAtRiskTest
{
// `|` is an alias for `or`, so a divisibility statement is read as a disjunction.
Expand Down
1 change: 1 addition & 0 deletions Sources/Tests/UnitTests/Core/CardinalityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace AngouriMath.Tests.Core
/// <c>card(S)</c>: the number of elements of a set, as a node of its own.
/// https://github.com/asc-community/AngouriMath/issues/1212
/// </summary>
[Trait("Area", "Core")]
public sealed class CardinalityTest
{
[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace AngouriMath.Tests.Core
/// nine, a sum of such piecewises had 3^12 cases and took 8 GB.
/// <a href="https://github.com/asc-community/AngouriMath/issues/1414">#1414</a>
/// </summary>
[Trait("Area", "Core")]
public sealed class ContradictoryConjunctionTest
{
[Theory]
Expand Down
1 change: 1 addition & 0 deletions Sources/Tests/UnitTests/Core/DividesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace AngouriMath.Tests.Core
/// <c>a divides b</c>: the statement that <c>b</c> is a whole multiple of <c>a</c>, as a node
/// of its own. https://github.com/asc-community/AngouriMath/issues/1212
/// </summary>
[Trait("Area", "Core")]
public sealed class DividesTest
{
[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace AngouriMath.Tests.Core
/// concurrent read and write, which is a property of the contract rather than of any run.
/// </para>
/// </remarks>
[Trait("Area", "Core")]
public sealed class FactorialCacheIsThreadSafeTest
{
/// <summary>Above anything another test is likely to have cached, so growth really runs.</summary>
Expand Down
1 change: 1 addition & 0 deletions Sources/Tests/UnitTests/Core/IntervalEvaluationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace AngouriMath.Tests.Core
/// does not read, and compares in three outcomes.
/// <a href="https://github.com/asc-community/AngouriMath/issues/1019">#1019</a>
/// </summary>
[Trait("Area", "Core")]
public sealed class IntervalEvaluationTest
{
[Theory]
Expand Down
1 change: 1 addition & 0 deletions Sources/Tests/UnitTests/Core/MatrixConcurrencyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace AngouriMath.Tests.Core
/// returning a wrong entity rather than by throwing, so those assertions count disagreements
/// instead of stopping at the first one.
/// </summary>
[Trait("Area", "Core")]
public sealed class MatrixConcurrencyTest
{
private const int Matrices = 40;
Expand Down
1 change: 1 addition & 0 deletions Sources/Tests/UnitTests/Core/SortKeyCacheTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace AngouriMath.Tests.Core
/// <c>with</c> spells its own key rather than inheriting the original's, and asking from
/// several threads at once gives every thread the same string.
/// </summary>
[Trait("Area", "Core")]
public sealed class SortKeyCacheTest
{
[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace AngouriMath.Tests.Core.Transformations
{
[Trait("Area", "Core")]
public sealed class EBindingsTest
{
[Fact]
Expand Down
1 change: 1 addition & 0 deletions Sources/Tests/UnitTests/Core/Transformations/EGraphTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace AngouriMath.Tests.Core.Transformations
{
[Trait("Area", "Core")]
public sealed class EGraphTest
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

namespace AngouriMath.Tests.Core.Transformations
{
[Trait("Area", "Core")]
public sealed class MatchPatternEMatchTest
{
private static readonly Func<Entity, double> Cost = AngouriMath.Core.CostModel.Default.Cost;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace AngouriMath.Tests.Core.Transformations
{
[Trait("Area", "Core")]
public sealed class MatchedRuleGrowthTest
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace AngouriMath.Tests.Core.Transformations
{
[Trait("Area", "Core")]
public sealed class MatchedRuleTryEMatchApplyTest
{
private static readonly System.Func<Entity, double> Cost = AngouriMath.Core.CostModel.Default.Cost;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace AngouriMath.Tests.Core.Transformations
{
[Trait("Area", "Core")]
public sealed class MatchedRulesAllTest
{
[Fact]
Expand Down
1 change: 1 addition & 0 deletions Sources/Tests/UnitTests/Core/UnknownDomainIsNotABugTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace UnitTests.Core
/// this library does not have was answered with AngouriBugException, which asks them to
/// report their own input to the issue tracker.
/// </summary>
[Trait("Area", "Core")]
public sealed class UnknownDomainIsNotABugTest
{
[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace AngouriMath.Tests.Core
/// make it safe: dropping a case that was reachable would shorten the answer and change it,
/// and a test that only counted cases could not tell the two apart.
/// </remarks>
[Trait("Area", "Core")]
public sealed class UnreachablePiecewiseCaseTest
{
private static int CaseCount(Entity piecewise)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace AngouriMath.Tests.PatternsTest
/// the binomial case rather than introducing one, which is the half of #205 that does
/// not need a maintainer's ruling.
/// </remarks>
[Trait("Area", "PatternsTest")]
public sealed class RationalizeDenominatorTest
{
private static bool IsSurd(Entity node)
Expand Down
Loading
Loading