about summary refs log tree commit diff
path: root/tests/rustdoc-js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/rustdoc-js')
-rw-r--r--tests/rustdoc-js/doc-alias.js13
-rw-r--r--tests/rustdoc-js/generics-trait.js21
-rw-r--r--tests/rustdoc-js/non-english-identifier.js8
-rw-r--r--tests/rustdoc-js/ordering.js9
-rw-r--r--tests/rustdoc-js/ordering.rs3
-rw-r--r--tests/rustdoc-js/pointer.js240
-rw-r--r--tests/rustdoc-js/pointer.rs40
-rw-r--r--tests/rustdoc-js/sort-stability.js9
-rw-r--r--tests/rustdoc-js/sort-stability.rs16
-rw-r--r--tests/rustdoc-js/type-parameters.js6
10 files changed, 323 insertions, 42 deletions
diff --git a/tests/rustdoc-js/doc-alias.js b/tests/rustdoc-js/doc-alias.js
index e57bd71419d..74f1665f74a 100644
--- a/tests/rustdoc-js/doc-alias.js
+++ b/tests/rustdoc-js/doc-alias.js
@@ -232,6 +232,12 @@ const EXPECTED = [
         'query': 'UnionItem',
         'others': [
             {
+                'path': 'doc_alias::Union',
+                'name': 'union_item',
+                'desc': 'Doc for <code>Union::union_item</code>',
+                'href': '../doc_alias/union.Union.html#structfield.union_item'
+            },
+            {
                 'path': 'doc_alias',
                 'name': 'Union',
                 'desc': 'Doc for <code>Union</code>',
@@ -239,13 +245,6 @@ const EXPECTED = [
                 'href': '../doc_alias/union.Union.html',
                 'is_alias': true
             },
-            // Not an alias!
-            {
-                'path': 'doc_alias::Union',
-                'name': 'union_item',
-                'desc': 'Doc for <code>Union::union_item</code>',
-                'href': '../doc_alias/union.Union.html#structfield.union_item'
-            },
         ],
     },
     {
diff --git a/tests/rustdoc-js/generics-trait.js b/tests/rustdoc-js/generics-trait.js
index 8da9c67050e..cd100463e9a 100644
--- a/tests/rustdoc-js/generics-trait.js
+++ b/tests/rustdoc-js/generics-trait.js
@@ -25,8 +25,25 @@ const EXPECTED = [
     },
     {
         'query': 'Resulx<SomeTrait>',
-        'in_args': [],
-        'returned': [],
+        'correction': 'Result',
+        'in_args': [
+            {
+                'path': 'generics_trait',
+                'name': 'beta',
+                'displayType': '`Result`<`T`, ()> -> ()',
+                'displayMappedNames': '',
+                'displayWhereClause': 'T: `SomeTrait`',
+            },
+        ],
+        'returned': [
+            {
+                'path': 'generics_trait',
+                'name': 'bet',
+                'displayType': ' -> `Result`<`T`, ()>',
+                'displayMappedNames': '',
+                'displayWhereClause': 'T: `SomeTrait`',
+            },
+        ],
     },
     {
         'query': 'Result<SomeTraiz>',
diff --git a/tests/rustdoc-js/non-english-identifier.js b/tests/rustdoc-js/non-english-identifier.js
index 3d50bd3ee90..0f9ffe7c038 100644
--- a/tests/rustdoc-js/non-english-identifier.js
+++ b/tests/rustdoc-js/non-english-identifier.js
@@ -7,7 +7,7 @@ const PARSED = [
             pathWithoutLast: [],
             pathLast: "中文",
             generics: [],
-            typeFilter: -1,
+            typeFilter: null,
         }],
         returned: [],
         foundElems: 1,
@@ -23,7 +23,7 @@ const PARSED = [
             pathLast: "_0mixed中英文",
             normalizedPathLast: "0mixed中英文",
             generics: [],
-            typeFilter: -1,
+            typeFilter: null,
         }],
         foundElems: 1,
         userQuery: "_0Mixed中英文",
@@ -38,7 +38,7 @@ const PARSED = [
             pathWithoutLast: ["my_crate"],
             pathLast: "中文api",
             generics: [],
-            typeFilter: -1,
+            typeFilter: null,
         }],
         foundElems: 1,
         userQuery: "my_crate::中文API",
