Add some scala tests

This commit is contained in:
Clément Fournier
2020-03-20 10:45:48 +01:00
parent 89cddd8aa8
commit f36835638f
9 changed files with 2093 additions and 260 deletions

View File

@ -1,18 +0,0 @@
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.ast
import net.sourceforge.pmd.lang.ast.test.BaseTreeDumpTest
import net.sourceforge.pmd.lang.ast.test.SimpleNodePrinter
import net.sourceforge.pmd.lang.java.JavaParsingHelper
import net.sourceforge.pmd.util.treeexport.TreeRenderer
abstract class AbstractJavaTreeDumpTest(printer: TreeRenderer = SimpleNodePrinter)
: BaseTreeDumpTest(printer = printer, extension = ".java") {
override val parser: JavaParsingHelper =
JavaParsingHelper.WITH_PROCESSING.withResourceContext(javaClass, "testdata")
}

View File

@ -1,20 +0,0 @@
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.ast
import org.junit.Test
/**
* Compare a dump of a file against a saved baseline.
*
* @author Clément Fournier
*/
class AstTreeDumpTests : AbstractJavaTreeDumpTest() {
@Test
fun testComplicatedLambda() = doTest("Bug1429")
}

View File

@ -1,22 +0,0 @@
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
public class Bug1429 {
public Set<String> getAttributeTuples() {
return (Set<String>) (this.attributes == null ? Collections.<String> emptySet() : new HashSet<String>(
CollectionUtils.collect(this.attributes.keySet(), new Transformer() {
@Override
public Object transform(final Object obj) {
final String key = (String) obj;
final String value = HGXLIFFTypeConfiguration.this.attributes.get(key);
String result = key;
if (StringUtils.isNotEmpty(value)) {
result = result.concat(":").concat(value);
}
return result;
}
})));
}
}

View File

