33
33
34
34
import com .oracle .graal .python .PythonLanguage ;
35
35
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 ;
37
37
import com .oracle .graal .python .nodes .control .GetNextNode ;
38
38
import com .oracle .graal .python .runtime .exception .PException ;
39
39
import com .oracle .graal .python .runtime .object .PythonObjectFactory ;
40
40
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 ;
41
44
import com .oracle .truffle .api .nodes .UnexpectedResultException ;
42
45
import com .oracle .truffle .api .profiles .ConditionProfile ;
43
46
@@ -47,12 +50,31 @@ public void setup() {
47
50
PythonTests .enterContext ();
48
51
}
49
52
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
+
50
68
@ Test
51
69
public void loopWithOnlyStop () throws UnexpectedResultException {
52
70
PRange range = PythonObjectFactory .create ().createRange (10 );
53
71
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 );
55
76
GetNextNode next = GetNextNode .create ();
77
+ testRoot .doInsert (next );
56
78
ConditionProfile errorProfile = ConditionProfile .createBinaryProfile ();
57
79
58
80
while (true ) {
@@ -71,8 +93,12 @@ public void loopWithOnlyStop() throws UnexpectedResultException {
71
93
public void loopWithStep () throws UnexpectedResultException {
72
94
PRange range = PythonObjectFactory .create ().createRange (0 , 10 , 2 );
73
95
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 );
75
100
GetNextNode next = GetNextNode .create ();
101
+ testRoot .doInsert (next );
76
102
ConditionProfile errorProfile = ConditionProfile .createBinaryProfile ();
77
103
78
104
while (true ) {
0 commit comments