about summary refs log tree commit diff stats
path: root/032array.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-11-05 21:35:25 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-11-05 21:35:25 -0700
commitcb48c5d79ca41d4b8d6f44f54cca53bfcb7b8670 (patch)
treedc7fb84e9dba3743dc0f88f937fbc98693ce5d6d /032array.cc
parent2e57fed3596983b3f8b2fed3694cb50bf4e3eef7 (diff)
downloadmu-cb48c5d79ca41d4b8d6f44f54cca53bfcb7b8670.tar.gz
3625 - gracefully handle fractional array index
Follow-up to commit 3622. Even though there's no code change that's just
a happy accident; we hadn't at all considered this constraint thus far.
Diffstat (limited to '032array.cc')
-rw-r--r--032array.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/032array.cc b/032array.cc
index b8b4088a..c9182912 100644
--- a/032array.cc
+++ b/032array.cc
@@ -305,6 +305,17 @@ void test_array_length_compound() {
   CHECK_EQ(array_length(x), 3);
 }
 
+:(scenario index_truncates)
+def main [
+  1:array:num:3 <- create-array
+  2:num <- copy 14
+  3:num <- copy 15
+  4:num <- copy 16
+  5:num <- index 1:array:num:3, 1.5  # non-whole number
+]
+# fraction is truncated away
++mem: storing 15 in location 5
+
 :(scenario index_out_of_bounds)
 % Hide_errors = true;
 def main [