lib/types: Add coercedTo unsound tests

+5
lib/tests/modules.sh
···
checkConfigOutput "\"24\"" config.value ./declare-coerced-value.nix ./define-value-string.nix
checkConfigError 'The option value .* in .* is not.*string or signed integer.*' config.value ./declare-coerced-value.nix ./define-value-list.nix
+
# Check coerced value with unsound coercion
+
checkConfigOutput "12" config.value ./declare-coerced-value-unsound.nix
+
checkConfigError 'The option value .* in .* is not.*8 bit signed integer.* or string.*' config.value ./declare-coerced-value-unsound.nix ./define-value-string-bigint.nix
+
checkConfigError 'unrecognised JSON value' config.value ./declare-coerced-value-unsound.nix ./define-value-string-arbitrary.nix
+
cat <<EOF
====== module tests ======
$pass Pass
+10
lib/tests/modules/declare-coerced-value-unsound.nix
···
+
{ lib, ... }:
+
+
{
+
options = {
+
value = lib.mkOption {
+
default = "12";
+
type = lib.types.coercedTo lib.types.str lib.toInt lib.types.ints.s8;
+
};
+
};
+
}
+3
lib/tests/modules/define-value-string-arbitrary.nix
···
+
{
+
value = "foobar";
+
}
+3
lib/tests/modules/define-value-string-bigint.nix
···
+
{
+
value = "1000";
+
}