Skip to content

Commit 84fb523

Browse files
committed
restore determinism, fix tests
1 parent 1881f29 commit 84fb523

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

de.peeeq.wurstscript/src/main/java/de/peeeq/datastructures/GraphInterpreter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.google.common.collect.Lists;
55
import com.google.common.collect.Sets;
66
import de.peeeq.wurstscript.utils.Utils;
7+
import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap;
78
import org.eclipse.jdt.annotation.Nullable;
89

910
import java.util.*;
@@ -81,8 +82,8 @@ public Set<Set<T>> findStronglyConnectedComponents(List<T> nodes) {
8182
Deque<T> p = new ArrayDeque<>();
8283
AtomicInteger c = new AtomicInteger();
8384
AtomicInteger componentCount = new AtomicInteger();
84-
Map<T, Integer> preorderNumber = new HashMap<>();
85-
Map<T, Integer> component = new HashMap<>();
85+
Object2IntLinkedOpenHashMap<T> preorderNumber = new Object2IntLinkedOpenHashMap<>();
86+
Object2IntLinkedOpenHashMap<T> component = new Object2IntLinkedOpenHashMap<>();
8687

8788
// This stack simulates the recursive calls
8889
Deque<T> traversalStack = new ArrayDeque<>();

de.peeeq.wurstscript/src/test/java/tests/wurstscript/tests/BugTests.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,23 @@ public void extensionMethodStatic() { // See #614
991991

992992
}
993993

994+
@Test
995+
public void testNameShadowError() {
996+
testAssertErrorsLines(true, "Variable x hides an other local variable with the same name",
997+
"package Test",
998+
"native testSuccess()",
999+
"function foo() returns bool",
1000+
" var x = 0",
1001+
" var sum = 0",
1002+
" for x in x",
1003+
" sum += x",
1004+
" return true",
1005+
"init",
1006+
" if foo()",
1007+
" testSuccess()"
1008+
);
1009+
}
1010+
9941011
@Test
9951012
public void testCyclicDependencyError() {
9961013
testAssertErrorsLines(true, "For loop target int doesn't provide a iterator() function",
@@ -999,8 +1016,8 @@ public void testCyclicDependencyError() {
9991016
"function foo() returns bool",
10001017
" var x = 0",
10011018
" var sum = 0",
1002-
" for x in x",
1003-
" sum += x",
1019+
" for i in x",
1020+
" sum += i",
10041021
" return true",
10051022
"init",
10061023
" if foo()",

0 commit comments

Comments
 (0)