MathematicalFunction { private static FunctionResolver cot() { return FunctionDSL.define(BuiltinFunctionName.COT.getName(), ExprCoreType.numberTypes().stream() .map(type -> FunctionDSL.impl(FunctionDSL.nullMissingHandling( v -> { Double value = v.doubleValue(); if (value == 0) { throw new ArithmeticException( String.format("Out of range value for cot(%s)", value)); } return new ExprDoubleValue(1 / Math.tan(value)); }), DOUBLE, type)).collect(Collectors.toList())); }  static void register(BuiltinFunctionRepository repository);  }
@Test public void cot_null_value() { FunctionExpression cot = dsl.cot(DSL.ref(DOUBLE_TYPE_NULL_VALUE_FIELD, DOUBLE)); assertEquals(DOUBLE, cot.type()); assertTrue(cot.valueOf(valueEnv()).isNull()); }
@Test public void cot_missing_value() { FunctionExpression cot = dsl.cot(DSL.ref(DOUBLE_TYPE_MISSING_VALUE_FIELD, DOUBLE)); assertEquals(DOUBLE, cot.type()); assertTrue(cot.valueOf(valueEnv()).isMissing()); }