From 02d35e4aa6ef84cdbd01d881bdc5c1acd50fc7dc Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 10 Jan 2023 14:52:59 +0300 Subject: feat(tvix/eval): implement builtins.toJSON Implements `Serialize` for `tvix_eval::Value`. Special care is taken with serialisation of attribute sets, and forcing of thunks. The tests should cover both cases well. Change-Id: I9bb135bacf6f87bc6bd0bd88cef0a42308e6c335 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7803 Reviewed-by: flokli Tested-by: BuildkiteCI Autosubmit: tazjin --- .../tests/tvix_tests/eval-okay-builtins-tojson-literals.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-literals.nix (limited to 'tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-literals.nix') diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-literals.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-literals.nix new file mode 100644 index 000000000000..12e8c03b171d --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-tojson-literals.nix @@ -0,0 +1,11 @@ +# tests serialisation of literal data +builtins.toJSON [ + 42 + "hello" + 13.37 + [ ] + [ 1 2 3 ] + { } + { name = "foo"; value = 42; } + { foo = 42; } +] -- cgit 1.4.1