BinaryPredicateOperator { private static FunctionResolver lte() { return FunctionDSL .define(BuiltinFunctionName.LTE.getName(), ExprCoreType.coreTypes().stream() .map(type -> FunctionDSL .impl( FunctionDSL .nullMissingHandling( (v1, v2) -> ExprBooleanValue.of(v1.compareTo(v2) <= 0)), BOOLEAN, type, type)) .collect( Collectors.toList())); }  static void register(BuiltinFunctionRepository repository);  }
@Test public void test_lte_null() { FunctionExpression lte = dsl.lte(DSL.literal(1), DSL.ref(INT_TYPE_NULL_VALUE_FIELD, INTEGER)); assertEquals(BOOLEAN, lte.type()); assertEquals(LITERAL_NULL, lte.valueOf(valueEnv())); lte = dsl.lte(DSL.ref(INT_TYPE_NULL_VALUE_FIELD, INTEGER), DSL.literal(1)); assertEquals(BOOLEAN, lte.type()); assertEquals(LITERAL_NULL, lte.valueOf(valueEnv())); lte = dsl.lte(DSL.ref(INT_TYPE_NULL_VALUE_FIELD, INTEGER), DSL.ref(INT_TYPE_NULL_VALUE_FIELD, INTEGER)); assertEquals(BOOLEAN, lte.type()); assertEquals(LITERAL_NULL, lte.valueOf(valueEnv())); }
@Test public void test_lte_missing() { FunctionExpression lte = dsl.lte(DSL.literal(1), DSL.ref(INT_TYPE_MISSING_VALUE_FIELD, INTEGER)); assertEquals(BOOLEAN, lte.type()); assertEquals(LITERAL_MISSING, lte.valueOf(valueEnv())); lte = dsl.lte(DSL.ref(INT_TYPE_MISSING_VALUE_FIELD, INTEGER), DSL.literal(1)); assertEquals(BOOLEAN, lte.type()); assertEquals(LITERAL_MISSING, lte.valueOf(valueEnv())); lte = dsl.lte(DSL.ref(INT_TYPE_MISSING_VALUE_FIELD, INTEGER), DSL.ref(INT_TYPE_MISSING_VALUE_FIELD, INTEGER)); assertEquals(BOOLEAN, lte.type()); assertEquals(LITERAL_MISSING, lte.valueOf(valueEnv())); }
@Test public void test_null_lte_missing() { FunctionExpression lte = dsl.lte(DSL.ref(INT_TYPE_NULL_VALUE_FIELD, INTEGER), DSL.ref(INT_TYPE_MISSING_VALUE_FIELD, INTEGER)); assertEquals(BOOLEAN, lte.type()); assertEquals(LITERAL_MISSING, lte.valueOf(valueEnv())); lte = dsl.lte(DSL.ref(INT_TYPE_MISSING_VALUE_FIELD, INTEGER), DSL.ref(INT_TYPE_NULL_VALUE_FIELD, INTEGER)); assertEquals(BOOLEAN, lte.type()); assertEquals(LITERAL_MISSING, lte.valueOf(valueEnv())); }