aboutsummaryrefslogtreecommitdiff
path: root/src/test/resources/com/puppycrawl/tools/checkstyle
diff options
context:
space:
mode:
authorDmytro Kytsmen <dmitrokytsmen@gmail.com>2017-04-20 20:31:43 +0300
committerRoman Ivanov <romani@users.noreply.github.com>2017-04-21 07:49:25 -0700
commit9731ffa74839168eed1378e9b10caa13ee0961e8 (patch)
treed86d477a3e89a5373cdbd30d13e494fe18ad7e75 /src/test/resources/com/puppycrawl/tools/checkstyle
parentdf04196eeba6d26a665fb6dc8aa7747322aca5f4 (diff)
downloadcheckstyle-9731ffa74839168eed1378e9b10caa13ee0961e8.tar.gz
Issue #4165: Split and Organize Checkstyle inputs by Test for checks in coding package: SuperClone
Diffstat (limited to 'src/test/resources/com/puppycrawl/tools/checkstyle')
-rw-r--r--src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/superclone/InputSuperCloneInnerAndWithArguments.java99
-rw-r--r--src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/superclone/InputSuperClonePlainAndSubclasses.java (renamed from src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputSuperClone.java)4
2 files changed, 101 insertions, 2 deletions
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/superclone/InputSuperCloneInnerAndWithArguments.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/superclone/InputSuperCloneInnerAndWithArguments.java
new file mode 100644
index 000000000..e5a45d68a
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/superclone/InputSuperCloneInnerAndWithArguments.java
@@ -0,0 +1,99 @@
+package com.puppycrawl.tools.checkstyle.checks.coding.superclone;
+public class InputSuperCloneInnerAndWithArguments
+{/* class body */
+ public InputSuperCloneInnerAndWithArguments() throws CloneNotSupportedException
+ { //constructor body
+ super.equals(new String());
+ super.clone();
+ }
+
+ public Object clone() throws CloneNotSupportedException
+ {
+ return super.clone();
+ }
+
+ public void method() throws CloneNotSupportedException
+ {
+ super.clone();
+ }
+
+ {
+ super.clone();
+ }
+}
+
+class NoSuperClone
+{
+ public Object clone()
+ {
+ return null;
+ }
+}
+
+class InnerClone
+{
+ public Object clone()
+ {
+ class Inner
+ {
+ public Object clone() throws CloneNotSupportedException
+ {
+ return super.clone();
+ }
+ }
+ return null;
+ }
+}
+
+// This could not pass as valid semantically but tests that
+// type arguments are ignored when checking super calls
+class CloneWithTypeArguments<T> extends CloneWithTypeArgumentsAndNoSuper<T>
+{
+ public CloneWithTypeArguments<T> clone() throws CloneNotSupportedException
+ {
+ return (CloneWithTypeArguments<T>) super.<T>clone();
+ }
+}
+
+class CloneWithTypeArgumentsAndNoSuper<T>
+{
+ public CloneWithTypeArgumentsAndNoSuper<T> clone() throws CloneNotSupportedException
+ {
+ return null;
+ }
+}
+
+//Check that super keword isn't snagged here
+class MyClassWithGenericSuperMethod
+{
+ void someMethod(java.util.List<? super java.util.Map<Object, Object>> l)
+ {
+
+ }
+
+ /**
+ * Not a valid clone override. Should not get flagged.
+ * @param o some object
+ * @return a cloned Object?
+ */
+ public static Object clone(Object o) {
+ return null;
+ }
+}
+
+class AnotherClass {
+
+ /**
+ * Not a valid clone override. Should not get flagged.
+ * @param t some type
+ * @param <T> a type
+ * @return a cloned type?
+ */
+ public <T> T clone(T t) {
+ return null;
+ }
+}
+
+class NativeTest {
+ public native Object clone();
+}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputSuperClone.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/superclone/InputSuperClonePlainAndSubclasses.java
index 42efa3712..25d4a6a7f 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputSuperClone.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/superclone/InputSuperClonePlainAndSubclasses.java
@@ -1,7 +1,7 @@
-package com.puppycrawl.tools.checkstyle.checks.coding;
+package com.puppycrawl.tools.checkstyle.checks.coding.superclone;
-interface InputSuperClone {
+interface InputSuperClonePlainAndSubclasses {
void clone();
}