diff options
| author | Stjepan Glavina <stjepang@gmail.com> | 2018-04-06 15:02:21 +0200 |
|---|---|---|
| committer | Stjepan Glavina <stjepang@gmail.com> | 2018-04-06 15:15:28 +0200 |
| commit | f86deef5b6059b9a0a76d9f0dafb95ced85f7449 (patch) | |
| tree | d94f5bccb1bb443a0c2bc9cddf83daed6248ef62 /src/libcore/tests | |
| parent | a143462783cec88b7b733e8aa09990bfeb59f754 (diff) | |
| download | rust-f86deef5b6059b9a0a76d9f0dafb95ced85f7449.tar.gz rust-f86deef5b6059b9a0a76d9f0dafb95ced85f7449.zip | |
Add Cell::update
Diffstat (limited to 'src/libcore/tests')
| -rw-r--r-- | src/libcore/tests/cell.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libcore/tests/cell.rs b/src/libcore/tests/cell.rs index cc0ef6a6f17..962fb2f0e02 100644 --- a/src/libcore/tests/cell.rs +++ b/src/libcore/tests/cell.rs @@ -27,6 +27,17 @@ fn smoketest_cell() { } #[test] +fn cell_update() { + let x = Cell::new(10); + + assert_eq!(x.update(|x| x + 5), 15); + assert_eq!(x.get(), 15); + + assert_eq!(x.update(|x| x / 3), 5); + assert_eq!(x.get(), 5); +} + +#[test] fn cell_has_sensible_show() { let x = Cell::new("foo bar"); assert!(format!("{:?}", x).contains(x.get())); |
