summaryrefslogtreecommitdiff
path: root/tests/src/tests.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-09-19 16:53:59 +0200
committerLaurenz <laurmaedje@gmail.com>2023-09-19 16:53:59 +0200
commit7a46a85d3e25dd7eeee6abc9068302ba8d01fa65 (patch)
treeae52e800ee0d9dc979043439ee2748998bf26fbe /tests/src/tests.rs
parent163c2e1aa27169c1eba946204096d3e8fdfd3c18 (diff)
Improve span stability after incremental parsing
Diffstat (limited to 'tests/src/tests.rs')
-rw-r--r--tests/src/tests.rs17
1 files changed, 6 insertions, 11 deletions
diff --git a/tests/src/tests.rs b/tests/src/tests.rs
index e7595cf7..d7536907 100644
--- a/tests/src/tests.rs
+++ b/tests/src/tests.rs
@@ -25,7 +25,7 @@ use typst::doc::{Document, Frame, FrameItem, Meta};
use typst::eval::{eco_format, func, Bytes, Datetime, Library, NoneValue, Tracer, Value};
use typst::font::{Font, FontBook};
use typst::geom::{Abs, Color, Smart};
-use typst::syntax::{FileId, PackageVersion, Source, Span, SyntaxNode, VirtualPath};
+use typst::syntax::{FileId, PackageVersion, Source, SyntaxNode, VirtualPath};
use typst::{World, WorldExt};
use typst_library::layout::{Margin, PageElem};
use typst_library::text::{TextElem, TextSize};
@@ -779,7 +779,6 @@ fn test_reparse(
];
let mut ok = true;
-
let mut apply = |replace: Range<usize>, with| {
let mut incr_source = Source::detached(text);
if incr_source.root().len() != text.len() {
@@ -795,18 +794,14 @@ fn test_reparse(
let edited_src = incr_source.text();
let ref_source = Source::detached(edited_src);
- let mut ref_root = ref_source.root().clone();
- let mut incr_root = incr_source.root().clone();
+ let ref_root = ref_source.root();
+ let incr_root = incr_source.root();
// Ensures that the span numbering invariants hold.
- let spans_ok = test_spans(output, &ref_root) && test_spans(output, &incr_root);
+ let spans_ok = test_spans(output, ref_root) && test_spans(output, incr_root);
- // Remove all spans so that the comparison works out.
- let tree_ok = {
- ref_root.synthesize(Span::detached());
- incr_root.synthesize(Span::detached());
- ref_root == incr_root
- };
+ // Ensure that the reference and incremental trees are the same.
+ let tree_ok = ref_root.spanless_eq(incr_root);
if !tree_ok {
writeln!(