From 7c37e57426d71fe0a2402e074b3f2ee05aaa6c57 Mon Sep 17 00:00:00 2001 From: Ishan Jain Date: Fri, 14 Jun 2024 09:17:56 +0530 Subject: [PATCH] added tests --- crates/ide/src/expand_macro.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/crates/ide/src/expand_macro.rs b/crates/ide/src/expand_macro.rs index 1ead045788..c411248c48 100644 --- a/crates/ide/src/expand_macro.rs +++ b/crates/ide/src/expand_macro.rs @@ -228,6 +228,32 @@ mod tests { expect.assert_eq(&actual); } + #[test] + fn only_expand_allowed_builtin_macro() { + let fail_tests = [r#" + //- minicore: asm + $0asm!("0x300, x0"); + "#]; + + for test in fail_tests { + let (analysis, pos) = fixture::position(test); + let expansion = analysis.expand_macro(pos).unwrap(); + assert!(expansion.is_none()); + } + + let tests = [( + r#" + //- minicore: concat + $0concat!("test", 10, 'b', true);"#, + expect![[r#" + concat! + "test10btrue""#]], + )]; + for (test, expect) in tests { + check(test, expect); + } + } + #[test] fn macro_expand_as_keyword() { check(