garydgregory commented on code in PR #165:
URL: https://github.com/apache/commons-bcel/pull/165#discussion_r1014726556
##########
src/test/java/org/apache/bcel/classfile/ConstantPoolModuleToStringTestCase.java:
##########
@@ -353,19 +400,50 @@ public void visitUnknown(final Unknown obj) {
"src/test/resources/jpms/java18/commons-io/module-info.class",
"src/test/resources/jpms/java19-ea/commons-io/module-info.class"})
// @formatter:on
- public void test(final String first) throws Exception {
+ void test(final String first) throws Exception {
try (final InputStream inputStream =
Files.newInputStream(Paths.get(first))) {
- final ClassParser classParser = new ClassParser(inputStream,
"module-info.class");
- final JavaClass javaClass = classParser.parse();
- final ConstantPool constantPool = javaClass.getConstantPool();
- final ToStringVisitor visitor = new ToStringVisitor(constantPool);
- final DescendingVisitor descendingVisitor = new
DescendingVisitor(javaClass, visitor);
- try {
- javaClass.accept(descendingVisitor);
- } catch (Exception | Error e) {
- fail(visitor.toString(), e);
+ test(inputStream);
+ }
+ }
+
+ @Test
+ void test() throws Exception {
+ final Enumeration<URL> moduleURLs =
getClass().getClassLoader().getResources("module-info.class");
+ while (moduleURLs.hasMoreElements()) {
+ final URL url = moduleURLs.nextElement();
+ try (InputStream inputStream = url.openStream()) {
+ test(inputStream);
}
}
}
+ @ParameterizedTest
+ @ValueSource(strings = {
+ // @formatter:off
+ "org.apache.commons.lang3.function.TriFunction",
Review Comment:
@nbauma109
Please add a comment why these classes and not others, I think it will help
people reading the code :-)
##########
src/test/java/org/apache/bcel/generic/EmptyVisitorTestCase.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bcel.generic;
+
+import static org.junit.jupiter.api.Assertions.fail;
+
+import org.apache.bcel.classfile.Code;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.classfile.Method;
+import org.apache.bcel.util.SyntheticRepository;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.awt.Color;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Map;
+
+class EmptyVisitorTestCase {
+
+ /*
+ * https://docs.oracle.com/javase/specs/jvms/se17/html/jvms-6.html#jvms-6.2
+ */
+ private static final String RESERVED_OPCODE = "Reserved opcode";
+
+ @ParameterizedTest
+ @ValueSource(classes = { BigInteger.class, BigDecimal.class, Color.class,
Map.class })
Review Comment:
@nbauma109
Please add a comment why these classes and not others, I think it will help
people reading the code :-)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]