rustdoc-json: Add some tests for typealias
item
This commit is contained in:
parent
2d0bb0d4b9
commit
bf0e862903
21
src/test/rustdoc-json/type/dyn.rs
Normal file
21
src/test/rustdoc-json/type/dyn.rs
Normal file
@ -0,0 +1,21 @@
|
||||
// ignore-tidy-linelength
|
||||
|
||||
// @count dyn.json "$.index[*][?(@.name=='dyn')].inner.items" 1
|
||||
// @set sync_int_gen = - "$.index[*][?(@.name=='SyncIntGen')].id"
|
||||
// @is - "$.index[*][?(@.name=='dyn')].inner.items[0]" $sync_int_gen
|
||||
|
||||
// @is - "$.index[*][?(@.name=='SyncIntGen')].kind" \"typedef\"
|
||||
// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.generics" '{"params": [], "where_predicates": []}'
|
||||
// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.kind" \"resolved_path\"
|
||||
// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.name" \"Box\"
|
||||
// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.bindings" []
|
||||
// @count - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args" 1
|
||||
// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.kind" \"resolved_path\"
|
||||
// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.kind" \"resolved_path\"
|
||||
// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.name" \"Fn\"
|
||||
// @count - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.param_names[*]" 3
|
||||
// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.param_names[0].trait_bound.trait.inner.name" \"Send\"
|
||||
// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.param_names[1].trait_bound.trait.inner.name" \"Sync\"
|
||||
// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.param_names[2]" "{\"outlives\": \"'static\"}"
|
||||
// @is - "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.args" '{"parenthesized": {"inputs": [],"output": {"inner": "i32","kind": "primitive"}}}'
|
||||
pub type SyncIntGen = Box<dyn Fn() -> i32 + Send + Sync + 'static>;
|
28
src/test/rustdoc-json/type/fn_lifetime.rs
Normal file
28
src/test/rustdoc-json/type/fn_lifetime.rs
Normal file
@ -0,0 +1,28 @@
|
||||
// ignore-tidy-linelength
|
||||
|
||||
// @is fn_lifetime.json "$.index[*][?(@.name=='GenericFn')].kind" \"typedef\"
|
||||
|
||||
// @count - "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*]" 1
|
||||
// @is - "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*].name" \"\'a\"
|
||||
// @has - "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*].kind.lifetime"
|
||||
// @count - "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*].kind.lifetime.outlives[*]" 0
|
||||
// @count - "$.index[*][?(@.name=='GenericFn')].inner.generics.where_predicates[*]" 0
|
||||
// @is - "$.index[*][?(@.name=='GenericFn')].inner.type.kind" \"function_pointer\"
|
||||
// @count - "$.index[*][?(@.name=='GenericFn')].inner.type.inner.generic_params[*]" 0
|
||||
// @count - "$.index[*][?(@.name=='GenericFn')].inner.type.inner.decl.inputs[*]" 1
|
||||
// @is - "$.index[*][?(@.name=='GenericFn')].inner.type.inner.decl.inputs[*][1].inner.lifetime" \"\'a\"
|
||||
// @is - "$.index[*][?(@.name=='GenericFn')].inner.type.inner.decl.output.inner.lifetime" \"\'a\"
|
||||
|
||||
pub type GenericFn<'a> = fn(&'a i32) -> &'a i32;
|
||||
|
||||
// @is fn_lifetime.json "$.index[*][?(@.name=='ForAll')].kind" \"typedef\"
|
||||
// @count - "$.index[*][?(@.name=='ForAll')].inner.generics.params[*]" 0
|
||||
// @count - "$.index[*][?(@.name=='ForAll')].inner.generics.where_predicates[*]" 0
|
||||
// @count - "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*]" 1
|
||||
// @is - "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*].name" \"\'a\"
|
||||
// @has - "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*].kind.lifetime"
|
||||
// @count - "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*].kind.lifetime.outlives[*]" 0
|
||||
// @count - "$.index[*][?(@.name=='ForAll')].inner.type.inner.decl.inputs[*]" 1
|
||||
// @is - "$.index[*][?(@.name=='ForAll')].inner.type.inner.decl.inputs[*][1].inner.lifetime" \"\'a\"
|
||||
// @is - "$.index[*][?(@.name=='ForAll')].inner.type.inner.decl.output.inner.lifetime" \"\'a\"
|
||||
pub type ForAll = for<'a> fn(&'a i32) -> &'a i32;
|
33
src/test/rustdoc-json/type/generic_default.rs
Normal file
33
src/test/rustdoc-json/type/generic_default.rs
Normal file
@ -0,0 +1,33 @@
|
||||
// ignore-tidy-linelength
|
||||
|
||||
// @set result = generic_default.json "$.index[*][?(@.name=='Result')].id"
|
||||
pub enum Result<T, E> {
|
||||
Ok(T),
|
||||
Err(E),
|
||||
}
|
||||
|
||||
// @set my_error = - "$.index[*][?(@.name=='MyError')].id"
|
||||
pub struct MyError {}
|
||||
|
||||
// @is - "$.index[*][?(@.name=='MyResult')].kind" \"typedef\"
|
||||
// @count - "$.index[*][?(@.name=='MyResult')].inner.generics.where_predicates[*]" 0
|
||||
// @count - "$.index[*][?(@.name=='MyResult')].inner.generics.params[*]" 2
|
||||
// @is - "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].name" \"T\"
|
||||
// @is - "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].name" \"E\"
|
||||
// @has - "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].kind.type"
|
||||
// @has - "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type"
|
||||
// @count - "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].kind.type.bounds[*]" 0
|
||||
// @count - "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.bounds[*]" 0
|
||||
// @is - "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].kind.type.default" null
|
||||
// @is - "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.default.kind" \"resolved_path\"
|
||||
// @is - "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.default.inner.id" $my_error
|
||||
// @is - "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.default.inner.name" \"MyError\"
|
||||
// @is - "$.index[*][?(@.name=='MyResult')].inner.type.kind" \"resolved_path\"
|
||||
// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.id" $result
|
||||
// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.name" \"Result\"
|
||||
// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.bindings" []
|
||||
// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[0].type.kind" \"generic\"
|
||||
// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[1].type.kind" \"generic\"
|
||||
// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[0].type.inner" \"T\"
|
||||
// @is - "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[1].type.inner" \"E\"
|
||||
pub type MyResult<T, E = MyError> = Result<T, E>;
|
Loading…
x
Reference in New Issue
Block a user