Compare commits

...

6 Commits

Author SHA1 Message Date
Jeffrey Griffin
aa9f673316 require serde/alloc but not serde/std 2019-04-03 15:26:35 -07:00
David Tolnay
72e22e5b6d
Release 1.0.39 2019-02-28 01:08:14 -08:00
David Tolnay
82c5182bfa
Merge pull request #521 from dtolnay/f
Fix adjacently tagged f32 roundtrip regression
2019-02-28 01:07:20 -08:00
David Tolnay
d79c8e5f1e
Fix adjacently tagged f32 roundtrip regression 2019-02-28 00:57:55 -08:00
David Tolnay
6ac689b2b3
Format with rustfmt 2019-02-14 2019-02-27 22:51:08 -08:00
David Tolnay
d6ff3de39c
Simplify running update-references.sh 2019-02-17 11:12:26 -08:00
10 changed files with 57 additions and 30 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "serde_json"
version = "1.0.38" # remember to update html_root_url
version = "1.0.39" # remember to update html_root_url
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
license = "MIT/Apache-2.0"
description = "A JSON serialization file format"
@ -16,12 +16,13 @@ travis-ci = { repository = "serde-rs/json" }
appveyor = { repository = "serde-rs/json" }
[dependencies]
serde = "1.0.60"
serde = { version = "1.0.60", default-features = false, features = ["alloc"] }
indexmap = { version = "1.0", optional = true }
itoa = "0.4.3"
ryu = "0.2"
[dev-dependencies]
automod = "0.1"
compiletest_rs = { version = "0.3", features = ["stable"] }
serde_bytes = "0.10"
serde_derive = "1.0"

View File

@ -3,8 +3,8 @@
use std::error;
use std::fmt::{self, Debug, Display};
use std::io;
use std::str::FromStr;
use std::result;
use std::str::FromStr;
use serde::de;
use serde::ser;

View File

@ -294,7 +294,7 @@
//! [macro]: https://docs.serde.rs/serde_json/macro.json.html
//! [`serde-json-core`]: https://japaric.github.io/serde-json-core/serde_json_core/
#![doc(html_root_url = "https://docs.rs/serde_json/1.0.38")]
#![doc(html_root_url = "https://docs.rs/serde_json/1.0.39")]
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
// Ignored clippy lints

View File

@ -473,7 +473,7 @@ macro_rules! deserialize_any {
} else if let Some(i) = self.as_i64() {
return visitor.visit_i64(i);
} else if let Some(f) = self.as_f64() {
if f.to_string() == self.n {
if ryu::Buffer::new().format(f) == self.n || f.to_string() == self.n {
return visitor.visit_f64(f);
}
}

12
tests/README.md Normal file
View File

@ -0,0 +1,12 @@
#### To run tests
```sh
(cd deps && cargo clean && cargo update && cargo build)
cargo test
```
#### To update goldens after running ui tests
```sh
ui/update-references.sh
```

View File

@ -13,6 +13,7 @@ fn ui() {
--extern serde_json \
",
)),
build_base: std::path::PathBuf::from("target/ui"),
..Default::default()
});
}

6
tests/regression.rs Normal file
View File

@ -0,0 +1,6 @@
extern crate automod;
extern crate serde;
extern crate serde_derive;
#[path = "regression/mod.rs"]
mod regression;

View File

@ -0,0 +1,18 @@
use serde_derive::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug)]
#[serde(tag = "type", content = "data")]
enum E {
Float(f32),
}
#[test]
fn test() {
let e = E::Float(159.1);
let v = serde_json::to_value(e).unwrap();
let e = serde_json::from_value::<E>(v).unwrap();
match e {
E::Float(f) => assert_eq!(f, 159.1),
}
}

1
tests/regression/mod.rs Normal file
View File

@ -0,0 +1 @@
automod::dir!("tests/regression");

View File

@ -19,32 +19,20 @@
# If you find yourself manually editing a foo.stderr file, you're
# doing it wrong.
if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "" || "$2" == "" ]]; then
echo "usage: $0 <build-directory> <relative-path-to-rs-files>"
echo ""
echo "For example:"
echo " $0 ../../../build/x86_64-apple-darwin/test/ui *.rs */*.rs"
fi
cd "$(dirname "${BASH_SOURCE[0]}")"
BUILD_DIR="../../target/ui"
MYDIR=$(dirname $0)
BUILD_DIR="$1"
shift
while [[ "$1" != "" ]]; do
STDERR_NAME="${1/%.rs/.stderr}"
STDOUT_NAME="${1/%.rs/.stdout}"
shift
if [ -f $BUILD_DIR/$STDOUT_NAME ] && \
! (diff $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME >& /dev/null); then
echo updating $MYDIR/$STDOUT_NAME
cp $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME
for testcase in *.rs; do
STDERR_NAME="${testcase/%.rs/.stderr}"
STDOUT_NAME="${testcase/%.rs/.stdout}"
if [ -f "$BUILD_DIR/$STDOUT_NAME" ] && \
! (diff "$BUILD_DIR/$STDOUT_NAME" "$STDOUT_NAME" >& /dev/null); then
echo "updating $STDOUT_NAME"
cp "$BUILD_DIR/$STDOUT_NAME" "$STDOUT_NAME"
fi
if [ -f $BUILD_DIR/$STDERR_NAME ] && \
! (diff $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME >& /dev/null); then
echo updating $MYDIR/$STDERR_NAME
cp $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME
if [ -f "$BUILD_DIR/$STDERR_NAME" ] && \
! (diff "$BUILD_DIR/$STDERR_NAME" "$STDERR_NAME" >& /dev/null); then
echo "updating $STDERR_NAME"
cp "$BUILD_DIR/$STDERR_NAME" "$STDERR_NAME"
fi
done