about summary refs log tree commit diff stats
path: root/cpp/060string.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-18 08:34:48 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-18 08:43:23 -0700
commitc85254c858f2086efe9f522341ba714341a62747 (patch)
tree02cac23e4f0c6c2e94681802203dd82aa3e97fed /cpp/060string.mu
parentc8e725632e106920edd7b6aad1556dd8993ecee4 (diff)
downloadmu-c85254c858f2086efe9f522341ba714341a62747.tar.gz
1097 - 'grow-buffer' works the first time!
I thought I'd need to duplicate scenarios to simulate running some code,
making some checks, running some more code. But I can just keep saving
state to raw locations! I'd still have to manage raw locations myself,
though. And it can be ping-pongy to have to check on the other blocks
then go back to the run block. But what's the alternative? Multiple run
blocks (even excluding the implementation effort) raise questions of
namespace sharing across them.

If it gets too bad I can intersperse recipes inside the scenario. Yes,
that will work. Of course, overly long tests might themselves be a bad
idea. We'll see, this is all terra incognita syntactically speaking.

This might not be enough to check that a routine is waiting on a
channel, but should keep us until then. Wait, even there what you need
is a way to check on the status of your child routines. Yeah, doable.
Even if we're getting ahead of ourselves.
Diffstat (limited to 'cpp/060string.mu')
-rw-r--r--cpp/060string.mu17
1 files changed, 17 insertions, 0 deletions
diff --git a/cpp/060string.mu b/cpp/060string.mu
index 8f64b67f..a0d2757d 100644
--- a/cpp/060string.mu
+++ b/cpp/060string.mu
@@ -204,12 +204,29 @@ scenario buffer-append-works [
 #?     $print [
 #? ]
     2:array:character/raw <- copy s2:address:array:character/deref
+    +buffer-filled
+    x:address:buffer <- buffer-append x:address:buffer, 100:literal  # 'd'
+    s3:address:array:character <- get x:address:buffer/deref, data:offset
+    10:boolean/raw <- equal s1:address:array:character, s3:address:array:character
+    11:integer/raw <- get x:address:buffer/deref, length:offset
+    12:array:character/raw <- copy s3:address:array:character/deref
   ]
   memory should contain [
+    # before +buffer-filled
     1 <- 1   # no change in data pointer
     2 <- 3   # size of data
     3 <- 97  # data
     4 <- 98
     5 <- 99
+    # in the end
+    10 <- 0   # data pointer has grown
+    11 <- 4   # final length
+    12 <- 6   # but data's capacity has doubled
+    13 <- 97  # data
+    14 <- 98
+    15 <- 99
+    16 <- 100
+    17 <- 0
+    18 <- 0
   ]
 ]