Skip to content

Commit

Permalink
Add integration test for macro expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
shepmaster committed May 25, 2020
1 parent 8abd141 commit a3cf77b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/spec/features/tools_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit a3cf77b

Please sign in to comment.