Skip to content

Commit 0e4c4b5

Browse files
committed
Add some tests for mdx parse types, must_use
1 parent 5f6ed18 commit 0e4c4b5

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

src/lib.rs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ pub enum MdxExpressionKind {
198198
/// Can be passed as `mdx_expression_parse` in [`ParseOptions`][] to support
199199
/// expressions according to a certain grammar (typically, a programming
200200
/// language).
201+
///
201202
pub type MdxExpressionParse = dyn Fn(&str, &MdxExpressionKind) -> MdxSignal;
202203

203204
/// Control which constructs are enabled.
@@ -1579,6 +1580,9 @@ mod tests {
15791580

15801581
#[test]
15811582
fn test_constructs() {
1583+
#![allow(unused_must_use)]
1584+
Constructs::default();
1585+
15821586
let constructs = Constructs::default();
15831587
assert!(constructs.attention, "should default to `CommonMark` (1)");
15841588
assert!(
@@ -1618,6 +1622,9 @@ mod tests {
16181622

16191623
#[test]
16201624
fn test_parse_options() {
1625+
#![allow(unused_must_use)]
1626+
ParseOptions::default();
1627+
16211628
let options = ParseOptions::default();
16221629
assert!(
16231630
options.constructs.attention,
@@ -1682,6 +1689,9 @@ mod tests {
16821689

16831690
#[test]
16841691
fn test_compile_options() {
1692+
#![allow(unused_must_use)]
1693+
CompileOptions::default();
1694+
16851695
let options = CompileOptions::default();
16861696
assert!(
16871697
!options.allow_dangerous_html,
@@ -1705,6 +1715,9 @@ mod tests {
17051715

17061716
#[test]
17071717
fn test_options() {
1718+
#![allow(unused_must_use)]
1719+
Options::default();
1720+
17081721
let options = Options::default();
17091722
assert!(
17101723
options.parse.constructs.attention,
@@ -1744,6 +1757,9 @@ mod tests {
17441757

17451758
#[test]
17461759
fn test_to_html() {
1760+
#![allow(unused_must_use)]
1761+
to_html("a");
1762+
17471763
assert_eq!(
17481764
to_html("a"),
17491765
"<p>a</p>",
@@ -1753,6 +1769,9 @@ mod tests {
17531769

17541770
#[test]
17551771
fn test_to_html_with_options() {
1772+
#![allow(unused_must_use)]
1773+
to_html_with_options("a", &Options::default());
1774+
17561775
assert_eq!(
17571776
to_html_with_options("a", &Options::default()).unwrap(),
17581777
"<p>a</p>",
@@ -1762,6 +1781,9 @@ mod tests {
17621781

17631782
#[test]
17641783
fn test_to_mdast() {
1784+
#![allow(unused_must_use)]
1785+
to_mdast("a", &ParseOptions::default());
1786+
17651787
assert!(
17661788
matches!(
17671789
to_mdast("a", &ParseOptions::default()).unwrap(),
@@ -1770,4 +1792,42 @@ mod tests {
17701792
"should support turning markdown into mdast with `to_mdast`"
17711793
);
17721794
}
1795+
1796+
#[test]
1797+
fn test_mdx_expression_parse() {
1798+
fn func(_value: &str, _kind: &MdxExpressionKind) -> MdxSignal {
1799+
MdxSignal::Ok
1800+
}
1801+
1802+
let func_accepting = |_a: Box<MdxExpressionParse>| true;
1803+
1804+
assert!(
1805+
matches!(func("a", &MdxExpressionKind::Expression), MdxSignal::Ok),
1806+
"should expose an `MdxExpressionParse` type (1)"
1807+
);
1808+
1809+
assert!(
1810+
func_accepting(Box::new(func)),
1811+
"should expose an `MdxExpressionParse` type (2)"
1812+
);
1813+
}
1814+
1815+
#[test]
1816+
fn test_mdx_esm_parse() {
1817+
fn func(_value: &str) -> MdxSignal {
1818+
MdxSignal::Ok
1819+
}
1820+
1821+
let func_accepting = |_a: Box<MdxEsmParse>| true;
1822+
1823+
assert!(
1824+
matches!(func("a"), MdxSignal::Ok),
1825+
"should expose an `MdxEsmParse` type (1)"
1826+
);
1827+
1828+
assert!(
1829+
func_accepting(Box::new(func)),
1830+
"should expose an `MdxEsmParse` type (2)"
1831+
);
1832+
}
17731833
}

0 commit comments

Comments
 (0)