about summary refs log tree commit diff stats
path: root/075channel.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-09-28 19:48:56 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-09-28 19:48:56 -0700
commit6f65d5918f4b73de56e6cb6362c7cbc7dbbe5945 (patch)
treedec4043f2d62f5dd02156d369e20af247881e2ac /075channel.mu
parent1627d836b46440f57d766b154ec488fa2e5a1e06 (diff)
downloadmu-6f65d5918f4b73de56e6cb6362c7cbc7dbbe5945.tar.gz
3429 - standardize Mu scenarios
A long-standing problem has been that I couldn't spread code across
'run' blocks because they were separate scopes, so I've ended up making
them effectively comments. Running code inside a 'run' block is
identical in every way to simply running the code directly. The 'run'
block is merely a visual aid to separate setup from the component under
test.

In the process I've also standardized all Mu scenarios to always run in
a local scope, and only use (raw) numeric addresses for values they want
to check later.
Diffstat (limited to '075channel.mu')
-rw-r--r--075channel.mu43
1 files changed, 22 insertions, 21 deletions
diff --git a/075channel.mu b/075channel.mu
index ebac99a6..7819f787 100644
--- a/075channel.mu
+++ b/075channel.mu
@@ -177,9 +177,9 @@ scenario channel-initialization [
 ]
 
 scenario channel-write-increments-free [
+  local-scope
+  _, sink:&:sink:num <- new-channel 3/capacity
   run [
-    local-scope
-    _, sink:&:sink:num <- new-channel 3/capacity
     sink <- write sink, 34
     chan:&:channel:num <- get *sink, chan:offset
     10:num/raw <- get *chan, first-full:offset
@@ -192,10 +192,10 @@ scenario channel-write-increments-free [
 ]
 
 scenario channel-read-increments-full [
+  local-scope
+  source:&:source:num, sink:&:sink:num <- new-channel 3/capacity
+  sink <- write sink, 34
   run [
-    local-scope
-    source:&:source:num, sink:&:sink:num <- new-channel 3/capacity
-    sink <- write sink, 34
     _, _, source <- read source
     chan:&:channel:num <- get *source, chan:offset
     10:num/raw <- get *chan, first-full:offset
@@ -208,14 +208,14 @@ scenario channel-read-increments-full [
 ]
 
 scenario channel-wrap [
+  local-scope
+  # channel with just 1 slot
+  source:&:source:num, sink:&:sink:num <- new-channel 1/capacity
+  chan:&:channel:num <- get *source, chan:offset
+  # write and read a value
+  sink <- write sink, 34
+  _, _, source <- read source
   run [
-    local-scope
-    # channel with just 1 slot
-    source:&:source:num, sink:&:sink:num <- new-channel 1/capacity
-    chan:&:channel:num <- get *source, chan:offset
-    # write and read a value
-    sink <- write sink, 34
-    _, _, source <- read source
     # first-free will now be 1
     10:num/raw <- get *chan, first-free:offset
     11:num/raw <- get *chan, first-free:offset
@@ -249,9 +249,10 @@ scenario channel-new-empty-not-full [
 ]
 
 scenario channel-write-not-empty [
+  local-scope
+  source:&:source:num, sink:&:sink:num <- new-channel 3/capacity
+  chan:&:channel:num <- get *source, chan:offset
   run [
-    source:&:source:num, sink:&:sink:num <- new-channel 3/capacity
-    chan:&:channel:num <- get *source, chan:offset
     sink <- write sink, 34
     10:bool/raw <- channel-empty? chan
     11:bool/raw <- channel-full? chan
@@ -263,10 +264,10 @@ scenario channel-write-not-empty [
 ]
 
 scenario channel-write-full [
+  local-scope
+  source:&:source:num, sink:&:sink:num <- new-channel 1/capacity
+  chan:&:channel:num <- get *source, chan:offset
   run [
-    local-scope
-    source:&:source:num, sink:&:sink:num <- new-channel 1/capacity
-    chan:&:channel:num <- get *source, chan:offset
     sink <- write sink, 34
     10:bool/raw <- channel-empty? chan
     11:bool/raw <- channel-full? chan
@@ -278,11 +279,11 @@ scenario channel-write-full [
 ]
 
 scenario channel-read-not-full [
+  local-scope
+  source:&:source:num, sink:&:sink:num <- new-channel 1/capacity
+  chan:&:channel:num <- get *source, chan:offset
+  sink <- write sink, 34
   run [
-    local-scope
-    source:&:source:num, sink:&:sink:num <- new-channel 1/capacity
-    chan:&:channel:num <- get *source, chan:offset
-    sink <- write sink, 34
     _, _, source <- read source
     10:bool/raw <- channel-empty? chan
     11:bool/raw <- channel-full? chan