/**
 * 
 */
package com.github.phantomthief.test;

import java.io.IOException;

import org.junit.Test;

import com.github.phantomthief.util.MoreFunctions;
import com.google.common.base.Supplier;

/**
 * @author w.vela
 */
public class MoreFunctionsTest {

    @Test
    public void testTrying() throws Exception {
        assert (MoreFunctions.catching(i -> function(i, Exception::new), 1) == null);
        assert (MoreFunctions.catching(i -> function(i, IllegalArgumentException::new), 1) == null);
        assert (MoreFunctions.catching(i -> function(i, null), 1).equals("1"));
        try {
            MoreFunctions.catching(i -> function(i, IllegalArgumentException::new), 1,
                    IOException.class);
            assert (false);
        } catch (Throwable e) {
            assert (e.getClass() == IllegalArgumentException.class);
        }
    }

    private <X extends Throwable> String function(int i, Supplier<X> exception) throws X {
        if (exception != null) {
            X x = exception.get();
            throw x;
        } else {
            return i + "";
        }
    }
}

@@ -55,37 +55,75 @@
 ort 
-java.io.IOException;%0A
+static com.github.phantomthief.util.MoreFunctions.catching;
 %0Aimport 
 org.
@@ -118,16 +118,23 @@
 %0Aimport 
+static 
 org.juni
@@ -139,65 +139,51 @@
 nit.
-Test;%0A%0Aimport com.github.phantomthief.util.MoreFunctions;
+Assert.assertTrue;%0A%0Aimport org.junit.Test;%0A
 %0Aimp
@@ -352,32 +352,21 @@
   assert
- (MoreFunctions.
+True(
 catching
@@ -427,32 +427,21 @@
   assert
- (MoreFunctions.
+True(
 catching
@@ -521,24 +521,13 @@
 sert
- (MoreFunctions.
+True(
 catc
@@ -576,288 +576,8 @@
 ));%0A
-        try %7B%0A            MoreFunctions.catching(i -%3E function(i, IllegalArgumentException::new), 1,%0A                    IOException.class);%0A            assert (false);%0A        %7D catch (Throwable e) %7B%0A            assert (e.getClass() == IllegalArgumentException.class);%0A        %7D%0A
     

fix testcase.