diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-01-01 17:04:37 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-01-01 17:04:37 -0800 |
commit | 2a4088119cf41175457414dfa59bd4064b8f0562 (patch) | |
tree | 64fe184e399f9870ebd481a90eec34d51e5dff68 /archive/1.vm/090scenario_filesystem_test.mu | |
parent | 23fd294d85959c6b476bcdc35ed6ad508cc99b8f (diff) | |
download | mu-2a4088119cf41175457414dfa59bd4064b8f0562.tar.gz |
5852
Diffstat (limited to 'archive/1.vm/090scenario_filesystem_test.mu')
-rw-r--r-- | archive/1.vm/090scenario_filesystem_test.mu | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/archive/1.vm/090scenario_filesystem_test.mu b/archive/1.vm/090scenario_filesystem_test.mu new file mode 100644 index 00000000..b487bfe0 --- /dev/null +++ b/archive/1.vm/090scenario_filesystem_test.mu @@ -0,0 +1,99 @@ +# Check our support for fake file systems in scenarios. + +scenario read-from-fake-file [ + local-scope + assume-resources [ + [a] <- [ + |xyz| + ] + ] + contents:&:source:char <- start-reading resources, [a] + 1:char/raw <- read contents + 2:char/raw <- read contents + 3:char/raw <- read contents + 4:char/raw <- read contents + _, 5:bool/raw <- read contents + memory-should-contain [ + 1 <- 120 # x + 2 <- 121 # y + 3 <- 122 # z + 4 <- 10 # newline + 5 <- 1 # eof + ] +] + +scenario write-to-new-fake-file [ + local-scope + assume-resources [ + ] + sink:&:sink:char, writer:num/routine <- start-writing resources, [a] + sink <- write sink, 120/x + sink <- write sink, 121/y + close sink + wait-for-routine writer + contents-read-back:text <- slurp resources, [a] + 10:bool/raw <- equal contents-read-back, [xy] + memory-should-contain [ + 10 <- 1 # file contents read back exactly match what was written + ] +] + +scenario write-to-new-fake-file-2 [ + local-scope + assume-resources [ + [a] <- [ + |abc| + ] + ] + sink:&:sink:char, writer:num/routine <- start-writing resources, [b] + sink <- write sink, 120/x + sink <- write sink, 121/y + close sink + wait-for-routine writer + contents-read-back:text <- slurp resources, [b] + 10:bool/raw <- equal contents-read-back, [xy] + memory-should-contain [ + 10 <- 1 # file contents read back exactly match what was written + ] +] + +scenario write-to-fake-file-that-exists [ + local-scope + assume-resources [ + [a] <- [] + ] + sink:&:sink:char, writer:num/routine <- start-writing resources, [a] + sink <- write sink, 120/x + sink <- write sink, 121/y + close sink + wait-for-routine writer + contents-read-back:text <- slurp resources, [a] + 10:bool/raw <- equal contents-read-back, [xy] + memory-should-contain [ + 10 <- 1 # file contents read back exactly match what was written + ] +] + +scenario write-to-existing-file-preserves-other-files [ + local-scope + assume-resources [ + [a] <- [] + [b] <- [ + |bcd| + ] + ] + sink:&:sink:char, writer:num/routine <- start-writing resources, [a] + sink <- write sink, 120/x + sink <- write sink, 121/y + close sink + wait-for-routine writer + contents-read-back:text <- slurp resources, [a] + 10:bool/raw <- equal contents-read-back, [xy] + other-file-contents:text <- slurp resources, [b] + 11:bool/raw <- equal other-file-contents, [bcd +] + memory-should-contain [ + 10 <- 1 # file contents read back exactly match what was written + 11 <- 1 # other files also continue to persist unchanged + ] +] |