mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-04 17:14:37 +00:00
Add tests for tag union toEncoder derivers
This commit is contained in:
parent
178850462e
commit
ef350e4aed
1 changed files with 32 additions and 2 deletions
|
@ -1,4 +1,8 @@
|
||||||
#![cfg(test)]
|
#![cfg(test)]
|
||||||
|
// Even with #[allow(non_snake_case)] on individual idents, rust-analyzer issues diagnostics.
|
||||||
|
// See https://github.com/rust-lang/rust-analyzer/issues/6541.
|
||||||
|
// For the `v!` macro we use uppercase variables when constructing tag unions.
|
||||||
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
hash::{BuildHasher, Hash, Hasher},
|
hash::{BuildHasher, Hash, Hasher},
|
||||||
|
@ -328,7 +332,6 @@ macro_rules! test_hash_eq {
|
||||||
($($name:ident: $synth1:expr, $synth2:expr)*) => {$(
|
($($name:ident: $synth1:expr, $synth2:expr)*) => {$(
|
||||||
#[test]
|
#[test]
|
||||||
fn $name() {
|
fn $name() {
|
||||||
#![allow(non_snake_case)]
|
|
||||||
check_hash(true, $synth1, $synth2)
|
check_hash(true, $synth1, $synth2)
|
||||||
}
|
}
|
||||||
)*};
|
)*};
|
||||||
|
@ -338,7 +341,6 @@ macro_rules! test_hash_neq {
|
||||||
($($name:ident: $synth1:expr, $synth2:expr)*) => {$(
|
($($name:ident: $synth1:expr, $synth2:expr)*) => {$(
|
||||||
#[test]
|
#[test]
|
||||||
fn $name() {
|
fn $name() {
|
||||||
#![allow(non_snake_case)]
|
|
||||||
check_hash(false, $synth1, $synth2)
|
check_hash(false, $synth1, $synth2)
|
||||||
}
|
}
|
||||||
)*};
|
)*};
|
||||||
|
@ -479,4 +481,32 @@ fn two_field_record() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[ignore = "NOTE: this would never actually happen, because [] is uninhabited, and hence toEncoder can never be called with a value of []!
|
||||||
|
Rightfully it induces broken assertions in other parts of the compiler, so we ignore it."]
|
||||||
|
fn empty_tag_union() {
|
||||||
|
derive_test(
|
||||||
|
v!(EMPTY_TAG_UNION),
|
||||||
|
"[] -> Encoder fmt | fmt has EncoderFormatting",
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
\Test.0 -> when Test.0 is
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn tag_one_label_zero_args() {
|
||||||
|
derive_test(
|
||||||
|
v!([A]),
|
||||||
|
"[ A ] -> Encoder fmt | fmt has EncoderFormatting",
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
\Test.0 -> when Test.0 is (A) -> (Encode.toEncoder "A" [ ])
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// }}} deriver tests
|
// }}} deriver tests
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue