Fast-path for determining ability member impls for builtin opaques

This commit is contained in:
Ayaz Hafiz 2023-03-20 16:05:10 -04:00
parent 297a571b34
commit e6094df69b
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
8 changed files with 182 additions and 60 deletions

View file

@ -504,6 +504,25 @@ mod encode_immediate {
)
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn bool() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Encode, Json] provides [main] to "./platform"
main =
when Str.fromUtf8 (Encode.toBytes Bool.false Json.toUtf8) is
Ok s -> s
_ -> "<bad>"
"#
),
RocStr::from(r"false"),
RocStr
)
}
macro_rules! num_immediate {
($($num:expr, $typ:ident)*) => {$(
#[test]
@ -1001,6 +1020,25 @@ mod decode_immediate {
)
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
fn bool() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
main =
when Str.toUtf8 "false" |> Decode.fromBytes Json.fromUtf8 is
Ok s -> s
_ -> Bool.true
"#
),
false,
bool
)
}
macro_rules! num_immediate {
($($num:expr, $typ:ident)*) => {$(
#[test]