summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-02-09 22:56:44 +0100
committerLaurenz <laurmaedje@gmail.com>2021-02-09 22:56:44 +0100
commitf9197dcfef11c4c054a460c80ff6023dae6f1f2a (patch)
tree500d28b7a6e35eb99245deaa38367a19dc2aed7b /tests
parent06ca740d01b428f12f6bd327257cd05dce737b03 (diff)
Add arguments value 🏓
Diffstat (limited to 'tests')
-rw-r--r--tests/lang/ref/call-args.pngbin3713 -> 3295 bytes
-rw-r--r--tests/lang/ref/call-bracket.pngbin1897 -> 1700 bytes
-rw-r--r--tests/lang/ref/call-chain.pngbin10171 -> 8692 bytes
-rw-r--r--tests/lang/ref/call-invalid.pngbin1905 -> 1706 bytes
-rw-r--r--tests/lang/ref/comment.pngbin1215 -> 1168 bytes
-rw-r--r--tests/lang/ref/if-branch.pngbin2040 -> 1959 bytes
-rw-r--r--tests/lang/ref/repr.pngbin8440 -> 8355 bytes
-rw-r--r--tests/typeset.rs28
8 files changed, 6 insertions, 22 deletions
diff --git a/tests/lang/ref/call-args.png b/tests/lang/ref/call-args.png
index 0ce9000a..99acd84b 100644
--- a/tests/lang/ref/call-args.png
+++ b/tests/lang/ref/call-args.png
Binary files differ
diff --git a/tests/lang/ref/call-bracket.png b/tests/lang/ref/call-bracket.png
index 2f020629..a1214b3d 100644
--- a/tests/lang/ref/call-bracket.png
+++ b/tests/lang/ref/call-bracket.png
Binary files differ
diff --git a/tests/lang/ref/call-chain.png b/tests/lang/ref/call-chain.png
index 5c90dbd8..de5520b8 100644
--- a/tests/lang/ref/call-chain.png
+++ b/tests/lang/ref/call-chain.png
Binary files differ
diff --git a/tests/lang/ref/call-invalid.png b/tests/lang/ref/call-invalid.png
index e03d84c1..a60e037f 100644
--- a/tests/lang/ref/call-invalid.png
+++ b/tests/lang/ref/call-invalid.png
Binary files differ
diff --git a/tests/lang/ref/comment.png b/tests/lang/ref/comment.png
index 79f438b2..0ab9a988 100644
--- a/tests/lang/ref/comment.png
+++ b/tests/lang/ref/comment.png
Binary files differ
diff --git a/tests/lang/ref/if-branch.png b/tests/lang/ref/if-branch.png
index 8bb85296..4e7f471a 100644
--- a/tests/lang/ref/if-branch.png
+++ b/tests/lang/ref/if-branch.png
Binary files differ
diff --git a/tests/lang/ref/repr.png b/tests/lang/ref/repr.png
index f3bf781e..110e26c0 100644
--- a/tests/lang/ref/repr.png
+++ b/tests/lang/ref/repr.png
Binary files differ
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 {