mirror of
https://github.com/aNNiMON/Own-Programming-Language-Tutorial.git
synced 2024-09-20 00:34:20 +03:00
Fix concurrent modification exception in ounit, when new modules are loaded in test
This commit is contained in:
parent
99bdd1c953
commit
90db2b0aa3
@ -88,8 +88,10 @@ public final class ounit implements Module {
|
||||
|
||||
@Override
|
||||
public Value execute(Value[] args) {
|
||||
List<TestInfo> tests = Functions.getFunctions().entrySet().stream()
|
||||
final var testFunctions = ScopeHandler.functions().entrySet().stream()
|
||||
.filter(e -> e.getKey().toLowerCase().startsWith("test"))
|
||||
.toList();
|
||||
List<TestInfo> tests = testFunctions.stream()
|
||||
.map(e -> runTest(e.getKey(), e.getValue()))
|
||||
.toList();
|
||||
|
||||
@ -133,19 +135,12 @@ public final class ounit implements Module {
|
||||
}
|
||||
}
|
||||
|
||||
private static class TestInfo {
|
||||
final String name;
|
||||
final boolean isPassed;
|
||||
final String failureDescription;
|
||||
final long elapsedTimeInMicros;
|
||||
|
||||
public TestInfo(String name, boolean isPassed, String failureDescription, long elapsedTimeInMicros) {
|
||||
this.name = name;
|
||||
this.isPassed = isPassed;
|
||||
this.failureDescription = failureDescription;
|
||||
this.elapsedTimeInMicros = elapsedTimeInMicros;
|
||||
}
|
||||
|
||||
private record TestInfo(
|
||||
String name,
|
||||
boolean isPassed,
|
||||
String failureDescription,
|
||||
long elapsedTimeInMicros
|
||||
) {
|
||||
public String info() {
|
||||
return String.format("%s [%s]\n%sElapsed: %s\n",
|
||||
name,
|
||||
|
Loading…
Reference in New Issue
Block a user