mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
Add decoding record derive key tests
This commit is contained in:
parent
07cac2b4ce
commit
68441479b8
4 changed files with 35 additions and 8 deletions
|
@ -5,6 +5,7 @@
|
|||
#![allow(non_snake_case)]
|
||||
|
||||
use crate::{
|
||||
test_key_eq, test_key_neq,
|
||||
util::{check_immediate, derive_test},
|
||||
v,
|
||||
};
|
||||
|
@ -14,6 +15,34 @@ use roc_types::subs::Variable;
|
|||
|
||||
use roc_derive_key::DeriveBuiltin::Decoder;
|
||||
|
||||
test_key_eq! {
|
||||
Decoder,
|
||||
|
||||
same_record:
|
||||
v!({ a: v!(U8), }), v!({ a: v!(U8), })
|
||||
same_record_fields_diff_types:
|
||||
v!({ a: v!(U8), }), v!({ a: v!(STR), })
|
||||
same_record_fields_any_order:
|
||||
v!({ a: v!(U8), b: v!(U8), c: v!(U8), }),
|
||||
v!({ c: v!(U8), a: v!(U8), b: v!(U8), })
|
||||
explicit_empty_record_and_implicit_empty_record:
|
||||
v!(EMPTY_RECORD), v!({})
|
||||
|
||||
list_list_diff_types:
|
||||
v!(Symbol::LIST_LIST v!(STR)), v!(Symbol::LIST_LIST v!(U8))
|
||||
str_str:
|
||||
v!(Symbol::STR_STR), v!(Symbol::STR_STR)
|
||||
}
|
||||
|
||||
test_key_neq! {
|
||||
Decoder,
|
||||
|
||||
different_record_fields:
|
||||
v!({ a: v!(U8), }), v!({ b: v!(U8), })
|
||||
record_empty_vs_nonempty:
|
||||
v!(EMPTY_RECORD), v!({ a: v!(U8), })
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn immediates() {
|
||||
check_immediate(Decoder, v!(U8), Symbol::DECODE_U8);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
use insta::assert_snapshot;
|
||||
|
||||
use crate::{
|
||||
test_hash_eq, test_hash_neq,
|
||||
test_key_eq, test_key_neq,
|
||||
util::{check_immediate, derive_test},
|
||||
v,
|
||||
};
|
||||
|
@ -17,7 +17,7 @@ use roc_types::subs::Variable;
|
|||
|
||||
// {{{ hash tests
|
||||
|
||||
test_hash_eq! {
|
||||
test_key_eq! {
|
||||
ToEncoder,
|
||||
|
||||
same_record:
|
||||
|
@ -70,7 +70,7 @@ test_hash_eq! {
|
|||
v!(@Symbol::BOOL_BOOL => v!([ True, False ])), v!(Symbol::UNDERSCORE => v!([False, True]))
|
||||
}
|
||||
|
||||
test_hash_neq! {
|
||||
test_key_neq! {
|
||||
ToEncoder,
|
||||
|
||||
different_record_fields:
|
||||
|
|
|
@ -178,7 +178,7 @@ where
|
|||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! test_hash_eq {
|
||||
macro_rules! test_key_eq {
|
||||
($builtin:expr, $($name:ident: $synth1:expr, $synth2:expr)*) => {$(
|
||||
#[test]
|
||||
fn $name() {
|
||||
|
@ -188,7 +188,7 @@ macro_rules! test_hash_eq {
|
|||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! test_hash_neq {
|
||||
macro_rules! test_key_neq {
|
||||
($builtin:expr, $($name:ident: $synth1:expr, $synth2:expr)*) => {$(
|
||||
#[test]
|
||||
fn $name() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue