diff options
author | Robert Hensing <roberth@users.noreply.github.com> | 2024-03-11 10:02:09 +0100 |
---|---|---|
committer | Jade Lovelace <lix@jade.fyi> | 2024-04-07 19:10:43 -0700 |
commit | b995c17f0eb8d9598f339c080c467101c1f55feb (patch) | |
tree | 1dea41c905bfdc6825135dd330c1fcf4cc0f9451 /tests/functional/repl_characterization | |
parent | de20392c37c79f0aea03d4f580171178d896be15 (diff) |
Merge pull request #10208 from 9999years/print-strings-directly
`:print` strings directly in `nix repl`
(cherry picked from commit 3539172fd2f7cee639ce46423c58beca4231f2db)
Change-Id: I1972f3bf3b56312851f38288509d371d37f21677
Upstream-PR: https://github.com/NixOS/nix/pull/10208
Diffstat (limited to 'tests/functional/repl_characterization')
-rw-r--r-- | tests/functional/repl_characterization/data/repl_printing.test | 92 | ||||
-rw-r--r-- | tests/functional/repl_characterization/repl_characterization.cc | 1 |
2 files changed, 93 insertions, 0 deletions
diff --git a/tests/functional/repl_characterization/data/repl_printing.test b/tests/functional/repl_characterization/data/repl_printing.test new file mode 100644 index 000000000..1206281e7 --- /dev/null +++ b/tests/functional/repl_characterization/data/repl_printing.test @@ -0,0 +1,92 @@ +Printing a string with escapes in it will render as a string normally. + + nix-repl> "meow\n\nmeowmeowmeow" + "meow\n\nmeowmeowmeow" + +But with :p on the string itself it will print it literally to the output. + + nix-repl> :p "meow\n\nmeowmeowmeow" + meow + + meowmeowmeow + + nix-repl> builtins.listToAttrs (builtins.genList (x: { name = "meow${toString x}"; value = { meow = { inherit x; s = "meowmeow\n\n${toString x}"; }; }; }) 10) + { + meow0 = { ... }; + meow1 = { ... }; + meow2 = { ... }; + meow3 = { ... }; + meow4 = { ... }; + meow5 = { ... }; + meow6 = { ... }; + meow7 = { ... }; + meow8 = { ... }; + meow9 = { ... }; + } + +Also, :p will expand attrs, but it will leave the strings escaped as normal if +they aren't the top level item being printed. + + nix-repl> :p builtins.listToAttrs (builtins.genList (x: { name = "meow${toString x}"; value = { meow = { inherit x; s = "meowmeow\n\n${toString x}"; }; }; }) 10) + { + meow0 = { + meow = { + s = "meowmeow\n\n0"; + x = 0; + }; + }; + meow1 = { + meow = { + s = "meowmeow\n\n1"; + x = 1; + }; + }; + meow2 = { + meow = { + s = "meowmeow\n\n2"; + x = 2; + }; + }; + meow3 = { + meow = { + s = "meowmeow\n\n3"; + x = 3; + }; + }; + meow4 = { + meow = { + s = "meowmeow\n\n4"; + x = 4; + }; + }; + meow5 = { + meow = { + s = "meowmeow\n\n5"; + x = 5; + }; + }; + meow6 = { + meow = { + s = "meowmeow\n\n6"; + x = 6; + }; + }; + meow7 = { + meow = { + s = "meowmeow\n\n7"; + x = 7; + }; + }; + meow8 = { + meow = { + s = "meowmeow\n\n8"; + x = 8; + }; + }; + meow9 = { + meow = { + s = "meowmeow\n\n9"; + x = 9; + }; + }; + } diff --git a/tests/functional/repl_characterization/repl_characterization.cc b/tests/functional/repl_characterization/repl_characterization.cc index fa5a7ba74..ae4d4030f 100644 --- a/tests/functional/repl_characterization/repl_characterization.cc +++ b/tests/functional/repl_characterization/repl_characterization.cc @@ -185,5 +185,6 @@ REPL_TEST(regression_9917); REPL_TEST(regression_9918); REPL_TEST(regression_l145); REPL_TEST(stack_vars); +REPL_TEST(repl_printing); }; // namespace nix |