Skip to content

Commit 0a37e36

Browse files
committed
fix PRange junit tests
1 parent 92695b7 commit 0a37e36

File tree

1 file changed

+29
-3
lines changed
  • graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/datatype

1 file changed

+29
-3
lines changed

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/datatype/PRangeTests.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,14 @@
3333

3434
import com.oracle.graal.python.PythonLanguage;
3535
import com.oracle.graal.python.builtins.objects.range.PRange;
36-
import com.oracle.graal.python.nodes.control.GetIteratorNodeGen;
36+
import com.oracle.graal.python.nodes.control.GetIteratorNode;
3737
import com.oracle.graal.python.nodes.control.GetNextNode;
3838
import com.oracle.graal.python.runtime.exception.PException;
3939
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
4040
import com.oracle.graal.python.test.PythonTests;
41+
import com.oracle.truffle.api.frame.VirtualFrame;
42+
import com.oracle.truffle.api.nodes.Node;
43+
import com.oracle.truffle.api.nodes.RootNode;
4144
import com.oracle.truffle.api.nodes.UnexpectedResultException;
4245
import com.oracle.truffle.api.profiles.ConditionProfile;
4346

@@ -47,12 +50,31 @@ public void setup() {
4750
PythonTests.enterContext();
4851
}
4952

53+
static class TestRoot extends RootNode {
54+
protected TestRoot(PythonLanguage language) {
55+
super(language);
56+
}
57+
58+
@Override
59+
public Object execute(VirtualFrame frame) {
60+
return null;
61+
}
62+
63+
public void doInsert(Node child) {
64+
insert(child);
65+
}
66+
}
67+
5068
@Test
5169
public void loopWithOnlyStop() throws UnexpectedResultException {
5270
PRange range = PythonObjectFactory.create().createRange(10);
5371
int index = 0;
54-
Object iter = GetIteratorNodeGen.create().executeWith(range);
72+
TestRoot testRoot = new TestRoot(PythonLanguage.getCurrent());
73+
GetIteratorNode getIter = GetIteratorNode.create();
74+
testRoot.doInsert(getIter);
75+
Object iter = getIter.executeWith(range);
5576
GetNextNode next = GetNextNode.create();
77+
testRoot.doInsert(next);
5678
ConditionProfile errorProfile = ConditionProfile.createBinaryProfile();
5779

5880
while (true) {
@@ -71,8 +93,12 @@ public void loopWithOnlyStop() throws UnexpectedResultException {
7193
public void loopWithStep() throws UnexpectedResultException {
7294
PRange range = PythonObjectFactory.create().createRange(0, 10, 2);
7395
int index = 0;
74-
Object iter = GetIteratorNodeGen.create().executeWith(range);
96+
TestRoot testRoot = new TestRoot(PythonLanguage.getCurrent());
97+
GetIteratorNode getIter = GetIteratorNode.create();
98+
testRoot.doInsert(getIter);
99+
Object iter = getIter.executeWith(range);
75100
GetNextNode next = GetNextNode.create();
101+
testRoot.doInsert(next);
76102
ConditionProfile errorProfile = ConditionProfile.createBinaryProfile();
77103

78104
while (true) {

0 commit comments

Comments
 (0)