package jamaica.core.functions;

import jamaica.core.interfaces.*;
import org.testng.annotations.*;
import static java.lang.System.*;
import static org.testng.Assert.*;

public class lang {

    // if_null
    @Test public void if_null__returns_the_first_parameter_if_it_is_not_null() {
        String notNull = "Hello";
        assertEquals(if_null(notNull, () -> "World"), "Hello");
    }
    @Test public void if_null__executes_the_code_block_if_the_first_parameter_is_null() {
        String notNull = null;
        assertEquals(if_null(notNull, () -> "World"), "World");
    }
    public static <T> T if_null(T object, Supplier<T> block) {
        return object != null ? object : block.get();
    }


    // parse_double
    @Test public void parse_double__parses_a_string_value_into_the_equivalent_double() {
        assertEquals(parse_double("5.0"), 5.0);
    }
    public static double parse_double(String value) {
        return Double.valueOf(value);
    }


    // sleep
    @Test public void sleep__causes_the_thread_to_pause() {
        long start = currentTimeMillis();
        sleep(1);
        assertTrue(currentTimeMillis() > start);
    }
    public static void sleep(long millis) {
        try {
            Thread.sleep(millis);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}

@@ -184,16 +184,373 @@
 lang %7B%0A%0A
+    // are_equal%0A    public static boolean are_equal(Object o1, Object o2) %7B%0A        if (o1 == null && o2 == null) %7B%0A            return true;%0A        %7D else if (o1 == null && o2 != null) %7B%0A            return false;%0A        %7D else if (o2 == null && o1 != null) %7B%0A            return false;%0A        %7D else %7B%0A            return o1.equals(o2);%0A        %7D%0A    %7D%0A%0A%0A
     // i

import are_equal function