mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Add derive keys for decoders
This commit is contained in:
parent
6697e353a1
commit
e2179348c6
6 changed files with 129 additions and 4 deletions
29
crates/compiler/test_derive/src/decoding.rs
Normal file
29
crates/compiler/test_derive/src/decoding.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
#![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 crate::{util::check_immediate, v};
|
||||
use roc_module::symbol::Symbol;
|
||||
use roc_types::subs::{Subs, Variable};
|
||||
|
||||
use roc_derive_key::DeriveBuiltin::Decoder;
|
||||
|
||||
#[test]
|
||||
fn immediates() {
|
||||
check_immediate(Decoder, v!(U8), Symbol::DECODE_U8);
|
||||
check_immediate(Decoder, v!(U16), Symbol::DECODE_U16);
|
||||
check_immediate(Decoder, v!(U32), Symbol::DECODE_U32);
|
||||
check_immediate(Decoder, v!(U64), Symbol::DECODE_U64);
|
||||
check_immediate(Decoder, v!(U128), Symbol::DECODE_U128);
|
||||
check_immediate(Decoder, v!(I8), Symbol::DECODE_I8);
|
||||
check_immediate(Decoder, v!(I16), Symbol::DECODE_I16);
|
||||
check_immediate(Decoder, v!(I32), Symbol::DECODE_I32);
|
||||
check_immediate(Decoder, v!(I64), Symbol::DECODE_I64);
|
||||
check_immediate(Decoder, v!(I128), Symbol::DECODE_I128);
|
||||
check_immediate(Decoder, v!(DEC), Symbol::DECODE_DEC);
|
||||
check_immediate(Decoder, v!(F32), Symbol::DECODE_F32);
|
||||
check_immediate(Decoder, v!(F64), Symbol::DECODE_F64);
|
||||
check_immediate(Decoder, v!(STR), Symbol::DECODE_STRING);
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
#![cfg(test)]
|
||||
|
||||
mod decoding;
|
||||
mod encoding;
|
||||
|
||||
mod pretty_print;
|
||||
|
|
|
@ -45,6 +45,11 @@ fn module_source_and_path(builtin: DeriveBuiltin) -> (ModuleId, &'static str, Pa
|
|||
module_source(ModuleId::ENCODE),
|
||||
builtins_path.join("Encode.roc"),
|
||||
),
|
||||
DeriveBuiltin::Decoder => (
|
||||
ModuleId::DECODE,
|
||||
module_source(ModuleId::DECODE),
|
||||
builtins_path.join("Decode.roc"),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue