diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-02-09 22:56:44 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-02-09 22:56:44 +0100 |
| commit | f9197dcfef11c4c054a460c80ff6023dae6f1f2a (patch) | |
| tree | 500d28b7a6e35eb99245deaa38367a19dc2aed7b /tests | |
| parent | 06ca740d01b428f12f6bd327257cd05dce737b03 (diff) | |
Add arguments value 🏓
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/lang/ref/call-args.png | bin | 3713 -> 3295 bytes | |||
| -rw-r--r-- | tests/lang/ref/call-bracket.png | bin | 1897 -> 1700 bytes | |||
| -rw-r--r-- | tests/lang/ref/call-chain.png | bin | 10171 -> 8692 bytes | |||
| -rw-r--r-- | tests/lang/ref/call-invalid.png | bin | 1905 -> 1706 bytes | |||
| -rw-r--r-- | tests/lang/ref/comment.png | bin | 1215 -> 1168 bytes | |||
| -rw-r--r-- | tests/lang/ref/if-branch.png | bin | 2040 -> 1959 bytes | |||
| -rw-r--r-- | tests/lang/ref/repr.png | bin | 8440 -> 8355 bytes | |||
| -rw-r--r-- | tests/typeset.rs | 28 |
8 files changed, 6 insertions, 22 deletions
diff --git a/tests/lang/ref/call-args.png b/tests/lang/ref/call-args.png Binary files differindex 0ce9000a..99acd84b 100644 --- a/tests/lang/ref/call-args.png +++ b/tests/lang/ref/call-args.png diff --git a/tests/lang/ref/call-bracket.png b/tests/lang/ref/call-bracket.png Binary files differindex 2f020629..a1214b3d 100644 --- a/tests/lang/ref/call-bracket.png +++ b/tests/lang/ref/call-bracket.png diff --git a/tests/lang/ref/call-chain.png b/tests/lang/ref/call-chain.png Binary files differindex 5c90dbd8..de5520b8 100644 --- a/tests/lang/ref/call-chain.png +++ b/tests/lang/ref/call-chain.png diff --git a/tests/lang/ref/call-invalid.png b/tests/lang/ref/call-invalid.png Binary files differindex e03d84c1..a60e037f 100644 --- a/tests/lang/ref/call-invalid.png +++ b/tests/lang/ref/call-invalid.png diff --git a/tests/lang/ref/comment.png b/tests/lang/ref/comment.png Binary files differindex 79f438b2..0ab9a988 100644 --- a/tests/lang/ref/comment.png +++ b/tests/lang/ref/comment.png diff --git a/tests/lang/ref/if-branch.png b/tests/lang/ref/if-branch.png Binary files differindex 8bb85296..4e7f471a 100644 --- a/tests/lang/ref/if-branch.png +++ b/tests/lang/ref/if-branch.png diff --git a/tests/lang/ref/repr.png b/tests/lang/ref/repr.png Binary files differindex f3bf781e..110e26c0 100644 --- a/tests/lang/ref/repr.png +++ b/tests/lang/ref/repr.png diff --git a/tests/typeset.rs b/tests/typeset.rs index c894b2d4..d64294d1 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -16,7 +16,7 @@ use walkdir::WalkDir; use typst::diag::{Diag, Feedback, Level, Pass}; use typst::env::{Env, ImageResource, ResourceLoader}; -use typst::eval::{Args, EvalContext, Scope, Value, ValueFunc}; +use typst::eval::{EvalContext, Scope, Value, ValueArgs, ValueFunc}; use typst::exec::State; use typst::export::pdf; use typst::font::FsIndexExt; @@ -24,7 +24,6 @@ use typst::geom::{Length, Point, Sides, Size, Spec}; use typst::layout::{Element, Expansion, Fill, Frame, Geometry, Image, Shape}; use typst::library; use typst::parse::{LineMap, Scanner}; -use typst::pretty::{Pretty, Printer}; use typst::shaping::Shaped; use typst::syntax::{Location, Pos, SpanVec, Spanned, WithSpan}; use typst::typeset; @@ -320,28 +319,13 @@ struct Panic { } fn register_helpers(scope: &mut Scope, panics: Rc<RefCell<Vec<Panic>>>) { - pub fn f(_: &mut EvalContext, args: &mut Args) -> Value { - let (array, dict) = args.drain(); - let iter = array - .into_iter() - .map(|v| (None, v)) - .chain(dict.into_iter().map(|(k, v)| (Some(k), v))); - - let mut p = Printer::new(); - p.push_str("f("); - p.join(iter, ", ", |(key, value), p| { - if let Some(key) = key { - p.push_str(&key); - p.push_str(": "); - } - value.pretty(p); - }); - p.push(')'); - - Value::Str(p.finish()) + pub fn f(_: &mut EvalContext, args: &mut ValueArgs) -> Value { + let value = args.clone().into(); + args.items.clear(); + value } - let test = move |ctx: &mut EvalContext, args: &mut Args| -> Value { + let test = move |ctx: &mut EvalContext, args: &mut ValueArgs| -> Value { let lhs = args.require::<Value>(ctx, "left-hand side"); let rhs = args.require::<Value>(ctx, "right-hand side"); if lhs != rhs { |
