about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-08-14 05:24:04 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-08-14 05:24:04 -0700
commitdf32a04c40832fe3d3092b35233a58af74af00f9 (patch)
tree7f439f3d8a448e977630ac0e9efe1d0810bf092a
parentfda86efe517b7086c0ec7601462aa119b2cba1a1 (diff)
downloadmu-df32a04c40832fe3d3092b35233a58af74af00f9.tar.gz
3186 - handle 'new-buffer' without ingredients
-rw-r--r--061text.mu14
1 files changed, 14 insertions, 0 deletions
diff --git a/061text.mu b/061text.mu
index 1ba93f75..6d0fb082 100644
--- a/061text.mu
+++ b/061text.mu
@@ -122,6 +122,11 @@ def new-buffer capacity:number -> result:address:buffer [
   load-ingredients
   result <- new buffer:type
   *result <- put *result, length:offset, 0
+  {
+    break-if capacity
+    # capacity not provided
+    capacity <- copy 10
+  }
   data:address:array:character <- new character:type, capacity
   *result <- put *result, data:offset, data
   return result
@@ -242,6 +247,15 @@ scenario buffer-append-works [
   ]
 ]
 
+scenario buffer-append-to-empty [
+  run [
+    local-scope
+    x:address:buffer <- new-buffer
+    c:character <- copy 97/a
+    x <- append x, c
+  ]
+]
+
 scenario buffer-append-handles-backspace [
   run [
     local-scope