From e507b842918f80340257304bd9541cb3b3abc9da Mon Sep 17 00:00:00 2001 From: sterni Date: Sat, 11 Sep 2021 21:56:05 +0200 Subject: feat(users/sterni/nix/string): very simple printf implementation This is mostly to yet another silly idea which turns out to be possible. This may be actually useful should I implement more sophisticated format specifiers like "%xd" or "%f". Change-Id: Ia56cd6f5793a09fe5e19c91a8e8f9098f3244d57 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3537 Tested-by: BuildkiteCI Reviewed-by: sterni --- users/sterni/nix/string/tests/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'users/sterni/nix/string/tests') diff --git a/users/sterni/nix/string/tests/default.nix b/users/sterni/nix/string/tests/default.nix index 2caecbfa7b3f..c8aec9464077 100644 --- a/users/sterni/nix/string/tests/default.nix +++ b/users/sterni/nix/string/tests/default.nix @@ -56,10 +56,17 @@ let })) ]; + f = "f"; + testPrintf = it "prints f" [ + (assertEq "basic %s usage" "print ${f}" (string.printf "print %s" f)) + (assertEq "% escaping" "100%" (string.printf "100%%")) + ]; + in runTestsuite "nix.string" [ testTakeDrop testIndexing testFinding testMatch + testPrintf ] -- cgit 1.4.1