mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 10:18:46 +00:00
Added new tests for SneakyThrows
This commit is contained in:
1 parent
0de0f25c90
commit
2ff16d3375
4 files changed
+120
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import java.awt.AWTException;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
class SneakyThrowsMultiple {
|
||||
public void test() {
|
||||
try {
|
||||
try {
|
||||
System.out.println("test1");
|
||||
throw new IOException();
|
||||
} catch (IOException $ex) {
|
||||
throw lombok.Lombok.sneakyThrow($ex);
|
||||
}
|
||||
} catch (Throwable $ex) {
|
||||
throw lombok.Lombok.sneakyThrow($ex);
|
||||
}
|
||||
}
|
||||
public void test2() {
|
||||
try {
|
||||
try {
|
||||
System.out.println("test2");
|
||||
if (new Random().nextBoolean()) {
|
||||
throw new IOException();
|
||||
} else {
|
||||
throw new AWTException("WHAT");
|
||||
}
|
||||
} catch (AWTException $ex) {
|
||||
throw lombok.Lombok.sneakyThrow($ex);
|
||||
}
|
||||
} catch (IOException $ex) {
|
||||
throw lombok.Lombok.sneakyThrow($ex);
|
||||
}
|
||||
}
|
||||
public void test3() {
|
||||
try {
|
||||
try {
|
||||
System.out.println("test3");
|
||||
throw new IOException();
|
||||
} catch (IOException $ex) {
|
||||
throw lombok.Lombok.sneakyThrow($ex);
|
||||
}
|
||||
} catch (Throwable $ex) {
|
||||
throw lombok.Lombok.sneakyThrow($ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import java.io.IOException;
|
||||
class SneakyThrowsSingle {
|
||||
public void test() {
|
||||
try {
|
||||
System.out.println("test1");
|
||||
} catch (Throwable $ex) {
|
||||
throw lombok.Lombok.sneakyThrow($ex);
|
||||
}
|
||||
}
|
||||
public void test2() {
|
||||
try {
|
||||
System.out.println("test2");
|
||||
throw new IOException();
|
||||
} catch (IOException $ex) {
|
||||
throw lombok.Lombok.sneakyThrow($ex);
|
||||
}
|
||||
}
|
||||
public void test3() {
|
||||
try {
|
||||
System.out.println("test3");
|
||||
throw new IOException();
|
||||
} catch (IOException $ex) {
|
||||
throw lombok.Lombok.sneakyThrow($ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import java.awt.AWTException;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
class SneakyThrowsMultiple {
|
||||
@lombok.SneakyThrows(IOException.class,Throwable.class)
|
||||
public void test() {
|
||||
System.out.println("test1");
|
||||
throw new IOException();
|
||||
}
|
||||
|
||||
@lombok.SneakyThrows(AWTException.class,IOException.class)
|
||||
public void test2() {
|
||||
System.out.println("test2");
|
||||
if (new Random().nextBoolean()) {
|
||||
throw new IOException();
|
||||
}
|
||||
else {
|
||||
throw new AWTException("WHAT");
|
||||
}
|
||||
}
|
||||
|
||||
@lombok.SneakyThrows(value={IOException.class,Throwable.class})
|
||||
public void test3() {
|
||||
System.out.println("test3");
|
||||
throw new IOException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import java.io.IOException;
|
||||
|
||||
class SneakyThrowsSingle {
|
||||
@lombok.SneakyThrows(Throwable.class)
|
||||
public void test() {
|
||||
System.out.println("test1");
|
||||
}
|
||||
|
||||
@lombok.SneakyThrows(IOException.class)
|
||||
public void test2() {
|
||||
System.out.println("test2");
|
||||
throw new IOException();
|
||||
}
|
||||
|
||||
@lombok.SneakyThrows(value=IOException.class)
|
||||
public void test3() {
|
||||
System.out.println("test3");
|
||||
throw new IOException();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user