175 Commits

Author SHA1 Message Date
David Tolnay
25129334eb
Add authors to Cargo.toml 2022-07-31 19:25:47 -07:00
David Tolnay
01ef46e363
Ignore assertions_on_result_states clippy lint
error: called `assert!` with `Result::is_err`
      --> tests/regression/issue795.rs:53:5
       |
    53 |     assert!(serde_json::from_str::<Enum>(s).is_err());
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `serde_json::from_str::<Enum>(s).unwrap_err()`
       |
       = note: `-D clippy::assertions-on-result-states` implied by `-D clippy::all`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_err`
      --> tests/regression/issue795.rs:56:5
       |
    56 |     assert!(serde_json::from_value::<Enum>(j).is_err());
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `serde_json::from_value::<Enum>(j).unwrap_err()`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_err`
       --> tests/stream.rs:179:9
        |
    179 |         assert!(stream.next().unwrap().is_err());
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `stream.next().unwrap().unwrap_err()`
        |
        = note: `-D clippy::assertions-on-result-states` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_err`
       --> tests/test.rs:940:5
        |
    940 |     assert!(v.is_err());
        |     ^^^^^^^^^^^^^^^^^^^ help: replace with: `v.unwrap_err()`
        |
        = note: `-D clippy::assertions-on-result-states` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_err`
        --> tests/test.rs:1735:5
         |
    1735 |     assert!(res.is_err());
         |     ^^^^^^^^^^^^^^^^^^^^^ help: replace with: `res.unwrap_err()`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_err`
        --> tests/test.rs:1738:5
         |
    1738 |     assert!(res.is_err());
         |     ^^^^^^^^^^^^^^^^^^^^^ help: replace with: `res.unwrap_err()`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_err`
        --> tests/test.rs:1741:5
         |
    1741 |     assert!(res.is_err());
         |     ^^^^^^^^^^^^^^^^^^^^^ help: replace with: `res.unwrap_err()`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_err`
        --> tests/test.rs:1930:5
         |
    1930 |     assert!(serde_json::to_value(&map).is_err());
         |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `serde_json::to_value(&map).unwrap_err()`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_err`
        --> tests/test.rs:2005:5
         |
    2005 |     assert!(from_str::<E>(r#" "V"0 "#).is_err());
         |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `from_str::<E>(r#" "V"0 "#).unwrap_err()`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states
2022-07-29 22:11:16 -07:00
David Tolnay
d1cbbb634a
Update ui test suite to nightly-2022-07-20 2022-07-19 21:20:38 -07:00
David Tolnay
f901012df6
Ignore derive_partial_eq_without_eq clippy lint
error: you are deriving `PartialEq` and can implement `Eq`
      --> tests/test.rs:65:24
       |
    65 | #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
       |                        ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
       |
       = note: `-D clippy::derive-partial-eq-without-eq` implied by `-D clippy::all`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq

    error: you are deriving `PartialEq` and can implement `Eq`
      --> tests/test.rs:74:24
       |
    74 | #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
       |                        ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq

    error: you are deriving `PartialEq` and can implement `Eq`
       --> tests/test.rs:565:25
        |
    565 |     #[derive(Serialize, PartialEq, Debug)]
        |                         ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq

    error: you are deriving `PartialEq` and can implement `Eq`
        --> tests/test.rs:1278:28
         |
    1278 |     #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
         |                            ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq

    error: you are deriving `PartialEq` and can implement `Eq`
        --> tests/test.rs:1395:21
         |
    1395 |     #[derive(Debug, PartialEq, Deserialize)]
         |                     ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq

    error: you are deriving `PartialEq` and can implement `Eq`
        --> tests/test.rs:1415:21
         |
    1415 |     #[derive(Debug, PartialEq, Deserialize)]
         |                     ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq

    error: you are deriving `PartialEq` and can implement `Eq`
        --> tests/test.rs:1425:21
         |
    1425 |     #[derive(Debug, PartialEq, Deserialize)]
         |                     ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq

    error: you are deriving `PartialEq` and can implement `Eq`
        --> tests/test.rs:1627:21
         |
    1627 |     #[derive(Debug, PartialEq, Serialize, Deserialize)]
         |                     ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
2022-05-21 20:46:06 -07:00
David Tolnay
efa4c9f9bb
Ignore unused_macro_rules warning in test macros
warning: 1st rule of macro `json_str` is never used
     --> tests/macros/mod.rs:2:5
      |
    2 |     ([]) => {
      |     ^^^^
      |
      = note: `#[warn(unused_macro_rules)]` on by default

    warning: 3rd rule of macro `json_str` is never used
      --> tests/macros/mod.rs:11:5
       |
    11 |     ({}) => {
       |     ^^^^
2022-05-12 21:34:53 -07:00
David Tolnay
c0f93432cc
Ignore trait_duplication_in_bounds clippy false positives
https://github.com/rust-lang/rust-clippy/issues/8757

    error: this trait bound is already specified in the where clause
      --> tests/regression/issue845.rs:13:8
       |
    13 |     T: TryFrom<u64> + TryFrom<i64> + FromStr,
       |        ^^^^^^^^^^^^
       |
       = note: `-D clippy::trait-duplication-in-bounds` implied by `-D clippy::pedantic`
       = help: consider removing this trait bound
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trait_duplication_in_bounds

    error: this trait bound is already specified in the where clause
      --> tests/regression/issue845.rs:14:33
       |
    14 |     <T as TryFrom<u64>>::Error: Display,
       |                                 ^^^^^^^
       |
       = help: consider removing this trait bound
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trait_duplication_in_bounds

    error: this trait bound is already specified in the where clause
      --> tests/regression/issue845.rs:49:8
       |
    49 |     T: TryFrom<u64> + TryFrom<i64> + FromStr,
       |        ^^^^^^^^^^^^
       |
       = help: consider removing this trait bound
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trait_duplication_in_bounds

    error: this trait bound is already specified in the where clause
      --> tests/regression/issue845.rs:50:33
       |
    50 |     <T as TryFrom<u64>>::Error: Display,
       |                                 ^^^^^^^
       |
       = help: consider removing this trait bound
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trait_duplication_in_bounds
2022-04-30 20:19:52 -07:00
David Tolnay
7e56a406e5
Merge pull request #830 from lucacasonato/support_lone_surrogates_in_raw_value
Allow lone surrogates in raw values
2022-02-11 20:43:06 -08:00
David Tolnay
2d81cbd113
Move raw_value test imports to block of imports 2022-01-22 15:30:46 -08:00
David Tolnay
6a3fb68979
Add test of deserializing a &RawValue in map key position
Currently fails with:

    ---- test_raw_value_in_map_key stdout ----
    thread 'test_borrowed_raw_value' panicked at 'called `Result::unwrap()`
    on an `Err` value: Error("invalid type: newtype struct, expected any
    valid JSON value", line: 1, column: 2)', tests/test.rs:2230:52
2022-01-22 15:19:28 -08:00
David Tolnay
d541381455
Deserialize small numbers as integers in arbitrary_precision 2022-01-15 16:44:37 -08:00
David Tolnay
0ca5a69d73
Add regression test for issue 845 2022-01-15 16:40:22 -08:00
David Tolnay
6de3d398ef
Merge pull request 841 from EFanZh/unsized-value-to-raw-value 2022-01-01 11:41:44 -08:00
EFanZh
012f567a38 Allow creating RawValues from references to unsized values 2022-01-01 19:03:16 +08:00
David Tolnay
5d2cbcdd4b
Eliminate lib module 2021-12-30 20:52:08 -08:00
David Tolnay
aaaf125f0b
Disable TcpStream test on miri
error: unsupported operation: can't call foreign function: getaddrinfo
        --> nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/net.rs:191:21
         |
    191  |             cvt_gai(c::getaddrinfo(c_host.as_ptr(), ptr::null(), &hints, &mut res))
         |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function: getaddrinfo
         |
         = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
2021-12-11 15:01:07 -08:00
David Tolnay
c3eddcdf40
Collect imports to top of test suite 2021-12-11 14:53:18 -08:00
David Tolnay
a28529ddc9
Skip ui test when running in miri 2021-12-11 14:50:52 -08:00
David Tolnay
7db1ea907d
Ignore needless_late_init Clippy lint
error: unneeded late initalization
       --> tests/../src/lexical/float.rs:173:9
        |
    173 |         let exp: u64;
        |         ^^^^^^^^^^^^^
        |
        = note: `-D clippy::needless-late-init` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init
    help: declare `exp` here
        |
    174 |         let exp: u64 = if (fp.exp == F::DENORMAL_EXPONENT) && (fp.mant & F::HIDDEN_BIT_MASK.as_u64()) == 0 {
        |         ++++++++++++++
    help: remove the assignments from the branches
        |
    175 ~             0
    176 |         } else {
    177 ~             (fp.exp + F::EXPONENT_BIAS) as u64
        |
    help: add a semicolon after the `if` expression
        |
    178 |         };
        |          +
2021-12-07 18:41:06 -08:00
Luca Casonato
51e9616dee
Allow lone surrogates in raw values 2021-11-26 02:08:46 +01:00
Luca Casonato
07c740c2ff
fix parsing escape sequences after lone surrogates 2021-11-24 23:48:42 +01:00
Luca Casonato
849c6845b4
Deserialize lone surrogates into byte bufs
This commit deserializes lone surrogates in strings that are encoded in
escape sequences instead of erroring on them.
2021-11-24 14:50:33 +01:00
David Tolnay
37da27fc77
Merge pull request 822 from deankarn/master 2021-11-12 19:05:05 -08:00
Dean Karn
0992b44721 only include retain for BTreeMap if Rust 1.53.0+ 2021-11-11 21:19:51 -08:00
Dean Karn
d275e04a77 Add retain to Map
This adds the `retain` function to the Map type which calls the inner
maps, Either indexmap or std BTreeMap's, retain.

I'm trying to mutate a Value::Object's Map in-place and could't find a
nice way without the retain function.
2021-11-11 20:24:37 -08:00
David Tolnay
0035947522
Touch up PR 814 2021-11-05 12:25:12 -07:00
Timothée Haudebourg
f53ae31df6 Use the same hash for +0 and -0. 2021-11-05 12:57:41 +01:00
David Tolnay
2e1c46c895
Update ui test suite to nightly-2021-10-17 2021-10-16 19:20:52 -07:00
David Tolnay
019b179cf7
Ui test changes for trybuild 1.0.49 2021-10-08 03:00:04 -04:00
David Tolnay
733b353394
Update ui test files 2021-10-07 00:19:07 -04:00
David Tolnay
9298f54ace
Resolve manual_str_repeat clippy lint 2021-10-01 01:11:06 -04:00
David Tolnay
019041e4d5
Resolve semicolon_if_nothing_returned pedantic clippy lint
error: consider adding a `;` to the last statement for consistent formatting
       --> tests/../src/lexical/float.rs:111:9
        |
    111 |         round_to_native::<F, _>(self, algorithm)
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `round_to_native::<F, _>(self, algorithm);`
        |
        = note: `-D clippy::semicolon-if-nothing-returned` implied by `-D clippy::pedantic`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned

    error: consider adding a `;` to the last statement for consistent formatting
       --> tests/../src/lexical/math.rs:616:9
        |
    616 |         iadd_impl(x, y, 0)
        |         ^^^^^^^^^^^^^^^^^^ help: add a `;` here: `iadd_impl(x, y, 0);`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned

    error: consider adding a `;` to the last statement for consistent formatting
       --> tests/../src/lexical/math.rs:862:9
        |
    862 |         self.ishl(n as usize)
        |         ^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `self.ishl(n as usize);`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned

    error: consider adding a `;` to the last statement for consistent formatting
       --> tests/../src/lexical/math.rs:868:9
        |
    868 |         small::imul_pow5(self.data_mut(), n)
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `small::imul_pow5(self.data_mut(), n);`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned

    error: consider adding a `;` to the last statement for consistent formatting
       --> tests/lexical/float.rs:184:5
        |
    184 |     check_round_to_f64(10234494226754558294, -1086, 2498655817078750, -1074)
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `check_round_to_f64(10234494226754558294, -1086, 2498655817078750, -1074);`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
2021-10-01 01:09:12 -04:00
David Tolnay
0b5931550a
Resolve needless_borrow clippy lint
error: this expression borrows a reference (`&lexical::float::ExtendedFloat`) that is immediately dereferenced by the compiler
       --> tests/../src/lexical/algorithm.rs:136:45
        |
    136 |         u64::error_is_accurate::<F>(errors, &fp)
        |                                             ^^^ help: change this to: `fp`
        |
        = note: `-D clippy::needless-borrow` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
2021-10-01 01:07:42 -04:00
David Tolnay
fc4db0306a
Run clippy on test suite too 2021-10-01 00:46:45 -04:00
David Tolnay
f5219be867
Add test parsing -0 2021-09-14 12:52:55 -07:00
David Tolnay
b419f2e065
Test negative zero parsing to f32 2021-09-14 12:51:27 -07:00
David Tolnay
ef823af7d5
Suppress unused field in test_borrow_in_map_key
warning: field is never read: `map`
        --> tests/test.rs:2233:9
         |
    2233 |         map: BTreeMap<MyMapKey, ()>,
         |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = note: `#[warn(dead_code)]` on by default
2021-09-14 12:50:03 -07:00
David Tolnay
f4fc150c45
Fix dead code warning in issue 795 regression test
warning: field is never read: `x`
     --> tests/regression/issue795.rs:9:15
      |
    9 |     Variant { x: u8 },
      |               ^^^^^
      |
      = note: `#[warn(dead_code)]` on by default
2021-09-14 12:49:18 -07:00
David Tolnay
12207ed2a3
Add regression test for issue 795 2021-08-28 11:21:40 -07:00
Ruifeng Xie
21523246e5
Make arbitrary_precision preserve the exact string representation 2021-07-17 11:27:27 +08:00
David Tolnay
892e2a8264
Update ui test suite to nightly-2021-05-14 2021-05-13 19:15:50 -07:00
David Tolnay
2f812d0363
Add test of RawValue deserialization from invalid utf-8 2021-02-27 20:46:09 -08:00
David Tolnay
9bcb08fd92
Fix unnecessary trailing semicolon lints in test suite
warning: unnecessary trailing semicolon
        --> tests/test.rs:2133:6
         |
    2133 |     };
         |      ^ help: remove this semicolon
         |
         = note: `#[warn(redundant_semicolons)]` on by default

    warning: unnecessary trailing semicolon
        --> tests/test.rs:2166:6
         |
    2166 |     };
         |      ^ help: remove this semicolon
2021-02-27 20:44:53 -08:00
David Tolnay
b1ca6c7186
Add test of as_f64 on large number
Closes https://github.com/serde-rs/json/issues/710.
2020-10-12 13:35:04 -07:00
David Tolnay
509d52e70a
Simplify how regression tests are imported 2020-09-05 12:33:03 -07:00
David Tolnay
9357569b1c
Trigger missing comma rustc suggestion 2020-06-28 22:46:33 -07:00
David Tolnay
0443daa488
Prevent type ascription misdiagnosis 2020-06-28 22:38:59 -07:00
David Tolnay
4a948df6f6
Add ui test of missing comma between object entries 2020-06-28 22:24:56 -07:00
David Tolnay
43598d82f4
Gate some tests behind float_roundtrip feature 2020-06-08 21:36:27 -07:00
David Tolnay
5cb2721d5f
Add float test case demonstrating exponent overflow
thread 'test_parse_f64' panicked at 'attempt to subtract with overflow', src/de.rs:664:27
2020-06-07 23:46:40 -07:00
David Tolnay
67f3dc37dc
Format with rustfmt 2020-05-19 2020-06-07 19:53:49 -07:00