]> git.lizzy.rs Git - rust.git/commitdiff
Add test for union keyword highlighting
authorGuillaume Gomez <guillaume.gomez@huawei.com>
Sat, 24 Jul 2021 14:08:27 +0000 (16:08 +0200)
committerGuillaume Gomez <guillaume.gomez@huawei.com>
Fri, 6 Aug 2021 13:27:22 +0000 (15:27 +0200)
src/librustdoc/html/highlight/fixtures/union.html [new file with mode: 0644]
src/librustdoc/html/highlight/fixtures/union.rs [new file with mode: 0644]
src/librustdoc/html/highlight/tests.rs

diff --git a/src/librustdoc/html/highlight/fixtures/union.html b/src/librustdoc/html/highlight/fixtures/union.html
new file mode 100644 (file)
index 0000000..c0acf31
--- /dev/null
@@ -0,0 +1,8 @@
+<span class="kw">union</span> <span class="ident">Foo</span> {
+    <span class="ident">i</span>: <span class="ident">i8</span>,
+    <span class="ident">u</span>: <span class="ident">i8</span>,
+}
+
+<span class="kw">fn</span> <span class="ident">main</span>() {
+    <span class="kw">let</span> <span class="ident">union</span> <span class="op">=</span> <span class="number">0</span>;
+}
diff --git a/src/librustdoc/html/highlight/fixtures/union.rs b/src/librustdoc/html/highlight/fixtures/union.rs
new file mode 100644 (file)
index 0000000..269ee11
--- /dev/null
@@ -0,0 +1,8 @@
+union Foo {
+    i: i8,
+    u: i8,
+}
+
+fn main() {
+    let union = 0;
+}
index 68592ae96c187b273eebb1c5d76c417b0fa86954..450bbfea1ea863143504f6f0a9ec91b77b5cee80 100644 (file)
@@ -54,3 +54,13 @@ fn test_keyword_highlight() {
         expect_file!["fixtures/highlight.html"].assert_eq(&html.into_inner());
     });
 }
+
+#[test]
+fn test_union_highlighting() {
+    create_default_session_globals_then(|| {
+        let src = include_str!("fixtures/union.rs");
+        let mut html = Buffer::new();
+        write_code(&mut html, src, Edition::Edition2018, None);
+        expect_file!["fixtures/union.html"].assert_eq(&html.into_inner());
+    });
+}