Skip to content
Permalink
Browse files

That - some javadocs and buck test vm_args

  • Loading branch information...
elucash committed Apr 12, 2019
1 parent 9118862 commit de73defee9c61fa60ef0399c7978b1fbd1311345
Showing with 160 additions and 6 deletions.
  1. +7 −2 lib/rules.bzl
  2. +2 −1 mod/grammar/BUCK
  3. +2 −1 mod/lang/BUCK
  4. +65 −2 mod/that/src/io/immutables/that/Assert.java
  5. +84 −0 mod/that/src/io/immutables/that/That.java
@@ -15,6 +15,8 @@ _kotlin_test_deps_default = [
'//lib/junit:junit'
]

_java_test_vm_args = ['-ea', '-Dio.immutables.that.replace-error-message= ']

def java_module(
name,
deps = [],
@@ -45,7 +47,7 @@ def java_module(
resources_root = 'test',
deps = _dedupe([':' + name] + _java_test_deps_default + test_deps),
plugins = plugins,
vm_args = ['-ea', '-Dio.immutables.that.replace-error-message= '],
vm_args = _java_test_vm_args,
)

def kotlin_module(
@@ -78,9 +80,12 @@ def kotlin_module(
resources_root = 'test',
deps = _dedupe([':' + name] + _kotlin_test_deps_default + test_deps),
plugins = plugins,
vm_args = ['-ea'],
vm_args = _java_test_vm_args,
)

def _dedupe(seq):
seen = {}
return [x for x in seq if not (x in seen or seen.update({x: ()}))]

def java_test_vm_args():
return _java_test_vm_args
@@ -1,4 +1,4 @@
load('//lib:rules.bzl', 'java_module')
load('//lib:rules.bzl', 'java_module', 'java_test_vm_args')

java_library(
name = 'grammar',
@@ -83,4 +83,5 @@ java_test(
'//mod/that:that',
'//lib/junit:junit',
],
vm_args = java_test_vm_args(),
)
@@ -1,4 +1,4 @@
load('//lib:rules.bzl', 'java_module')
load('//lib:rules.bzl', 'java_module', 'java_test_vm_args')

java_library(
name = 'lang',
@@ -80,4 +80,5 @@ java_test(
':sourcerun_processor',
'//mod/common:immutables',
],
vm_args = java_test_vm_args(),
)
@@ -6,95 +6,158 @@
import javax.annotation.Nullable;

/**
* {@code Assert.that}: Minimalistic, extensible and attentive to details assertion checker
* toolkit.
* {@code Assert.that}: Minimalistic, extensible and attentive to details assertions.
*/
public final class Assert {
private Assert() {}

/**
* @return that condition
*/
@CheckReturnValue
public static That.Condition that() {
class Tested implements That.Condition {}
return new Tested();
}

/**
* @param actualRuns runnable or lambda
* @return that runnable
*/
@CheckReturnValue
public static That.Runnable that(Runnable actualRuns) {
class Tested extends That.What<Runnable, That.Runnable> implements That.Runnable {}
return new Tested().set(actualRuns);
}

/**
* @param <T> actual object type
* @param actual object
* @return that object
*/
@CheckReturnValue
public static <T> That.Object<T> that(@Nullable T actual) {
class Tested extends That.What<T, That.Object<T>> implements That.Object<T> {}
return new Tested().set(actual);
}

/**
* @param <T> actual object type
* @param actual optional object
* @return that optional
*/
@CheckReturnValue
public static <T> That.Optional<T> that(java.util.Optional<T> actual) {
class Tested extends That.What<java.util.Optional<T>, That.Optional<T>> implements That.Optional<T> {}
return new Tested().set(actual);
}

/**
* @param <T> actual element type
* @param actual iterable object
* @return that iterable
*/
@CheckReturnValue
public static <T> That.Iterable<T> that(java.lang.Iterable<T> actual) {
class Tested extends That.What<java.lang.Iterable<T>, That.Iterable<T>> implements That.Iterable<T> {}
return new Tested().set(actual);
}

/**
* @param <T> actual element type
* @param actual stream object
* @return that iterable
*/
@CheckReturnValue
public static <T> That.Iterable<T> that(java.util.stream.Stream<T> actual) {
class Tested extends That.What<java.lang.Iterable<T>, That.Iterable<T>> implements That.Iterable<T> {}
return new Tested().set(actual.collect(Collectors.toList()));
}

/**
* @param <T> actual component type
* @param actual array object
* @return that iterable
*/
@CheckReturnValue
@SafeVarargs
public static <T> That.Iterable<T> that(T... actual) {
class Tested extends That.What<java.lang.Iterable<T>, That.Iterable<T>> implements That.Iterable<T> {}
return new Tested().set(Arrays.asList(actual));
}

/**
* @param actual long value or null
* @return that double
*/
@CheckReturnValue
public static That.String that(@Nullable String actual) {
class Tested extends That.What<String, That.String> implements That.String {}
return new Tested().set(actual);
}

/**
* @param actual long value or null
* @return that double
*/
@CheckReturnValue
public static That.Boolean that(@Nullable Boolean actual) {
class Tested extends That.What<Boolean, That.Boolean> implements That.Boolean {}
return new Tested().set(actual);
}

/**
* @param actual long value or null
* @return that double
*/
@CheckReturnValue
public static That.Double that(@Nullable Double actual) {
class Tested extends That.What<Double, That.Double> implements That.Double {}
return new Tested().set(actual);
}

/**
* @param actual long value or null
* @return that long
*/
@CheckReturnValue
public static That.Long that(@Nullable Long actual) {
class Tested extends That.What<Long, That.Long> implements That.Long {}
return new Tested().set(actual);
}

/**
* @param actual int value or null
* @return that integer
*/
@CheckReturnValue
public static That.Int that(@Nullable Integer actual) {
class Tested extends That.What<Integer, That.Int> implements That.Int {}
return new Tested().set(actual);
}

/**
* @param actual short value or null
* @return that integer
*/
@CheckReturnValue
public static That.Int that(@Nullable Short actual) {
return that(actual == null ? null : actual.intValue());
}

/**
* @param actual character value or null
* @return that integer
*/
@CheckReturnValue
public static That.Int that(@Nullable Character actual) {
return that(actual == null ? null : (int) actual.charValue());
}

/**
* @param actual float value or null
* @return that double
*/
@CheckReturnValue
public static That.Double that(@Nullable Float actual) {
return that(actual == null ? null : actual.doubleValue());
Oops, something went wrong.

0 comments on commit de73def

Please sign in to comment.
You can’t perform that action at this time.