@ -1,200 +0,0 @@
└─ CompilationUnit
└─ TypeDeclaration
└─ ClassOrInterfaceDeclaration
└─ ClassOrInterfaceBody
└─ ClassOrInterfaceBodyDeclaration
└─ MethodDeclaration
├─ ResultType
│ └─ Type
│ └─ ReferenceType
│ └─ ClassOrInterfaceType
│ └─ TypeArguments
│ └─ TypeArgument
│ └─ ReferenceType
│ └─ ClassOrInterfaceType
├─ MethodDeclarator
│ └─ FormalParameters
└─ Block
└─ BlockStatement
└─ Statement
└─ ReturnStatement
└─ Expression
└─ CastExpression
├─ Type
│ └─ ReferenceType
│ └─ ClassOrInterfaceType
│ └─ TypeArguments
│ └─ TypeArgument
│ └─ ReferenceType
│ └─ ClassOrInterfaceType
└─ PrimaryExpression
└─ PrimaryPrefix
└─ Expression
└─ ConditionalExpression
├─ EqualityExpression
│ ├─ PrimaryExpression
│ │ ├─ PrimaryPrefix
│ │ └─ PrimarySuffix
│ └─ PrimaryExpression
│ └─ PrimaryPrefix
│ └─ Literal
│ └─ NullLiteral
├─ Expression
│ └─ PrimaryExpression
│ ├─ PrimaryPrefix
│ │ └─ Name
│ ├─ PrimarySuffix
│ │ └─ MemberSelector
│ │ └─ TypeArguments
│ │ └─ TypeArgument
│ │ └─ ReferenceType
│ │ └─ ClassOrInterfaceType
│ └─ PrimarySuffix
│ └─ Arguments
└─ PrimaryExpression
└─ PrimaryPrefix
└─ AllocationExpression
├─ ClassOrInterfaceType
│ └─ TypeArguments
│ └─ TypeArgument
│ └─ ReferenceType
│ └─ ClassOrInterfaceType
└─ Arguments
└─ ArgumentList
└─ Expression
└─ PrimaryExpression
├─ PrimaryPrefix
│ └─ Name
└─ PrimarySuffix
└─ Arguments
└─ ArgumentList
├─ Expression
│ └─ PrimaryExpression
│ ├─ PrimaryPrefix
│ ├─ PrimarySuffix
│ ├─ PrimarySuffix
│ └─ PrimarySuffix
│ └─ Arguments
└─ Expression
└─ PrimaryExpression
└─ PrimaryPrefix
└─ AllocationExpression
├─ ClassOrInterfaceType
├─ Arguments
└─ ClassOrInterfaceBody
└─ ClassOrInterfaceBodyDeclaration
├─ Annotation
│ └─ MarkerAnnotation
│ └─ Name
└─ MethodDeclaration
├─ ResultType
│ └─ Type
│ └─ ReferenceType
│ └─ ClassOrInterfaceType
├─ MethodDeclarator
│ └─ FormalParameters
│ └─ FormalParameter
│ ├─ Type
│ │ └─ ReferenceType
│ │ └─ ClassOrInterfaceType
│ └─ VariableDeclaratorId
└─ Block
├─ BlockStatement
│ └─ LocalVariableDeclaration
│ ├─ Type
│ │ └─ ReferenceType
│ │ └─ ClassOrInterfaceType
│ └─ VariableDeclarator
│ ├─ VariableDeclaratorId
│ └─ VariableInitializer
│ └─ Expression
│ └─ CastExpression
│ ├─ Type
│ │ └─ ReferenceType
│ │ └─ ClassOrInterfaceType
│ └─ PrimaryExpression
│ └─ PrimaryPrefix
│ └─ Name
├─ BlockStatement
│ └─ LocalVariableDeclaration
│ ├─ Type
│ │ └─ ReferenceType
│ │ └─ ClassOrInterfaceType
│ └─ VariableDeclarator
│ ├─ VariableDeclaratorId
│ └─ VariableInitializer
│ └─ Expression
│ └─ PrimaryExpression
│ ├─ PrimaryPrefix
│ │ └─ Name
│ ├─ PrimarySuffix
│ ├─ PrimarySuffix
│ ├─ PrimarySuffix
│ └─ PrimarySuffix
│ └─ Arguments
│ └─ ArgumentList
│ └─ Expression
│ └─ PrimaryExpression
│ └─ PrimaryPrefix
│ └─ Name
├─ BlockStatement
│ └─ LocalVariableDeclaration
│ ├─ Type
│ │ └─ ReferenceType
│ │ └─ ClassOrInterfaceType
│ └─ VariableDeclarator
│ ├─ VariableDeclaratorId
│ └─ VariableInitializer
│ └─ Expression
│ └─ PrimaryExpression
│ └─ PrimaryPrefix
│ └─ Name
├─ BlockStatement
│ └─ Statement
│ └─ IfStatement
│ ├─ Expression
│ │ └─ PrimaryExpression
│ │ ├─ PrimaryPrefix
│ │ │ └─ Name
│ │ └─ PrimarySuffix
│ │ └─ Arguments
│ │ └─ ArgumentList
│ │ └─ Expression
│ │ └─ PrimaryExpression
│ │ └─ PrimaryPrefix
│ │ └─ Name
│ └─ Statement
│ └─ Block
│ └─ BlockStatement
│ └─ Statement
│ └─ StatementExpression
│ ├─ PrimaryExpression
│ │ └─ PrimaryPrefix
│ │ └─ Name
│ ├─ AssignmentOperator
│ └─ Expression
│ └─ PrimaryExpression
│ ├─ PrimaryPrefix
│ │ └─ Name
│ ├─ PrimarySuffix
│ │ └─ Arguments
│ │ └─ ArgumentList
│ │ └─ Expression
│ │ └─ PrimaryExpression
│ │ └─ PrimaryPrefix
│ │ └─ Literal
│ ├─ PrimarySuffix
│ └─ PrimarySuffix
│ └─ Arguments
│ └─ ArgumentList
│ └─ Expression
│ └─ PrimaryExpression
│ └─ PrimaryPrefix
│ └─ Name
└─ BlockStatement
└─ Statement
└─ ReturnStatement
└─ Expression
└─ PrimaryExpression
└─ PrimaryPrefix
└─ Name

