Skip to content

Commit

Permalink
build: update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeStanger committed Jun 16, 2024
1 parent 6b42e9b commit 73fb947
Show file tree
Hide file tree
Showing 27 changed files with 417 additions and 273 deletions.
546 changes: 315 additions & 231 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/inputs/compact.corn
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

eight=["foo""bar"]
nine=[truefalse]
ten=[nullnull]
ten=[1 2]
eleven=[[][]]
twelve=[{}{}]
}
3 changes: 3 additions & 0 deletions assets/inputs/null_in_array.corn
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
foo = [ null ]
}
2 changes: 1 addition & 1 deletion assets/inputs/very_compact.corn
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{one={foo="bar" bar="foo"} two={foo=1 bar=2} three={foo=1.0 bar=2.0} four={foo=true bar=false} five={foo=null bar=null} six={foo={} bar={}} seven={foo=[] bar=[]} eight=["foo""bar"] nine=[truefalse] ten=[nullnull] eleven=[[][]] twelve=[{}{}]}
{one={foo="bar" bar="foo"} two={foo=1 bar=2} three={foo=1.0 bar=2.0} four={foo=true bar=false} five={foo=null bar=null} six={foo={} bar={}} seven={foo=[] bar=[]} eight=["foo""bar"] nine=[truefalse] ten=[1 2] eleven=[[][]] twelve=[{}{}]}
4 changes: 2 additions & 2 deletions assets/outputs/json/compact.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
false
],
"ten": [
null,
null
1,
2
],
"eleven": [
[],
Expand Down
5 changes: 5 additions & 0 deletions assets/outputs/json/null_in_array.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"foo": [
null
]
}
3 changes: 2 additions & 1 deletion assets/outputs/json/quoted_keys.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
}
},
"with spaces": true,
"escaped'quote": false
"escaped'quote": false,
"escaped=equals": -3
}
4 changes: 2 additions & 2 deletions assets/outputs/json/very_compact.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
false
],
"ten": [
null,
null
1,
2
],
"eleven": [
[],
Expand Down
4 changes: 4 additions & 0 deletions assets/outputs/toml/compact.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ nine = [
true,
false,
]
ten = [
1,
2,
]
eleven = [
[],
[],
Expand Down
2 changes: 1 addition & 1 deletion assets/outputs/toml/complex_keys.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
with_underscore = 0
with-dash = 1
"with_🌽" = 2
"!\"£$%^&*()_" = 3
'!"£$%^&*()_' = 3
j12345 = 4

[foo]
Expand Down
Empty file.
1 change: 1 addition & 0 deletions assets/outputs/toml/quoted_keys.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"foo.bar" = 42
"with spaces" = true
"escaped'quote" = false
"escaped=equals" = -3

["green.eggs".and]
ham = "hello world"
Expand Down
4 changes: 4 additions & 0 deletions assets/outputs/toml/very_compact.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ nine = [
true,
false,
]
ten = [
1,
2,
]
eleven = [
[],
[],
Expand Down
4 changes: 2 additions & 2 deletions assets/outputs/yaml/compact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ nine:
- true
- false
ten:
- null
- null
- 1
- 2
eleven:
- []
- []
Expand Down
2 changes: 1 addition & 1 deletion assets/outputs/yaml/complex_keys.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
with_underscore: 0
with-dash: 1
"with_\U0001F33D": 2
with_🌽: 2
'!"£$%^&*()_': 3
j12345: 4
foo:
Expand Down
3 changes: 3 additions & 0 deletions assets/outputs/yaml/null_in_array.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
foo:
- null

1 change: 1 addition & 0 deletions assets/outputs/yaml/quoted_keys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ green.eggs:
ham: hello world
with spaces: true
escaped'quote: false
escaped=equals: -3

4 changes: 2 additions & 2 deletions assets/outputs/yaml/very_compact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ nine:
- true
- false
ten:
- null
- null
- 1
- 2
eleven:
- []
- []
Expand Down
12 changes: 6 additions & 6 deletions corn-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ keywords = ["configuration", "language", "pest", "peg", "cli"]

[dependencies]
libcorn = { version = "0.9.2", path = "../libcorn" }
clap = { version = "4.0.15", features = ["derive"] }
colored = "2.0.0"
clap = { version = "4.5.7", features = ["derive"] }
colored = "2.1.0"
serde = { version = "1.0.133", features = ["derive"] }
serde_json = "1.0.75"
serde_yaml = "0.9.11"
toml = "0.7.4"
pest = "2.3.0"
serde_json = "1.0.117"
serde_yaml = "0.9.34"
toml_edit = { version = "0.22.14", features = ["serde"] }
pest = "2.7.10"
2 changes: 1 addition & 1 deletion corn-cli/src/bin/corn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn serialize(config: &Value, output_type: OutputType) -> Result<String, Error> {
match output_type {
OutputType::Json => serde_json::to_string_pretty(&config).map_err(Error::from),
OutputType::Yaml => serde_yaml::to_string(&config).map_err(Error::from),
OutputType::Toml => toml::to_string_pretty(&config).map_err(Error::from),
OutputType::Toml => toml_edit::ser::to_string_pretty(&config).map_err(Error::from),
}
}

Expand Down
4 changes: 2 additions & 2 deletions corn-cli/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ impl From<serde_yaml::Error> for Error {
}
}

impl From<toml::ser::Error> for Error {
fn from(err: toml::ser::Error) -> Self {
impl From<toml_edit::ser::Error> for Error {
fn from(err: toml_edit::ser::Error) -> Self {
Self::Serializing(err.to_string())
}
}
Expand Down
30 changes: 15 additions & 15 deletions libcorn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ categories = ["config"]
keywords = ["configuration", "language", "wasm", "pest", "peg"]

[features]
wasm = ["wasm-bindgen", "serde-wasm-bindgen", "console_error_panic_hook", "wee_alloc"]
bench = ["criterion"]
wasm = ["wasm-bindgen", "serde-wasm-bindgen", "console_error_panic_hook", "wee_alloc"]
lua51 = ["mlua/lua51"]
lua52 = ["mlua/lua52"]
lua53 = ["mlua/lua53"]
Expand All @@ -23,29 +23,29 @@ name = "corn"
crate-type = ["cdylib", "rlib"]

[dependencies]
pest = "2.6.0"
pest_derive = "2.6.0"
pest = "2.7.10"
pest_derive = "2.7.10"
cfg-if = "1.0.0"
serde = { version = "1.0.133", features = ["derive"] }
indexmap = { version = "2.0.0", features = ["serde"] }
thiserror = "1.0.40"
wasm-bindgen = { version = "0.2.83", optional = true }
serde-wasm-bindgen = { version = "0.5.0", optional = true }
serde = { version = "1.0.203", features = ["derive"] }
indexmap = { version = "2.2.6", features = ["serde"] }
thiserror = "1.0.61"
wasm-bindgen = { version = "0.2.92", optional = true }
serde-wasm-bindgen = { version = "0.6.5", optional = true }
console_error_panic_hook = { version = "0.1.7", optional = true }
wee_alloc = { version = "0.4.5", optional = true }
mlua = { version = "0.8.9", features = ["vendored", "module", "macros", "serialize"], optional = true }
mlua = { version = "0.9.8", features = ["module", "macros", "serialize"], optional = true }

# bench
criterion = { version = "0.5.1", features = ["html_reports"], optional = true }

[dev-dependencies]
paste = "1.0.6"
wasm-bindgen-test = { version = "0.3.29" }
paste = "1.0.15"
wasm-bindgen-test = { version = "0.3.42" }
# required for testing
serde_json = "1.0.75"
serde_yaml = "0.9.11"
serde_bytes = "0.11.9"
toml = "0.7.4"
serde_json = "1.0.117"
serde_yaml = "0.9.34"
serde_bytes = "0.11.14"
toml_edit = { version = "0.22.14", features = ["serde"] }

[[bench]]
name = "serde"
Expand Down
4 changes: 4 additions & 0 deletions libcorn/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ pub enum Value<'a> {
/// true or false
Boolean(bool),
/// `null` literal.
///
/// Takes an optional unit type as the `toml` crate
/// errors when encountering unit types,
/// but can handle `None` types.
Null(Option<()>),
}

Expand Down
4 changes: 2 additions & 2 deletions libcorn/src/lua.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::Value;
use mlua::prelude::*;

impl<'lua> ToLua<'lua> for Value<'lua> {
fn to_lua(self, lua: &'lua Lua) -> LuaResult<LuaValue<'lua>> {
impl<'lua> IntoLua<'lua> for Value<'lua> {
fn into_lua(self, lua: &'lua Lua) -> LuaResult<LuaValue<'lua>> {
lua.to_value(&self)
}
}
Expand Down
2 changes: 1 addition & 1 deletion libcorn/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ impl<'a> CornParser<'a> {
}

let child_obj = obj
.remove(part)
.shift_remove(part)
.unwrap_or_else(|| Value::Object(IndexMap::new()));

match child_obj {
Expand Down
33 changes: 32 additions & 1 deletion libcorn/tests/de_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ struct Compact {
seven: CompactSeven,
eight: Vec<String>,
nine: Vec<bool>,
ten: Vec<()>,
ten: (u8, u8),
eleven: Vec<Vec<u8>>,
twelve: Vec<Empty>,
}
Expand Down Expand Up @@ -322,6 +322,11 @@ struct NullUnit {
#[derive(Deserialize, Debug, PartialEq)]
struct NullUnitInner;

#[derive(Deserialize, Debug, PartialEq)]
struct NullInArray {
foo: Vec<Option<u8>>,
}

#[derive(Deserialize, Debug, PartialEq)]
struct Object {
foo: SubObject,
Expand Down Expand Up @@ -359,6 +364,30 @@ struct ReadmeExample {
version: String,
}

#[derive(Deserialize, Debug, PartialEq)]
struct QuotedKeys {
#[serde(rename = "foo.bar")]
foo_bar: u8,
#[serde(rename = "green.eggs")]
green_eggs: GreenEggs,
#[serde(rename = "with spaces")]
with_spaces: bool,
#[serde(rename = "escaped'quote")]
escaped_quote: bool,
#[serde(rename = "escaped=equals")]
escaped_equals: i8,
}

#[derive(Deserialize, Debug, PartialEq)]
struct GreenEggs {
and: And,
}

#[derive(Deserialize, Debug, PartialEq)]
struct And {
ham: String,
}

#[derive(Deserialize, Debug, PartialEq)]
struct String_ {
foo: String,
Expand Down Expand Up @@ -432,9 +461,11 @@ generate_eq_tests!(
(integer, Integer),
(mixed_array, MixedArray),
(null, Null),
(null_in_array, NullInArray),
(object, Object),
(object_in_array, ObjectInArray),
(readme_example, ReadmeExample),
(quoted_keys, QuotedKeys),
(string, String_),
(string_interpolation, Basic),
(value_after_table, ValueAfterTable),
Expand Down
5 changes: 4 additions & 1 deletion libcorn/tests/parser_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ macro_rules! generate_eq_tests {
let valid = fs::read_to_string(format!("../assets/outputs/toml/{}.toml", test_name)).unwrap().replace("\r", "");

let config = parse(input.as_str()).unwrap();
let serialized = toml::to_string_pretty(&config).unwrap().replace("\r", "");
// fall back to default as toml can fail due to no null
let serialized = toml_edit::ser::to_string_pretty(&config).unwrap_or_default().replace("\r", "");

assert_eq!(serialized.trim(), valid.trim());
}
Expand Down Expand Up @@ -87,8 +88,10 @@ generate_eq_tests!(
integer,
mixed_array,
null,
null_in_array,
object,
object_in_array,
quoted_keys,
readme_example,
spread,
string,
Expand Down

0 comments on commit 73fb947

Please sign in to comment.