Skip to content

Commit 795f4b5

Browse files
committed
Add tests
1 parent d1a7b34 commit 795f4b5

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

tests/src/world.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use typst::text::{Font, FontBook, TextElem, TextSize};
2020
use typst::utils::{singleton, LazyHash};
2121
use typst::visualize::Color;
2222
use typst::{Feature, Library, World};
23+
use typst_library::foundations::{Module, Scope};
2324

2425
/// A world that provides access to the tests environment.
2526
#[derive(Clone)]
@@ -196,6 +197,14 @@ fn library() -> Library {
196197
.scope_mut()
197198
.define("forest", Color::from_u8(0x43, 0xA1, 0x27, 0xFF));
198199

200+
let mut contains_deprecated = Module::new("contains-deprecated", Scope::new());
201+
contains_deprecated.scope_mut().define_deprecated(
202+
"deprecated",
203+
NoneValue,
204+
"this is deprecated",
205+
);
206+
lib.global.scope_mut().define_module(contains_deprecated);
207+
199208
// Hook up default styles.
200209
lib.styles
201210
.set(PageElem::set_width(Smart::Custom(Abs::pt(120.0).into())));

tests/suite/scripting/deprecation.typ

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Test deprecation warnings.
2+
3+
// `contains-deprecated` is a module defined
4+
// for tests, which contains a single value:
5+
// `deprecated`, which is deprecated.
6+
7+
--- use-deprecated ---
8+
#import contains-deprecated: deprecated
9+
// Warning: 2-12 this is deprecated
10+
#deprecated
11+
12+
--- use-deprecated-wildcard ---
13+
#import contains-deprecated: *
14+
// Warning: 2-12 this is deprecated
15+
#deprecated
16+
17+
--- use-deprecated-field ---
18+
#import contains-deprecated
19+
// Warning: 22-32 this is deprecated
20+
#contains-deprecated.deprecated
21+
22+
--- no-deprecation-warning-emitted-for-binding ---
23+
#import contains-deprecated
24+
// Warning: 30-40 this is deprecated
25+
#let d = contains-deprecated.deprecated
26+
// No warning here.
27+
#d

0 commit comments

Comments
 (0)