Skip to content

Commit

Permalink
Add more tests (doesn't work because of score function)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniosarosi committed Dec 18, 2024
1 parent c5267b5 commit cac1a16
Showing 1 changed file with 55 additions and 3 deletions.
58 changes: 55 additions & 3 deletions engine/baml-lib/jsonish/src/tests/test_aliases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type C = A[]
);

test_deserializer!(
test_recursive_alias_union,
test_json_without_nested_objects,
r#"
type JsonValue = int | string | bool | JsonValue[] | map<string, JsonValue>
"#,
Expand All @@ -58,9 +58,61 @@ type JsonValue = int | string | bool | JsonValue[] | map<string, JsonValue>
);

test_deserializer!(
test_complex_recursive_alias,
test_json_with_nested_list,
r#"
type JsonValue = int | bool | string | JsonValue[] | map<string, JsonValue>
type JsonValue = int | string | bool | JsonValue[] | map<string, JsonValue>
"#,
r#"
{
"number": 1,
"string": "test",
"bool": true,
"list": [1, 2, 3]
}
"#,
FieldType::RecursiveTypeAlias("JsonValue".into()),
{
"number": 1,
"string": "test",
"bool": true,
"list": [1, 2, 3]
}
);

test_deserializer!(
test_json_with_nested_object,
r#"
type JsonValue = int | bool | JsonValue[] | map<string, JsonValue> | string
"#,
r#"
{
"number": 1,
"string": "test",
"bool": true,
"json": {
"number": 1,
"string": "test",
"bool": true
}
}
"#,
FieldType::RecursiveTypeAlias("JsonValue".into()),
{
"number": 1,
"string": "test",
"bool": true,
"json": {
"number": 1,
"string": "test",
"bool": true
}
}
);

test_deserializer!(
test_full_json_with_nested_objects,
r#"
type JsonValue = int | bool | JsonValue[] | map<string, JsonValue> | string
"#,
r#"
{
Expand Down

0 comments on commit cac1a16

Please sign in to comment.