From ae68a15a46c3a9fce4db7bfbf129ee103dd4c30d Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 27 May 2022 14:19:58 +0200 Subject: [PATCH] Print function for debugging --- tests/typeset.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/typeset.rs b/tests/typeset.rs index 72bdb4313..0d6031259 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -70,7 +70,7 @@ fn main() { ); styles.set(TextNode::SIZE, TextSize(Length::pt(10.0).into())); - // Hook up two more colors and an assert function into the global scope. + // Hook up helpers into the global scope. let mut std = typst::library::new(); std.define("conifer", RgbaColor::new(0x9f, 0xEB, 0x52, 0xFF)); std.define("forest", RgbaColor::new(0x43, 0xA1, 0x27, 0xFF)); @@ -82,6 +82,17 @@ fn main() { } Ok(Value::None) }); + std.def_fn("print", move |_, args| { + print!("> "); + for (i, value) in args.all::()?.into_iter().enumerate() { + if i > 0 { + print!(", ") + } + print!("{value:?}"); + } + println!(); + Ok(Value::None) + }); // Create loader and context. let loader = FsLoader::new().with_path(FONT_DIR);