From a3cf77bd7f0f39de99be80c9e4e35bb4e5641644 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Mon, 25 May 2020 13:22:07 -0400 Subject: [PATCH] Add integration test for macro expansion --- tests/spec/features/tools_spec.rb | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/spec/features/tools_spec.rb b/tests/spec/features/tools_spec.rb index 983ded16e..d3c82a7f3 100644 --- a/tests/spec/features/tools_spec.rb +++ b/tests/spec/features/tools_spec.rb @@ -57,6 +57,39 @@ def code_with_undefined_behavior EOF end + scenario "expand macros with the nightly compiler" do + editor.set code_that_uses_macros + in_tools_menu { click_on("Expand macros") } + + within(".output-stdout") do + # First-party + expect(page).to have_content('core::fmt::Arguments::new_v1') + + # Third-party procedural macro + expect(page).to have_content('block_on(async') + + # User-specified declarative macro + expect(page).to have_content('fn created_by_macro() -> i32 { 42 }') + end + end + + def code_that_uses_macros + <<~EOF + macro_rules! demo { + ($name:ident) => { + fn $name() -> i32 { 42 } + } + } + + demo!(created_by_macro); + + #[tokio::main] + async fn example() { + println!("a value: {}", created_by_macro()); + } + EOF + end + def editor Editor.new(page) end