Skip to content

Commit

Permalink
Start adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chip-so committed Feb 13, 2025
1 parent 024fe5f commit cccfb56
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions crates/aranya-policy-compiler/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,15 @@ fn test_type_errors() -> anyhow::Result<()> {
"#,
e: "Struct `Foo` has no member `y`",
},
Case {
t: r#"
struct Foo {a int}
function g(x struct Foo) bool {
return Foo{a: false}
}
"#,
e: "`Struct Foo` field `a` is not int",
},
Case {
t: r#"
function g(x string) bool {
Expand Down Expand Up @@ -1607,6 +1616,29 @@ fn test_type_errors() -> anyhow::Result<()> {
"#,
e: "Emit must be given a struct",
},
Case {
t: r#"
command Foo {
seal {
return serialize(3)
}
}
"#,
e: "Serializing non-struct",
},
Case {
t: r#"
command Foo {
seal {
return None
}
open {
return deserialize(3)
}
}
"#,
e: "Deserializing non-bytes",
},
];

for (i, c) in cases.iter().enumerate() {
Expand Down

0 comments on commit cccfb56

Please sign in to comment.