Skip to content

Commit

Permalink
Merge branch 'master' of github.com:IDML/idml
Browse files Browse the repository at this point in the history
  • Loading branch information
andimiller committed Feb 26, 2019
2 parents 65924e7 + 0702ecf commit 6c3c345
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions core/src/test/resources/io.idml.ast/IndexSuite.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,23 @@
"input": {"a": [10]},
"output": {"b": 10}
},

{
"name": "last item - missing",
"mapping": "b = a[-1]",
"input": {"a": []},
"output": {}
},

{
"name": "last item - longer list",
"mapping": "b = a[-1]",
"input": {"a": [1,2,3]},
"output": {"b": 3}
},
{
"name": "allow wrapping on all negative indexes",
"name": "not allow wrapping on all negative indexes",
"mapping": "b = a[-10]",
"input": {"a": [10, 11, 12, 13]},
"output": {"b": 12}
"output": {}
},

{
Expand Down
2 changes: 1 addition & 1 deletion datanodes/src/main/scala/io/idml/PtolemyArray.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ trait PtolemyArray extends PtolemyValue with CompositeValue {
/** Wrap an index so we can support negatives but overflows should always return nothing */
protected def wrapIndex(index: Int, size: Int): Int = {
if (index < 0) {
math.abs(index % size.max(1))
size + index
} else {
index
}
Expand Down

0 comments on commit 6c3c345

Please sign in to comment.