diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-06-06 10:15:43 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-06-06 10:15:43 -0700 |
commit | 3ad1d42cc9b8d25b22e53cfb4b206b91b1fc3a17 (patch) | |
tree | a56b40c21bf4ca58c8b52b7a3c1ad86c426594e8 | |
parent | fb1f2a0a0e1a7f00f6e9f3d6c00609034594e0f8 (diff) | |
download | mu-3ad1d42cc9b8d25b22e53cfb4b206b91b1fc3a17.tar.gz |
1533 - repl: long-standing bug with backspace
-rw-r--r-- | 060string.mu | 19 |
1 files changed, 18 insertions, 1 deletions
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 |