1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-04 17:18:23 -05:00
denoland-deno/std/wasi/testdata/std_fs_file_sync_data.rs
2020-06-29 10:44:08 -04:00

15 lines
446 B
Rust

// { "preopens": { "/scratch": "scratch" } }
use std::io::Write;
fn main() {
let mut file = std::fs::File::create("/scratch/file").unwrap();
assert!(file.write(b"Hello").is_ok());
assert!(file.sync_data().is_ok());
assert_eq!(std::fs::read("/scratch/file").unwrap(), b"Hello");
assert!(file.write(b", world!").is_ok());
assert!(file.sync_data().is_ok());
assert_eq!(std::fs::read("/scratch/file").unwrap(), b"Hello, world!");
}