@@ -94,7 +94,7 @@ const PARSED = [
             pathWithoutLast: ["my_crate"],
             pathLast: "中文宏",
             generics: [],
-            typeFilter: 16,
+            typeFilter: "macro",
         }],
         foundElems: 1,
         userQuery: "my_crate 中文宏!",
diff --git a/tests/rustdoc-js/ordering.js b/tests/rustdoc-js/ordering.js
new file mode 100644
index 00000000000..a7c10900da6
--- /dev/null
+++ b/tests/rustdoc-js/ordering.js
@@ -0,0 +1,9 @@
+const EXPECTED = [
+    {
+        'query': 'Entry',
+        'others': [
+            { 'path': 'ordering', 'name': 'Entry1a' },
+            { 'path': 'ordering', 'name': 'Entry2ab' },
+        ],
+    },
+];
diff --git a/tests/rustdoc-js/ordering.rs b/tests/rustdoc-js/ordering.rs
new file mode 100644
index 00000000000..18ca06ab5ec
--- /dev/null
+++ b/tests/rustdoc-js/ordering.rs
@@ -0,0 +1,3 @@
+pub struct Entry1a;
+pub struct Entry1b;
+pub struct Entry2ab;
diff --git a/tests/rustdoc-js/pointer.js b/tests/rustdoc-js/pointer.js
new file mode 100644
index 00000000000..b2b556858fd
--- /dev/null
+++ b/tests/rustdoc-js/pointer.js
@@ -0,0 +1,240 @@
+// exact-check
+
+const EXPECTED = [
+    // pinkie with explicit names
+    {
+        'query': 'usize, usize -> ()',
+        'others': [
+            { 'path': 'pointer', 'name': 'pinky' },
+        ],
+    },
+    {
+        'query': 'pointer<usize>, usize -> ()',
+        'others': [
+            { 'path': 'pointer', 'name': 'pinky' },
+        ],
+    },
+    {
+        'query': 'pointer<usize>, pointer<usize> -> ()',
+        'others': [],
+    },
+    {
+        'query': 'pointer<mut, usize>, usize -> ()',
+        'others': [],
+    },
+    // thumb with explicit names
+    {
+        'query': 'thumb, thumb -> ()',
+        'others': [
+            { 'path': 'pointer::Thumb', 'name': 'up' },
+        ],
+    },
+    {
+        'query': 'pointer<thumb>, thumb -> ()',
+        'others': [
+            { 'path': 'pointer::Thumb', 'name': 'up' },
+        ],
+    },
+    {
+        'query': 'pointer<thumb>, pointer<thumb> -> ()',
+        'others': [],
+    },
+    {
+        'query': 'pointer<mut, thumb>, thumb -> ()',
+        'others': [],
+    },
+    // index with explicit names
+    {
+        'query': 'index, index -> ()',
+        'others': [
+            { 'path': 'pointer::Index', 'name': 'point' },
+        ],
+    },
+    {
+        'query': 'pointer<index>, index -> ()',
+        'others': [
+            { 'path': 'pointer::Index', 'name': 'point' },
+        ],
+    },
+    {
+        'query': 'pointer<index>, pointer<index> -> ()',
+        'others': [],
+    },
+    {
+        'query': 'pointer<mut, index>, index -> ()',
+        'others': [],
+    },
+    // ring with explicit names
+    {
+        'query': 'ring, ring -> ()',
+        'others': [
+            { 'path': 'pointer::Ring', 'name': 'wear' },
+        ],
+    },
+    {
+        'query': 'pointer<ring>, ring -> ()',
+        'others': [
+            { 'path': 'pointer::Ring', 'name': 'wear' },
+        ],
+    },
+    {
+        'query': 'pointer<ring>, pointer<ring> -> ()',
+        // can't leave out the `mut`, because can't reorder like that
+        'others': [],
+    },
+    {
+        'query': 'pointer<mut, ring>, pointer<ring> -> ()',
+        'others': [
+            { 'path': 'pointer::Ring', 'name': 'wear' },
+        ],
+    },
+    {
+        'query': 'pointer<mut, ring>, pointer<mut, ring> -> ()',
+        'others': [],
+    },
+    // middle with explicit names
+    {
+        'query': 'middle, middle -> ()',
+        'others': [
+            { 'path': 'pointer', 'name': 'show' },
+        ],
+    },
+    {
+        'query': 'pointer<middle>, pointer<middle> -> ()',
+        // can't leave out the mut
+        'others': [],
+    },
+    {
+        'query': 'pointer<mut, middle>, pointer<mut, middle> -> ()',
+        'others': [
+            { 'path': 'pointer', 'name': 'show' },
+        ],
+    },
+    {
+        'query': 'pointer<pointer<mut, middle>>, pointer<mut, pointer<middle>> -> ()',
+        'others': [
+            { 'path': 'pointer', 'name': 'show' },
+        ],
+    },
+    {
+        'query': 'pointer<mut, pointer<middle>>, pointer<pointer<mut, middle>> -> ()',
+        'others': [
+            { 'path': 'pointer', 'name': 'show' },
+        ],
+    },
+    {
+        'query': 'pointer<pointer<mut, middle>>, pointer<pointer<mut, middle>> -> ()',
+        'others': [],
+    },
+    {
+        'query': 'pointer<mut, pointer<middle>>, pointer<mut, pointer<middle>> -> ()',
+        'others': [],
+    },
+    // pinkie with shorthand
+    {
+        'query': '*const usize, usize -> ()',
+        'others': [
+            { 'path': 'pointer', 'name': 'pinky' },
+        ],
+    },
+    // you can omit the `const`, if you want.
+    {
+        'query': '*usize, usize -> ()',
+        'others': [
+            { 'path': 'pointer', 'name': 'pinky' },
+        ],
+    },
+    {
+        'query': '*const usize, *const usize -> ()',
+        'others': [],
+    },
+    {
+        'query': '*mut usize, usize -> ()',
+        'others': [],
+    },
+    // thumb with shorthand
+    {
+        'query': '*const thumb, thumb -> ()',
+        'others': [
+            { 'path': 'pointer::Thumb', 'name': 'up' },
+        ],
+    },
+    {
+        'query': '*const thumb, *const thumb -> ()',
+        'others': [],
+    },
+    {
+        'query': '*mut thumb, thumb -> ()',
+        'others': [],
+    },
+    // index with explicit names
+    {
+        'query': '*const index, index -> ()',
+        'others': [
+            { 'path': 'pointer::Index', 'name': 'point' },
+        ],
+    },
+    {
+        'query': '*const index, *const index -> ()',
+        'others': [],
+    },
+    {
+        'query': '*mut index, index -> ()',
+        'others': [],
+    },
+    // ring with shorthand
+    {
+        'query': '*const ring, ring -> ()',
+        'others': [
+            { 'path': 'pointer::Ring', 'name': 'wear' },
+        ],
+    },
+    {
+        'query': '*const ring, ring -> ()',
+        'others': [
+            { 'path': 'pointer::Ring', 'name': 'wear' },
+        ],
+    },
+    {
+        'query': '*mut ring, *const ring -> ()',
+        'others': [
+            { 'path': 'pointer::Ring', 'name': 'wear' },
+        ],
+    },
+    {
+        'query': '*mut ring, *mut ring -> ()',
+        'others': [],
+    },
+    // middle with shorthand
+    {
+        'query': '*const middle, *const middle -> ()',
+        // can't leave out the mut
+        'others': [],
+    },
+    {
+        'query': '*mut middle, *mut middle -> ()',
+        'others': [
+            { 'path': 'pointer', 'name': 'show' },
+        ],
+    },
+    {
+        'query': '*const *mut middle, *mut *const middle -> ()',
+        'others': [
+            { 'path': 'pointer', 'name': 'show' },
+        ],
+    },
+    {
+        'query': '*mut *const middle, *const *mut middle -> ()',
+        'others': [
+            { 'path': 'pointer', 'name': 'show' },
+        ],
+    },
+    {
+        'query': '*const *mut middle, *const *mut middle -> ()',
+        'others': [],
+    },
+    {
+        'query': '*mut *const middle, *mut *const middle -> ()',
+        'others': [],
+    },
+];
diff --git a/tests/rustdoc-js/pointer.rs b/tests/rustdoc-js/pointer.rs
new file mode 100644
index 00000000000..8375a174303
--- /dev/null
+++ b/tests/rustdoc-js/pointer.rs
@@ -0,0 +1,40 @@
+#![feature(extern_types)]
+
+pub fn pinky(input: *const usize, manage: usize) {
+    unimplemented!()
+}
+
+pub struct Thumb;
+
+impl Thumb {
+    pub fn up(this: *const Self, finger: Thumb) {
+        unimplemented!()
+    }
+}
+
+pub enum Index {}
+
+impl Index {
+    pub fn point(self, data: *const Index) {
+        unimplemented!()
+    }
+}
+
+pub union Ring {
+    magic: u32,
+    marriage: f32,
+}
+
+impl Ring {
+    pub fn wear(this: *mut Self, extra: *const Ring) {
+        unimplemented!()
+    }
+}
+
+extern "C" {
+    pub type Middle;
+}
+
+pub fn show(left: *const *mut Middle, right: *mut *const Middle) {
+    unimplemented!()
+}
diff --git a/tests/rustdoc-js/sort-stability.js b/tests/rustdoc-js/sort-stability.js
deleted file mode 100644
index 8c095619a08..00000000000
--- a/tests/rustdoc-js/sort-stability.js
+++ /dev/null
@@ -1,9 +0,0 @@
-const EXPECTED = [
-    {
-        'query': 'foo',
-        'others': [
-            {"path": "sort_stability::old", "name": "foo"},
-            {"path": "sort_stability::new", "name": "foo"},
-        ],
-    },
-];
diff --git a/tests/rustdoc-js/sort-stability.rs b/tests/rustdoc-js/sort-stability.rs
deleted file mode 100644
index 68662bb3aab..00000000000
--- a/tests/rustdoc-js/sort-stability.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-#![feature(staged_api)]
-#![stable(feature = "foo_lib", since = "1.0.0")]
-
-#[stable(feature = "old_foo", since = "1.0.1")]
-pub mod old {
-    /// Old, stable foo
-    #[stable(feature = "old_foo", since = "1.0.1")]
-    pub fn foo() {}
-}
-
-#[unstable(feature = "new_foo", issue = "none")]
-pub mod new {
-    /// New, unstable foo
-    #[unstable(feature = "new_foo", issue = "none")]
-    pub fn foo() {}
-}
diff --git a/tests/rustdoc-js/type-parameters.js b/tests/rustdoc-js/type-parameters.js
index fa2b8d2ebfd..b1f1ee951c6 100644
--- a/tests/rustdoc-js/type-parameters.js
+++ b/tests/rustdoc-js/type-parameters.js
@@ -4,8 +4,8 @@ const EXPECTED = [
     {
         query: '-> trait:Some',
         others: [
-            { path: 'foo', name: 'alpha' },
             { path: 'foo', name: 'alef' },
+            { path: 'foo', name: 'alpha' },
         ],
     },
     {
@@ -75,10 +75,8 @@ const EXPECTED = [
     {
         query: 'Other',
         in_args: [
-            // because function is called "other", it's sorted first
-            // even though it has higher type distance
-            { path: 'foo', name: 'other' },
             { path: 'foo', name: 'alternate' },
+            { path: 'foo', name: 'other' },
         ],
     },
     {