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
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ static void Solve(int num) =>
{
var roots = "x2 + e^x + sin(x)".SolveEquation("x");
var set = (Set)roots.Simplify();
Assert.Equal(num % 2 == 0, !set.IsSetEmpty);
// With Newton the roots are numbers; without, the equation is left as the set it defines.
Assert.Equal(num % 2 == 0, set is Set.FiniteSet { IsSetEmpty: false });
});
new ThreadingChecker(Solve).Run();
}
Expand Down Expand Up @@ -123,7 +124,8 @@ static void Solve(int num)
using var _ = MathS.Settings.AllowNewton.Set(num % 2 == 0);
var roots = "x2 + e^x + sin(x)".SolveEquation("x");
var set = (Set)roots.Simplify();
Assert.Equal(num % 2 == 0, !set.IsSetEmpty);
// With Newton the roots are numbers; without, the equation is left as the set it defines.
Assert.Equal(num % 2 == 0, set is Set.FiniteSet { IsSetEmpty: false });
}
new ThreadingChecker(Solve).Run();
}
Expand Down
7 changes: 6 additions & 1 deletion Sources/Tests/UnitTests/TestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,19 @@ public void Run(int iterCount = 1, int threadCount = 4)
{
var tasks = new Task[threadCount];
for (var i = 0; i < threadCount; i++)
{
// Each task's own index: the lambda read the loop's variable, which had usually reached
// threadCount by the time a task ran, so every thread was asked the same thing.
var index = i;
tasks[i] = Task.Run(
() =>
{
var iterCountLocal = iterCount;
for (var j = 0; j < iterCountLocal; j++)
action(i);
action(index);
}
);
}
Task.WaitAll(tasks);
}
}
Expand Down
Loading