From c85254c858f2086efe9f522341ba714341a62747 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 18 Apr 2015 08:34:48 -0700 Subject: 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. --- cpp/060string.mu | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'cpp/060string.mu') 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 ] ] -- cgit 1.4.1-2-gfad0