mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
Num.toStr unit tests
This commit is contained in:
parent
f39f7eda03
commit
17e5ec85aa
1 changed files with 124 additions and 0 deletions
|
@ -2745,6 +2745,130 @@ fn num_to_str() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn num_to_str_u8() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
assert_evals_to!(r#"Num.toStr 0u8"#, RocStr::from("0"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 1u8"#, RocStr::from("1"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 10u8"#, RocStr::from("10"), RocStr);
|
||||
|
||||
let max = format!("{}", u8::MAX);
|
||||
assert_evals_to!(r#"Num.toStr Num.maxU8"#, RocStr::from(max.as_str()), RocStr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn num_to_str_u16() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
assert_evals_to!(r#"Num.toStr 0u16"#, RocStr::from("0"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 1u16"#, RocStr::from("1"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 10u16"#, RocStr::from("10"), RocStr);
|
||||
|
||||
let max = format!("{}", u16::MAX);
|
||||
assert_evals_to!(r#"Num.toStr Num.maxU16"#, RocStr::from(max.as_str()), RocStr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn num_to_str_u32() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
assert_evals_to!(r#"Num.toStr 0u32"#, RocStr::from("0"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 1u32"#, RocStr::from("1"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 10u32"#, RocStr::from("10"), RocStr);
|
||||
|
||||
let max = format!("{}", u32::MAX);
|
||||
assert_evals_to!(r#"Num.toStr Num.maxU32"#, RocStr::from(max.as_str()), RocStr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn num_to_str_u64() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
assert_evals_to!(r#"Num.toStr 0u64"#, RocStr::from("0"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 1u64"#, RocStr::from("1"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 10u64"#, RocStr::from("10"), RocStr);
|
||||
|
||||
let max = format!("{}", u64::MAX);
|
||||
assert_evals_to!(r#"Num.toStr Num.maxU64"#, RocStr::from(max.as_str()), RocStr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn num_to_str_i8() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
assert_evals_to!(r#"Num.toStr -10i8"#, RocStr::from("-10"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr -1i8"#, RocStr::from("-1"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 0i8"#, RocStr::from("0"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 1i8"#, RocStr::from("1"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 10i8"#, RocStr::from("10"), RocStr);
|
||||
|
||||
let max = format!("{}", i8::MAX);
|
||||
assert_evals_to!(r#"Num.toStr Num.maxI8"#, RocStr::from(max.as_str()), RocStr);
|
||||
|
||||
let max = format!("{}", i8::MIN);
|
||||
assert_evals_to!(r#"Num.toStr Num.minI8"#, RocStr::from(max.as_str()), RocStr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn num_to_str_i16() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
assert_evals_to!(r#"Num.toStr -10i16"#, RocStr::from("-10"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr -1i16"#, RocStr::from("-1"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 0i16"#, RocStr::from("0"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 1i16"#, RocStr::from("1"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 10i16"#, RocStr::from("10"), RocStr);
|
||||
|
||||
let max = format!("{}", i16::MAX);
|
||||
assert_evals_to!(r#"Num.toStr Num.maxI16"#, RocStr::from(max.as_str()), RocStr);
|
||||
|
||||
let max = format!("{}", i16::MIN);
|
||||
assert_evals_to!(r#"Num.toStr Num.minI16"#, RocStr::from(max.as_str()), RocStr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn num_to_str_i32() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
assert_evals_to!(r#"Num.toStr -10i32"#, RocStr::from("-10"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr -1i32"#, RocStr::from("-1"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 0i32"#, RocStr::from("0"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 1i32"#, RocStr::from("1"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 10i32"#, RocStr::from("10"), RocStr);
|
||||
|
||||
let max = format!("{}", i32::MAX);
|
||||
assert_evals_to!(r#"Num.toStr Num.maxI32"#, RocStr::from(max.as_str()), RocStr);
|
||||
|
||||
let max = format!("{}", i32::MIN);
|
||||
assert_evals_to!(r#"Num.toStr Num.minI32"#, RocStr::from(max.as_str()), RocStr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn num_to_str_i64() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
assert_evals_to!(r#"Num.toStr -10i64"#, RocStr::from("-10"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr -1i64"#, RocStr::from("-1"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 0i64"#, RocStr::from("0"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 1i64"#, RocStr::from("1"), RocStr);
|
||||
assert_evals_to!(r#"Num.toStr 10i64"#, RocStr::from("10"), RocStr);
|
||||
|
||||
let max = format!("{}", i64::MAX);
|
||||
assert_evals_to!(r#"Num.toStr Num.maxI64"#, RocStr::from(max.as_str()), RocStr);
|
||||
|
||||
let max = format!("{}", i64::MIN);
|
||||
assert_evals_to!(r#"Num.toStr Num.minI64"#, RocStr::from(max.as_str()), RocStr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn u8_addition_greater_than_i8() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue