about summary refs log tree commit diff stats
path: root/shell/sandbox.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-06-06 12:39:03 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-06-06 12:39:03 -0700
commit8014210316809c9d59adc015ecc181337b42cf19 (patch)
treecec2c2a98bc5f4277ce8aa63b30774e7bfc7e29b /shell/sandbox.mu
parent3bdf3b1a7f146998078975e2f7c1d5e887f84e9f (diff)
downloadmu-8014210316809c9d59adc015ecc181337b42cf19.tar.gz
shell: support negative integer literals
We still don't support _any_ fractional literals, positive or negative.
Diffstat (limited to 'shell/sandbox.mu')
-rw-r--r--shell/sandbox.mu18
1 files changed, 18 insertions, 0 deletions
diff --git a/shell/sandbox.mu b/shell/sandbox.mu
index 0aad5b44..67b89e75 100644
--- a/shell/sandbox.mu
+++ b/shell/sandbox.mu
@@ -740,6 +740,24 @@ fn test-run-integer {
   check-screen-row screen, 3/y, " => 1 ", "F - test-run-integer/2"
 }
 
+fn test-run-negative-integer {
+  var sandbox-storage: sandbox
+  var sandbox/esi: (addr sandbox) <- address sandbox-storage
+  initialize-sandbox-with sandbox, "-1"
+  # eval
+  edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/no-tweak-screen
+  # setup: screen
+  var screen-on-stack: screen
+  var screen/edi: (addr screen) <- address screen-on-stack
+  initialize-screen screen, 0x80/width, 0x10/height, 0/no-pixel-graphics
+  #
+  render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height, 1/show-cursor
+  # skip one line of padding
+  check-screen-row screen, 1/y, " -1    ", "F - test-run-negative-integer/0"
+  check-screen-row screen, 2/y, " ...   ", "F - test-run-negative-integer/1"
+  check-screen-row screen, 3/y, " => -1 ", "F - test-run-negative-integer/2"
+}
+
 fn test-run-error-invalid-integer {
   var sandbox-storage: sandbox
   var sandbox/esi: (addr sandbox) <- address sandbox-storage