mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Gen tests for derived tuple encoding
This commit is contained in:
parent
0b4a45c70d
commit
c7bd430026
1 changed files with 46 additions and 0 deletions
|
@ -787,6 +787,52 @@ fn encode_derived_record_with_many_types() {
|
|||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn encode_derived_tuple_two_fields() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test"
|
||||
imports [Encode, Json]
|
||||
provides [main] to "./platform"
|
||||
|
||||
main =
|
||||
tup = ("foo", 10u8)
|
||||
result = Str.fromUtf8 (Encode.toBytes tup Json.toUtf8)
|
||||
when result is
|
||||
Ok s -> s
|
||||
_ -> "<bad>"
|
||||
"#
|
||||
),
|
||||
RocStr::from(r#"["foo",10]"#),
|
||||
RocStr
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn encode_derived_tuple_of_tuples() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test"
|
||||
imports [Encode, Json]
|
||||
provides [main] to "./platform"
|
||||
|
||||
main =
|
||||
tup = ( ("foo", 10u8), (23u8, "bar", 15u8) )
|
||||
result = Str.fromUtf8 (Encode.toBytes tup Json.toUtf8)
|
||||
when result is
|
||||
Ok s -> s
|
||||
_ -> "<bad>"
|
||||
"#
|
||||
),
|
||||
RocStr::from(r#"[["foo",10],[23,"bar",15]]"#),
|
||||
RocStr
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(any(feature = "gen-llvm", feature = "gen-wasm")))]
|
||||
fn encode_derived_generic_record_with_different_field_types() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue