summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/compute/eval-path.pngbin0 -> 33952 bytes
-rw-r--r--tests/src/benches.rs2
-rw-r--r--tests/src/tests.rs2
-rw-r--r--tests/typ/compiler/recursion.typ35
-rw-r--r--tests/typ/compute/eval-path.typ18
-rw-r--r--tests/typ/compute/foundations.typ25
6 files changed, 52 insertions, 30 deletions
diff --git a/tests/ref/compute/eval-path.png b/tests/ref/compute/eval-path.png
new file mode 100644
index 00000000..c59dd2aa
--- /dev/null
+++ b/tests/ref/compute/eval-path.png
Binary files differ
diff --git a/tests/src/benches.rs b/tests/src/benches.rs
index 16122bd4..5ec0be61 100644
--- a/tests/src/benches.rs
+++ b/tests/src/benches.rs
@@ -57,7 +57,7 @@ fn bench_edit(iai: &mut Iai) {
fn bench_eval(iai: &mut Iai) {
let world = BenchWorld::new();
- let route = typst::eval::Route::default();
+ let route = typst::engine::Route::default();
let mut tracer = typst::eval::Tracer::new();
iai.run(|| {
typst::eval::eval(world.track(), route.track(), tracer.track_mut(), &world.source)
diff --git a/tests/src/tests.rs b/tests/src/tests.rs
index 0a936a8d..d801209e 100644
--- a/tests/src/tests.rs
+++ b/tests/src/tests.rs
@@ -535,7 +535,7 @@ fn test_part(
if world.print.model {
let world = (world as &dyn World).track();
- let route = typst::eval::Route::default();
+ let route = typst::engine::Route::default();
let mut tracer = typst::eval::Tracer::new();
let module =
diff --git a/tests/typ/compiler/recursion.typ b/tests/typ/compiler/recursion.typ
index 82da7245..461680ab 100644
--- a/tests/typ/compiler/recursion.typ
+++ b/tests/typ/compiler/recursion.typ
@@ -32,11 +32,40 @@
#test(type(f()), int)
---
+// Test redefinition.
+#let f(x) = "hello"
+#let f(x) = if x != none { f(none) } else { "world" }
+#test(f(1), "world")
+
+---
// Error: 15-21 maximum function call depth exceeded
#let rec(n) = rec(n) + 1
#rec(1)
---
-#let f(x) = "hello"
-#let f(x) = if x != none { f(none) } else { "world" }
-#test(f(1), "world")
+// Test cyclic imports during layout.
+// Error: 2-38 maximum layout depth exceeded
+// Hint: 2-38 try to reduce the amount of nesting in your layout
+#layout(_ => include "recursion.typ")
+
+---
+// Test recursive show rules.
+// Error: 22-25 maximum show rule depth exceeded
+// Hint: 22-25 check whether the show rule matches its own output
+// Hint: 22-25 this is a current compiler limitation that will be resolved in the future
+#show math.equation: $x$
+$ x $
+
+---
+// Error: 18-21 maximum show rule depth exceeded
+// Hint: 18-21 check whether the show rule matches its own output
+// Hint: 18-21 this is a current compiler limitation that will be resolved in the future
+#show "hey": box[hey]
+hey
+
+---
+// Error: 14-19 maximum show rule depth exceeded
+// Hint: 14-19 check whether the show rule matches its own output
+// Hint: 14-19 this is a current compiler limitation that will be resolved in the future
+#show "hey": "hey"
+hey
diff --git a/tests/typ/compute/eval-path.typ b/tests/typ/compute/eval-path.typ
new file mode 100644
index 00000000..c02bdfb1
--- /dev/null
+++ b/tests/typ/compute/eval-path.typ
@@ -0,0 +1,18 @@
+// Test file loading in eval.
+
+---
+// Test absolute path.
+#eval("image(\"/files/tiger.jpg\", width: 50%)")
+
+---
+#show raw: it => eval(it.text, mode: "markup")
+
+```
+#show emph: image("/files/tiger.jpg", width: 50%)
+_Tiger!_
+```
+
+---
+// Test relative path.
+// Ref: false
+#test(eval(`"HELLO" in read("./eval-path.typ")`.text), true)
diff --git a/tests/typ/compute/foundations.typ b/tests/typ/compute/foundations.typ
index 4e74966f..cabed0bf 100644
--- a/tests/typ/compute/foundations.typ
+++ b/tests/typ/compute/foundations.typ
@@ -103,30 +103,5 @@ Blue #move(dy: -0.15em)[🌊]
#eval("continue")
---
-// Error: 7-32 cannot access file system from here
-#eval("include \"../coma.typ\"")
-
----
-// Error: 7-30 cannot access file system from here
-#eval("image(\"/tiger.jpg\")")
-
----
-// Error: 23-30 cannot access file system from here
-#show raw: it => eval(it.text)
-
-```
-image("/tiger.jpg")
-```
-
----
-// Error: 23-42 cannot access file system from here
-#show raw: it => eval("[" + it.text + "]")
-
-```
-#show emph: _ => image("/giraffe.jpg")
-_No relative giraffe!_
-```
-
----
// Error: 7-12 expected semicolon or line break
#eval("1 2")