| 1 |
//! Tests for Rust playground support. |
| 2 |
|
| 3 |
use crate::prelude::*; |
| 4 |
|
| 5 |
// Verifies that a rust codeblock gets the playground class. |
| 6 |
#[test] |
| 7 |
fn playground_on_rust_code() { |
| 8 |
BookTest::from_dir("playground/playground_on_rust_code").check_main_file( |
| 9 |
"book/index.html", |
| 10 |
str![[r##" |
| 11 |
<h1 id="rust-sample"><a class="header" href="#rust-sample">Rust Sample</a></h1> |
| 12 |
<pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)] |
| 13 |
</span><span class="boring">fn main() { |
| 14 |
</span>let x = 1; |
| 15 |
<span class="boring">}</span></code></pre> |
| 16 |
"##]], |
| 17 |
); |
| 18 |
} |
| 19 |
|
| 20 |
// When the playground is disabled, there should be no playground class. |
| 21 |
#[test] |
| 22 |
fn disabled_playground() { |
| 23 |
BookTest::from_dir("playground/disabled_playground").check_main_file( |
| 24 |
"book/index.html", |
| 25 |
str![[r##" |
| 26 |
<h1 id="rust-sample"><a class="header" href="#rust-sample">Rust Sample</a></h1> |
| 27 |
<pre><code class="language-rust">let x = 1;</code></pre> |
| 28 |
"##]], |
| 29 |
); |
| 30 |
} |