summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/serde.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/serde.rs b/tests/serde.rs
index 31c3bc3..8b3b3dd 100644
--- a/tests/serde.rs
+++ b/tests/serde.rs
@@ -306,6 +306,36 @@ fn test_to_value_with_options() -> Result<(), Box<dyn std::error::Error>> {
}
#[test]
+fn test_from_value_nested_tables() -> Result<(), Box<dyn std::error::Error>> {
+ let lua = Lua::new();
+
+ let value = lua
+ .load(
+ r#"
+ local table_a = {a = "a"}
+ local table_b = {"b"}
+ return {
+ a = table_a,
+ b = {table_b, table_b},
+ ab = {a = table_a, b = table_b}
+ }
+ "#,
+ )
+ .eval::<Value>()?;
+ let got = lua.from_value::<serde_json::Value>(value)?;
+ assert_eq!(
+ got,
+ serde_json::json!({
+ "a": {"a": "a"},
+ "b": [["b"], ["b"]],
+ "ab": {"a": {"a": "a"}, "b": ["b"]},
+ })
+ );
+
+ Ok(())
+}
+
+#[test]
fn test_from_value_struct() -> Result<(), Box<dyn std::error::Error>> {
let lua = Lua::new();