diff options
Diffstat (limited to 'src/test/rustdoc-json/enums/discriminant')
5 files changed, 119 insertions, 0 deletions
diff --git a/src/test/rustdoc-json/enums/discriminant/basic.rs b/src/test/rustdoc-json/enums/discriminant/basic.rs new file mode 100644 index 000000000..8c221615a --- /dev/null +++ b/src/test/rustdoc-json/enums/discriminant/basic.rs @@ -0,0 +1,12 @@ +#[repr(i8)] +pub enum Ordering { + // @is "$.index[*][?(@.name=='Less')].inner.variant_inner.expr" '"-1"' + // @is "$.index[*][?(@.name=='Less')].inner.variant_inner.value" '"-1"' + Less = -1, + // @is "$.index[*][?(@.name=='Equal')].inner.variant_inner.expr" '"0"' + // @is "$.index[*][?(@.name=='Equal')].inner.variant_inner.value" '"0"' + Equal = 0, + // @is "$.index[*][?(@.name=='Greater')].inner.variant_inner.expr" '"1"' + // @is "$.index[*][?(@.name=='Greater')].inner.variant_inner.value" '"1"' + Greater = 1, +} diff --git a/src/test/rustdoc-json/enums/discriminant/expr.rs b/src/test/rustdoc-json/enums/discriminant/expr.rs new file mode 100644 index 000000000..235b0b473 --- /dev/null +++ b/src/test/rustdoc-json/enums/discriminant/expr.rs @@ -0,0 +1,39 @@ +pub enum Foo { + // @is "$.index[*][?(@.name=='Addition')].inner.variant_inner.value" '"0"' + // @is "$.index[*][?(@.name=='Addition')].inner.variant_inner.expr" '"{ _ }"' + Addition = 0 + 0, + // @is "$.index[*][?(@.name=='Bin')].inner.variant_inner.value" '"1"' + // @is "$.index[*][?(@.name=='Bin')].inner.variant_inner.expr" '"0b1"' + Bin = 0b1, + // @is "$.index[*][?(@.name=='Oct')].inner.variant_inner.value" '"2"' + // @is "$.index[*][?(@.name=='Oct')].inner.variant_inner.expr" '"0o2"' + Oct = 0o2, + // @is "$.index[*][?(@.name=='PubConst')].inner.variant_inner.value" '"3"' + // @is "$.index[*][?(@.name=='PubConst')].inner.variant_inner.expr" '"THREE"' + PubConst = THREE, + // @is "$.index[*][?(@.name=='Hex')].inner.variant_inner.value" '"4"' + // @is "$.index[*][?(@.name=='Hex')].inner.variant_inner.expr" '"0x4"' + Hex = 0x4, + // @is "$.index[*][?(@.name=='Cast')].inner.variant_inner.value" '"5"' + // @is "$.index[*][?(@.name=='Cast')].inner.variant_inner.expr" '"{ _ }"' + Cast = 5 as isize, + // @is "$.index[*][?(@.name=='PubCall')].inner.variant_inner.value" '"6"' + // @is "$.index[*][?(@.name=='PubCall')].inner.variant_inner.expr" '"{ _ }"' + PubCall = six(), + // @is "$.index[*][?(@.name=='PrivCall')].inner.variant_inner.value" '"7"' + // @is "$.index[*][?(@.name=='PrivCall')].inner.variant_inner.expr" '"{ _ }"' + PrivCall = seven(), + // @is "$.index[*][?(@.name=='PrivConst')].inner.variant_inner.value" '"8"' + // @is "$.index[*][?(@.name=='PrivConst')].inner.variant_inner.expr" '"EIGHT"' + PrivConst = EIGHT, +} + +pub const THREE: isize = 3; +const EIGHT: isize = 8; + +pub const fn six() -> isize { + 6 +} +const fn seven() -> isize { + 7 +} diff --git a/src/test/rustdoc-json/enums/discriminant/limits.rs b/src/test/rustdoc-json/enums/discriminant/limits.rs new file mode 100644 index 000000000..8df73d78d --- /dev/null +++ b/src/test/rustdoc-json/enums/discriminant/limits.rs @@ -0,0 +1,43 @@ +// ignore-tidy-linelength +#![feature(repr128)] +#![allow(incomplete_features)] + +#[repr(u64)] +pub enum U64 { + // @is "$.index[*][?(@.name=='U64Min')].inner.variant_inner.value" '"0"' + // @is "$.index[*][?(@.name=='U64Min')].inner.variant_inner.expr" '"u64::MIN"' + U64Min = u64::MIN, + // @is "$.index[*][?(@.name=='U64Max')].inner.variant_inner.value" '"18446744073709551615"' + // @is "$.index[*][?(@.name=='U64Max')].inner.variant_inner.expr" '"u64::MAX"' + U64Max = u64::MAX, +} + +#[repr(i64)] +pub enum I64 { + // @is "$.index[*][?(@.name=='I64Min')].inner.variant_inner.value" '"-9223372036854775808"' + // @is "$.index[*][?(@.name=='I64Min')].inner.variant_inner.expr" '"i64::MIN"' + I64Min = i64::MIN, + // @is "$.index[*][?(@.name=='I64Max')].inner.variant_inner.value" '"9223372036854775807"' + // @is "$.index[*][?(@.name=='I64Max')].inner.variant_inner.expr" '"i64::MAX"' + I64Max = i64::MAX, +} + +#[repr(u128)] +pub enum U128 { + // @is "$.index[*][?(@.name=='U128Min')].inner.variant_inner.value" '"0"' + // @is "$.index[*][?(@.name=='U128Min')].inner.variant_inner.expr" '"u128::MIN"' + U128Min = u128::MIN, + // @is "$.index[*][?(@.name=='U128Max')].inner.variant_inner.value" '"340282366920938463463374607431768211455"' + // @is "$.index[*][?(@.name=='U128Max')].inner.variant_inner.expr" '"u128::MAX"' + U128Max = u128::MAX, +} + +#[repr(i128)] +pub enum I128 { + // @is "$.index[*][?(@.name=='I128Min')].inner.variant_inner.value" '"-170141183460469231731687303715884105728"' + // @is "$.index[*][?(@.name=='I128Min')].inner.variant_inner.expr" '"i128::MIN"' + I128Min = i128::MIN, + // @is "$.index[*][?(@.name=='I128Max')].inner.variant_inner.value" '"170141183460469231731687303715884105727"' + // @is "$.index[*][?(@.name=='I128Max')].inner.variant_inner.expr" '"i128::MAX"' + I128Max = i128::MAX, +} diff --git a/src/test/rustdoc-json/enums/discriminant/num_underscore_and_suffix.rs b/src/test/rustdoc-json/enums/discriminant/num_underscore_and_suffix.rs new file mode 100644 index 000000000..3417baa07 --- /dev/null +++ b/src/test/rustdoc-json/enums/discriminant/num_underscore_and_suffix.rs @@ -0,0 +1,15 @@ +#[repr(u32)] +pub enum Foo { + // @is "$.index[*][?(@.name=='Basic')].inner.variant_inner.value" '"0"' + // @is "$.index[*][?(@.name=='Basic')].inner.variant_inner.expr" '"0"' + Basic = 0, + // @is "$.index[*][?(@.name=='Suffix')].inner.variant_inner.value" '"10"' + // @is "$.index[*][?(@.name=='Suffix')].inner.variant_inner.expr" '"10u32"' + Suffix = 10u32, + // @is "$.index[*][?(@.name=='Underscore')].inner.variant_inner.value" '"100"' + // @is "$.index[*][?(@.name=='Underscore')].inner.variant_inner.expr" '"1_0_0"' + Underscore = 1_0_0, + // @is "$.index[*][?(@.name=='SuffixUnderscore')].inner.variant_inner.value" '"1000"' + // @is "$.index[*][?(@.name=='SuffixUnderscore')].inner.variant_inner.expr" '"1_0_0_0u32"' + SuffixUnderscore = 1_0_0_0u32, +} diff --git a/src/test/rustdoc-json/enums/discriminant/only_some_have_discriminant.rs b/src/test/rustdoc-json/enums/discriminant/only_some_have_discriminant.rs new file mode 100644 index 000000000..6af944a22 --- /dev/null +++ b/src/test/rustdoc-json/enums/discriminant/only_some_have_discriminant.rs @@ -0,0 +1,10 @@ +pub enum Foo { + // @is "$.index[*][?(@.name=='Has')].inner.variant_inner" '{"expr":"0", "value":"0"}' + Has = 0, + // @is "$.index[*][?(@.name=='Doesnt')].inner.variant_inner" null + Doesnt, + // @is "$.index[*][?(@.name=='AlsoDoesnt')].inner.variant_inner" null + AlsoDoesnt, + // @is "$.index[*][?(@.name=='AlsoHas')].inner.variant_inner" '{"expr":"44", "value":"44"}' + AlsoHas = 44, +} |