mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 03:13:40 +07:00
nullity: initial tests
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
class Test {
|
||||
@NotNull
|
||||
String myFoo = "";
|
||||
|
||||
@Nullable
|
||||
String myFoo1 = null;
|
||||
|
||||
@NotNull
|
||||
String myFoo2 = foo2();
|
||||
@NotNull String foo2() { return "";}
|
||||
|
||||
@Nullable
|
||||
String myFoo3 = foo3();
|
||||
@Nullable String foo3() { return null;}
|
||||
|
||||
String myFoo4;
|
||||
void setFoo4() {
|
||||
myFoo4 = "";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
final String myFoo5;
|
||||
@Nullable
|
||||
final String myFoo6;
|
||||
@NotNull
|
||||
final String myFoo7;
|
||||
@Nullable
|
||||
final String myFoo8;
|
||||
final String myFoo9;
|
||||
@Nullable
|
||||
final String myFoo10;
|
||||
|
||||
/**
|
||||
* {@link #myFoo6}
|
||||
*/
|
||||
Test(@NotNull String param, @Nullable String paramNullable, String simpleParam) {
|
||||
myFoo5 = "";
|
||||
myFoo6 = null;
|
||||
myFoo7 = param;
|
||||
myFoo8 = paramNullable;
|
||||
myFoo9 = simpleParam;
|
||||
myFoo10 = foo10(false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
String foo10(boolean flag) {
|
||||
return flag ? foo2() : foo3();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
class Test {
|
||||
@Nullable
|
||||
String foo1() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
String foo2() {
|
||||
return "";
|
||||
}
|
||||
|
||||
String foo3(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
String foo4(@NotNull String s) {
|
||||
return s.substring(0);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
Integer foo5(Integer i) {
|
||||
return i++;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
Integer foo6(Integer i) {
|
||||
if (i == 0) return 1;
|
||||
return i * foo6(i--);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
Integer foo7(boolean flag) {
|
||||
return flag ? null : 1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
Integer foo8(boolean flag) {
|
||||
if (flag) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
String bar9() {
|
||||
return foo3("");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
String foo9() {
|
||||
return bar9();
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
String bar10() {
|
||||
return foo3("");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
String bar101() {
|
||||
return foo3("");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
String foo10(boolean flag) {
|
||||
return flag ? bar10() : bar101();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
String foo11() {
|
||||
class Foo{
|
||||
@Nullable
|
||||
String mess() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
class Test {
|
||||
void bar(@Nullable String str) {
|
||||
if (str == null) {
|
||||
foo(str);
|
||||
}
|
||||
}
|
||||
|
||||
String foo(String str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
String foo1(@Nullable String str) {
|
||||
if (str == null);
|
||||
return (str);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
String foo2(@Nullable String str) {
|
||||
if (str == null);
|
||||
return ((String)str);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
String fram(@Nullable String str, boolean b) {
|
||||
if (str != null) {
|
||||
return b ? str : "not null strimg";
|
||||
}
|
||||
return "str was null";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
class Test {
|
||||
void foo(@NotNull String s) {
|
||||
s.substring(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param str
|
||||
*/
|
||||
void bar(@NotNull String str) {
|
||||
if (str.substring(0) == null) {
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
class Test {
|
||||
void foo(@NotNull String s) {
|
||||
}
|
||||
|
||||
void bar(@NotNull String str) {
|
||||
foo(str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
class Test {
|
||||
String myFoo = "";
|
||||
|
||||
String myFoo1 = null;
|
||||
|
||||
String myFoo2 = foo2();
|
||||
@NotNull String foo2() { return "";}
|
||||
|
||||
String myFoo3 = foo3();
|
||||
@Nullable String foo3() { return null;}
|
||||
|
||||
String myFoo4;
|
||||
void setFoo4() {
|
||||
myFoo4 = "";
|
||||
}
|
||||
|
||||
final String myFoo5;
|
||||
final String myFoo6;
|
||||
final String myFoo7;
|
||||
final String myFoo8;
|
||||
final String myFoo9;
|
||||
final String myFoo10;
|
||||
|
||||
/**
|
||||
* {@link #myFoo6}
|
||||
*/
|
||||
Test(@NotNull String param, @Nullable String paramNullable, String simpleParam) {
|
||||
myFoo5 = "";
|
||||
myFoo6 = null;
|
||||
myFoo7 = param;
|
||||
myFoo8 = paramNullable;
|
||||
myFoo9 = simpleParam;
|
||||
myFoo10 = foo10(false);
|
||||
}
|
||||
|
||||
String foo10(boolean flag) {
|
||||
return flag ? foo2() : foo3();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
class Test {
|
||||
String foo1() {
|
||||
return null;
|
||||
}
|
||||
|
||||
String foo2() {
|
||||
return "";
|
||||
}
|
||||
|
||||
String foo3(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
String foo4(String s) {
|
||||
return s.substring(0);
|
||||
}
|
||||
|
||||
Integer foo5(Integer i) {
|
||||
return i++;
|
||||
}
|
||||
|
||||
Integer foo6(Integer i) {
|
||||
if (i == 0) return 1;
|
||||
return i * foo6(i--);
|
||||
}
|
||||
|
||||
Integer foo7(boolean flag) {
|
||||
return flag ? null : 1;
|
||||
}
|
||||
|
||||
Integer foo8(boolean flag) {
|
||||
if (flag) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
String bar9() {
|
||||
return foo3("");
|
||||
}
|
||||
|
||||
String foo9() {
|
||||
return bar9();
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
String bar10() {
|
||||
return foo3("");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
String bar101() {
|
||||
return foo3("");
|
||||
}
|
||||
|
||||
String foo10(boolean flag) {
|
||||
return flag ? bar10() : bar101();
|
||||
}
|
||||
|
||||
String foo11() {
|
||||
class Foo{
|
||||
String mess() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
class Test {
|
||||
void bar(String str) {
|
||||
if (str == null) {
|
||||
foo(str);
|
||||
}
|
||||
}
|
||||
|
||||
String foo(String str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
String foo1(String str) {
|
||||
if (str == null);
|
||||
return (str);
|
||||
}
|
||||
|
||||
String foo2(String str) {
|
||||
if (str == null);
|
||||
return ((String)str);
|
||||
}
|
||||
|
||||
String fram(String str, boolean b) {
|
||||
if (str != null) {
|
||||
return b ? str : "not null strimg";
|
||||
}
|
||||
return "str was null";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
class Test {
|
||||
void foo(String s) {
|
||||
s.substring(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param str
|
||||
*/
|
||||
void bar(String str) {
|
||||
if (str.substring(0) == null) {
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
class Test {
|
||||
void foo(@NotNull String s) {
|
||||
}
|
||||
|
||||
void bar(String str) {
|
||||
foo(str);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user