mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
Add gen tests for concerete unspecialized set conservation
This commit is contained in:
parent
d7a069675b
commit
7a4fed932d
1 changed files with 53 additions and 0 deletions
|
@ -787,6 +787,59 @@ fn encode_derived_record_with_many_types() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(all(any(feature = "gen-llvm", feature = "gen-wasm")))]
|
||||||
|
fn encode_derived_generic_record_with_different_field_types() {
|
||||||
|
assert_evals_to!(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
app "test"
|
||||||
|
imports [Encode, Json]
|
||||||
|
provides [main] to "./platform"
|
||||||
|
|
||||||
|
Q a b := {a: a, b: b} has [Encoding]
|
||||||
|
|
||||||
|
q = @Q {a: 10u32, b: "fieldb"}
|
||||||
|
|
||||||
|
main =
|
||||||
|
result = Str.fromUtf8 (Encode.toBytes q Json.toUtf8)
|
||||||
|
when result is
|
||||||
|
Ok s -> s
|
||||||
|
_ -> "<bad>"
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
RocStr::from(r#"{"a":10,"b":"fieldb"}"#),
|
||||||
|
RocStr
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(all(any(feature = "gen-llvm", feature = "gen-wasm")))]
|
||||||
|
fn encode_derived_generic_tag_with_different_field_types() {
|
||||||
|
assert_evals_to!(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
app "test"
|
||||||
|
imports [Encode, Json]
|
||||||
|
provides [main] to "./platform"
|
||||||
|
|
||||||
|
Q a b := [A a, B b] has [Encoding]
|
||||||
|
|
||||||
|
q : Q Str U32
|
||||||
|
q = @Q (B 67)
|
||||||
|
|
||||||
|
main =
|
||||||
|
result = Str.fromUtf8 (Encode.toBytes q Json.toUtf8)
|
||||||
|
when result is
|
||||||
|
Ok s -> s
|
||||||
|
_ -> "<bad>"
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
RocStr::from(r#"{"B":[67]}"#),
|
||||||
|
RocStr
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||||
fn decode_use_stdlib() {
|
fn decode_use_stdlib() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue