From 3ad1d42cc9b8d25b22e53cfb4b206b91b1fc3a17 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 6 Jun 2015 10:15:43 -0700 Subject: 1533 - repl: long-standing bug with backspace --- 060string.mu | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/060string.mu b/060string.mu index 0e7d0da5..225490f8 100644 --- a/060string.mu +++ b/060string.mu @@ -163,7 +163,7 @@ recipe buffer-append [ break-unless backspace?:boolean empty?:boolean <- lesser-or-equal len:address:number/deref, 0:literal reply-if empty?:boolean, in:address:buffer/same-as-ingredient:0 - len:address:number <- subtract len:address:number, 1:literal + len:address:number/deref <- subtract len:address:number/deref, 1:literal reply in:address:buffer/same-as-ingredient:0 } { @@ -231,6 +231,23 @@ scenario buffer-append-works [ ] ] +scenario buffer-append-handles-backspace [ + run [ + default-space:address:array:location <- new location:type, 30:literal + x:address:buffer <- init-buffer 3:literal + x:address:buffer <- buffer-append x:address:buffer, 97:literal # 'a' + x:address:buffer <- buffer-append x:address:buffer, 98:literal # 'b' + x:address:buffer <- buffer-append x:address:buffer, 8:literal/backspace + s:address:array:character <- buffer-to-array x:address:buffer + 1:array:character/raw <- copy s:address:array:character/deref + ] + memory-should-contain [ + 1 <- 1 # length + 2 <- 97 # contents + 3 <- 0 + ] +] + # result:address:array:character <- integer-to-decimal-string n:number recipe integer-to-decimal-string [ default-space:address:array:location <- new location:type, 30:literal -- cgit 1.4.1-2-gfad0