Skip to content

Commit bbd727e

Browse files
committed
adapt parser tests to changes in GetAttributeNode
1 parent 7254c64 commit bbd727e

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/grammar/TestParserTranslator.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@
105105
import com.oracle.truffle.api.nodes.NodeUtil;
106106
import com.oracle.truffle.api.source.Source;
107107

108-
@SuppressWarnings({"unchecked"})
109108
public class TestParserTranslator {
110109
PythonContext context;
111110

@@ -132,7 +131,7 @@ <T> T getChild(Node result, int num, Class<? extends T> klass) {
132131
continue;
133132
}
134133
assertTrue("Expected an instance of " + klass + ", got " + n.getClass(), klass.isInstance(n));
135-
return (T) n;
134+
return klass.cast(n);
136135
}
137136
assertFalse("Expected an instance of " + klass + ", got null", true);
138137
return null;
@@ -158,7 +157,12 @@ Object literalAs(String src, Class<? extends PNode> klass) {
158157
<T> T literalAs(String src, Class<? extends PNode> klass, Class<? extends T> rklass) {
159158
Object literal = literalAs(src, klass);
160159
assertTrue("Expected an instance of " + rklass + ", got " + literal.getClass(), rklass.isInstance(literal));
161-
return (T) literal;
160+
return rklass.cast(literal);
161+
}
162+
163+
<T> T assertInstanceOf(PNode value, Class<? extends T> klass) {
164+
assertTrue("Expected an instance of " + klass + ", got " + value.getClass(), klass.isInstance(value));
165+
return klass.cast(value);
162166
}
163167

164168
@Test
@@ -247,8 +251,8 @@ public void parseGlobalVariable() {
247251
public void parsePropertyAccess() {
248252
parseAs("foobar13_ddsA.property", GetAttributeNode.class);
249253
GetAttributeNode anotherProperty = parseAs("foobar13_ddsA.property.anotherProperty", GetAttributeNode.class);
250-
GetAttributeNode property = getFirstChild(anotherProperty, GetAttributeNode.class);
251-
getFirstChild(property, ReadGlobalOrBuiltinNode.class);
254+
GetAttributeNode property = assertInstanceOf(anotherProperty.getObject(), GetAttributeNode.class);
255+
assertInstanceOf(property.getObject(), ReadGlobalOrBuiltinNode.class);
252256
}
253257

254258
@Test

0 commit comments

Comments
 (0)