View File

@ -0,0 +1,23 @@
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast
import net.sourceforge.pmd.lang.ast.test.BaseParsingHelper
import net.sourceforge.pmd.lang.ast.test.BaseTreeDumpTest
import net.sourceforge.pmd.lang.ast.test.SimpleNodePrinter
import org.junit.Test
class ScalaParserTests : BaseTreeDumpTest(SimpleNodePrinter, ".scala") {
override val parser: BaseParsingHelper<*, *>
get() = ScalaParsingHelper.DEFAULT.withResourceContext(javaClass, "testdata")
@Test
fun testSomeScalaFeatures() = doTest("List")
@Test
fun testPackageObject() = doTest("package")
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package scala.collection
package object immutable {
type StringOps = scala.collection.StringOps
val StringOps = scala.collection.StringOps
type StringView = scala.collection.StringView
val StringView = scala.collection.StringView
@deprecated("Use Iterable instead of Traversable", "2.13.0")
type Traversable[+X] = Iterable[X]
@deprecated("Use Iterable instead of Traversable", "2.13.0")
val Traversable = Iterable
@deprecated("Use Map instead of DefaultMap", "2.13.0")
type DefaultMap[K, +V] = scala.collection.immutable.Map[K, V]
}

View File

@ -0,0 +1,90 @@
└─ Source
└─ Pkg
├─ TermSelect
│ ├─ TermName
│ └─ TermName
└─ PkgObject
├─ TermName
└─ Template
├─ Self
│ └─ NameAnonymous
├─ DefnType
│ ├─ TypeName
│ └─ TypeSelect
│ ├─ TermSelect
│ │ ├─ TermName
│ │ └─ TermName
│ └─ TypeName
├─ DefnVal
│ ├─ PatVar
│ │ └─ TermName
│ └─ TermSelect
│ ├─ TermSelect
│ │ ├─ TermName
│ │ └─ TermName
│ └─ TermName
├─ DefnType
│ ├─ TypeName
│ └─ TypeSelect
│ ├─ TermSelect
│ │ ├─ TermName
│ │ └─ TermName
│ └─ TypeName
├─ DefnVal
│ ├─ PatVar
│ │ └─ TermName
│ └─ TermSelect
│ ├─ TermSelect
│ │ ├─ TermName
│ │ └─ TermName
│ └─ TermName
├─ DefnType
│ ├─ ModAnnot
│ │ └─ Init
│ │ ├─ TypeName
│ │ ├─ NameAnonymous
│ │ ├─ LitString
│ │ └─ LitString
│ ├─ TypeName
│ ├─ TypeParam
│ │ ├─ ModCovariant
│ │ ├─ TypeName
│ │ └─ TypeBounds
│ └─ TypeApply
│ ├─ TypeName
│ └─ TypeName
├─ DefnVal
│ ├─ ModAnnot
│ │ └─ Init
│ │ ├─ TypeName
│ │ ├─ NameAnonymous
│ │ ├─ LitString
│ │ └─ LitString
│ ├─ PatVar
│ │ └─ TermName
│ └─ TermName
└─ DefnType
├─ ModAnnot
│ └─ Init
│ ├─ TypeName
│ ├─ NameAnonymous
│ ├─ LitString
│ └─ LitString
├─ TypeName
├─ TypeParam
│ ├─ TypeName
│ └─ TypeBounds
├─ TypeParam
│ ├─ ModCovariant
│ ├─ TypeName
│ └─ TypeBounds
└─ TypeApply
├─ TypeSelect
│ ├─ TermSelect
│ │ ├─ TermSelect
│ │ │ ├─ TermName
│ │ │ └─ TermName
│ │ └─ TermName
│ └─ TypeName
├─ TypeName
└─ TypeName