summary refs log tree commit diff
path: root/lib/tests/misc.nix
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2022-09-15 17:29:38 +0100
committerRobert Hensing <robert@roberthensing.nl>2022-09-17 22:16:39 +0100
commit1cbe950384a24f0b8272e3cc8813662292896821 (patch)
tree7fa8f803705bd85f363d1ad9e8400f97ea38dedf /lib/tests/misc.nix
parent1158501e7c7cba26d922723cf9f70099995eb755 (diff)
downloadnixpkgs-1cbe950384a24f0b8272e3cc8813662292896821.tar
nixpkgs-1cbe950384a24f0b8272e3cc8813662292896821.tar.gz
nixpkgs-1cbe950384a24f0b8272e3cc8813662292896821.tar.bz2
nixpkgs-1cbe950384a24f0b8272e3cc8813662292896821.tar.lz
nixpkgs-1cbe950384a24f0b8272e3cc8813662292896821.tar.xz
nixpkgs-1cbe950384a24f0b8272e3cc8813662292896821.tar.zst
nixpkgs-1cbe950384a24f0b8272e3cc8813662292896821.zip
lib.types: Add parentheses where description is ambiguous
Diffstat (limited to 'lib/tests/misc.nix')
-rw-r--r--lib/tests/misc.nix53
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix
index 584a946e92c..9b1397a7915 100644
--- a/lib/tests/misc.nix
+++ b/lib/tests/misc.nix
@@ -1206,4 +1206,57 @@ runTests {
     expr = strings.levenshteinAtMost 3 "hello" "Holla";
     expected = true;
   };
+
+  testTypeDescriptionInt = {
+    expr = (with types; int).description;
+    expected = "signed integer";
+  };
+  testTypeDescriptionListOfInt = {
+    expr = (with types; listOf int).description;
+    expected = "list of signed integer";
+  };
+  testTypeDescriptionListOfListOfInt = {
+    expr = (with types; listOf (listOf int)).description;
+    expected = "list of list of signed integer";
+  };
+  testTypeDescriptionListOfEitherStrOrBool = {
+    expr = (with types; listOf (either str bool)).description;
+    expected = "list of (string or boolean)";
+  };
+  testTypeDescriptionEitherListOfStrOrBool = {
+    expr = (with types; either (listOf bool) str).description;
+    expected = "(list of boolean) or string";
+  };
+  testTypeDescriptionEitherStrOrListOfBool = {
+    expr = (with types; either str (listOf bool)).description;
+    expected = "string or list of boolean";
+  };
+  testTypeDescriptionOneOfListOfStrOrBool = {
+    expr = (with types; oneOf [ (listOf bool) str ]).description;
+    expected = "(list of boolean) or string";
+  };
+  testTypeDescriptionOneOfListOfStrOrBoolOrNumber = {
+    expr = (with types; oneOf [ (listOf bool) str number ]).description;
+    expected = "(list of boolean) or string or signed integer or floating point number";
+  };
+  testTypeDescriptionEitherListOfBoolOrEitherStringOrNumber = {
+    expr = (with types; either (listOf bool) (either str number)).description;
+    expected = "(list of boolean) or string or signed integer or floating point number";
+  };
+  testTypeDescriptionEitherEitherListOfBoolOrStringOrNumber = {
+    expr = (with types; either (either (listOf bool) str) number).description;
+    expected = "(list of boolean) or string or signed integer or floating point number";
+  };
+  testTypeDescriptionEitherNullOrBoolOrString = {
+    expr = (with types; either (nullOr bool) str).description;
+    expected = "null or boolean or string";
+  };
+  testTypeDescriptionEitherListOfEitherBoolOrStrOrInt = {
+    expr = (with types; either (listOf (either bool str)) int).description;
+    expected = "(list of (boolean or string)) or signed integer";
+  };
+  testTypeDescriptionEitherIntOrListOrEitherBoolOrStr = {
+    expr = (with types; either int (listOf (either bool str))).description;
+    expected = "signed integer or list of (boolean or string)";
+  };
 }