Skip to content

Commit 45a7f09

Browse files
committed
add tests
1 parent 6b0a0af commit 45a7f09

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

library/coretests/tests/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
#![feature(never_type)]
7878
#![feature(next_index)]
7979
#![feature(numfmt)]
80+
#![feature(option_reduce)]
8081
#![feature(pattern)]
8182
#![feature(pointer_is_aligned_to)]
8283
#![feature(portable_simd)]

library/coretests/tests/option.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,3 +584,15 @@ fn as_slice() {
584584
assert_eq!(A, &[44]);
585585
assert_eq!(B, &[]);
586586
}
587+
588+
#[test]
589+
fn reduce_options() {
590+
let x = Some(10);
591+
let y = Some(7);
592+
let z = None::<i32>;
593+
594+
assert_eq!(x.reduce(y, |x, y| x + y), Some(17));
595+
assert_eq!(x.reduce(z, |x, y| x + y), Some(10));
596+
assert_eq!(y.reduce(z, |x, y| x + y), Some(7));
597+
assert_eq!(z.reduce(z, |x, y| x + y), None);
598+
}

0 commit comments

Comments
 (0)