Skip to content

Commit

Permalink
Revive the main Maybe test (#848)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfellis authored Aug 16, 2024
1 parent 79397d4 commit 9319b27
Showing 1 changed file with 14 additions and 35 deletions.
49 changes: 14 additions & 35 deletions src/compile/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2525,51 +2525,30 @@ test!(maybe_exists => r#"
stdout "true\nfalse\ntrue\n";
);

test_ignore!(maybe => r#"
fn fiver(val: float64) {
if val.i64 == 5 {
return some(5);
} else {
return none;
}
}
test!(maybe => r#"
// TODO: Rewrite these conditionals with conditional syntax once implemented
fn fiver(val: f64) -> i64? = if(val.i64 == 5,
fn () -> i64? = {i64?}(5),
fn () -> i64? = {i64?}());
export fn main {
const maybe5 = fiver(5.5);
if maybe5.isSome {
print(maybe5.getOr(0));
} else {
print('what?');
}
if(maybe5.exists,
fn = maybe5.getOr(0).print,
fn = 'what?'.print);
const maybeNot5 = fiver(4.4);
if maybeNot5.isNone {
print('Correctly received nothing!');
} else {
print('uhhh');
}
if(!maybeNot5.exists,
fn = 'Correctly received nothing!'.print,
fn = 'uhhh'.print);
if maybe5.isSome {
print(maybe5 || 0);
} else {
print('what?');
}
if maybeNot5.isNone {
print('Correctly received nothing!');
} else {
print('uhhh');
}
maybe5.string.print;
maybeNot5.string.print;
maybe5.print;
maybeNot5.print;
}"#;
stdout r#"5
Correctly received nothing!
5
Correctly received nothing!
5
none
void
"#;
);
test!(fallible => r#"
Expand Down

0 comments on commit 9319b27

Please sign in to comment.