Skip to content

Commit

Permalink
feat(hog): start arrays from 1 (#23773)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra authored Jul 18, 2024
1 parent 2ca07dc commit e494d0e
Show file tree
Hide file tree
Showing 15 changed files with 240 additions and 196 deletions.
41 changes: 22 additions & 19 deletions hogvm/__tests__/__snapshots__/arrays.hoge
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
["_h", 43, 0, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 43, 3, 2, "print", 1, 35, 33, 1, 32, "2", 33, 3, 43, 3, 2,
"print", 1, 35, 33, 1, 33, 2, 33, 3, 43, 2, 33, 4, 43, 3, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 43, 2, 43, 2,
33, 5, 43, 3, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 43, 3, 36, 0, 33, 1, 45, 2, "print", 1, 35, 36, 0, 33, 1, 48, 2,
"print", 1, 35, 36, 0, 33, 1, 48, 2, "print", 1, 35, 36, 0, 33, 6, 48, 2, "print", 1, 35, 36, 0, 33, 6, 48, 2, "print",
1, 35, 33, 1, 33, 2, 33, 3, 43, 3, 33, 1, 45, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 43, 2, 43, 2, 33, 5, 43, 3,
33, 1, 45, 33, 1, 45, 33, 1, 45, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 43, 2, 43, 2, 33, 5, 43, 3, 33, 1, 48,
33, 1, 48, 33, 1, 48, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 43, 2, 43, 2, 33, 5, 43, 3, 33, 1, 48, 33, 1, 48,
33, 1, 48, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 43, 2, 43, 2, 33, 5, 43, 3, 33, 6, 48, 33, 3, 48, 33, 1, 48,
2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 43, 2, 43, 2, 33, 5, 43, 3, 33, 6, 48, 33, 3, 48, 33, 1, 48, 2, "print",
1, 35, 33, 1, 33, 1, 33, 2, 33, 3, 33, 4, 43, 2, 43, 2, 33, 5, 43, 3, 33, 1, 45, 33, 1, 45, 33, 1, 45, 6, 2, "print", 1,
35, 33, 1, 33, 2, 33, 3, 33, 4, 43, 2, 43, 2, 33, 5, 43, 3, 33, 1, 45, 33, 1, 45, 33, 1, 45, 2, "print", 1, 35, 32,
"------", 2, "print", 1, 35, 33, 4, 33, 1, 33, 2, 33, 3, 43, 3, 2, "arrayPushBack", 2, 2, "print", 1, 35, 33, 0, 33, 1,
33, 2, 33, 3, 43, 3, 2, "arrayPushFront", 2, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 43, 3, 2, "arrayPopBack", 1, 2,
"print", 1, 35, 33, 1, 33, 2, 33, 3, 43, 3, 2, "arrayPopFront", 1, 2, "print", 1, 35, 33, 3, 33, 2, 33, 1, 43, 3, 2,
"arraySort", 1, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 43, 3, 2, "arrayReverse", 1, 2, "print", 1, 35, 33, 3, 33, 2,
33, 1, 43, 3, 2, "arrayReverseSort", 1, 2, "print", 1, 35, 32, ",", 33, 1, 33, 2, 33, 3, 43, 3, 2, "arrayStringConcat",
2, 2, "print", 1, 35, 32, "-----", 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 43, 4, 36, 1, 2, "print", 1, 35, 33,
5, 36, 1, 2, "arrayPushBack", 2, 35, 36, 1, 2, "print", 1, 35, 33, 0, 36, 1, 2, "arrayPushFront", 2, 35, 36, 1, 2,
"print", 1, 35, 36, 1, 2, "arrayPopBack", 1, 35, 36, 1, 2, "print", 1, 35, 36, 1, 2, "arrayPopFront", 1, 35, 36, 1, 2,
"print", 1, 35, 36, 1, 2, "arraySort", 1, 35, 36, 1, 2, "print", 1, 35, 36, 1, 2, "arrayReverse", 1, 35, 36, 1, 2,
"print", 1, 35, 36, 1, 2, "arrayReverseSort", 1, 35, 36, 1, 2, "print", 1, 35, 35, 35]
33, 5, 43, 3, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 43, 3, 36, 0, 33, 2, 45, 2, "print", 1, 35, 36, 0, 33, 2, 48, 2,
"print", 1, 35, 36, 0, 33, 2, 48, 2, "print", 1, 35, 36, 0, 33, 7, 48, 2, "print", 1, 35, 36, 0, 33, 7, 48, 2, "print",
1, 35, 33, 1, 33, 2, 33, 3, 43, 3, 33, 2, 45, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 43, 2, 43, 2, 33, 5, 43, 3,
33, 2, 45, 33, 2, 45, 33, 2, 45, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 43, 2, 43, 2, 33, 5, 43, 3, 33, 2, 48,
33, 2, 48, 33, 2, 48, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 43, 2, 43, 2, 33, 5, 43, 3, 33, 2, 48, 33, 2, 48,
33, 2, 48, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 43, 2, 43, 2, 33, 5, 43, 3, 33, 7, 48, 33, 4, 48, 33, 2, 48,
2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 43, 2, 43, 2, 33, 5, 43, 3, 33, 7, 48, 33, 4, 48, 33, 2, 48, 2, "print",
1, 35, 33, 1, 33, 1, 33, 2, 33, 3, 33, 4, 43, 2, 43, 2, 33, 5, 43, 3, 33, 2, 45, 33, 2, 45, 33, 2, 45, 6, 2, "print", 1,
35, 33, 1, 33, 2, 33, 3, 33, 4, 43, 2, 43, 2, 33, 5, 43, 3, 33, 2, 45, 33, 2, 45, 33, 2, 45, 2, "print", 1, 35, 32,
"------", 2, "print", 1, 35, 33, 1, 33, 2, 33, 1, 33, 2, 33, 3, 43, 3, 43, 3, 36, 1, 33, 2, 33, 4, 46, 36, 1, 33, 1, 45,
2, "print", 1, 35, 36, 1, 33, 2, 45, 2, "print", 1, 35, 36, 1, 33, 3, 45, 2, "print", 1, 35, 36, 1, 33, 3, 45, 33, 3,
33, 8, 46, 36, 1, 2, "print", 1, 35, 32, "------", 2, "print", 1, 35, 33, 4, 33, 1, 33, 2, 33, 3, 43, 3, 2,
"arrayPushBack", 2, 2, "print", 1, 35, 33, 0, 33, 1, 33, 2, 33, 3, 43, 3, 2, "arrayPushFront", 2, 2, "print", 1, 35, 33,
1, 33, 2, 33, 3, 43, 3, 2, "arrayPopBack", 1, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 43, 3, 2, "arrayPopFront", 1, 2,
"print", 1, 35, 33, 3, 33, 2, 33, 1, 43, 3, 2, "arraySort", 1, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 43, 3, 2,
"arrayReverse", 1, 2, "print", 1, 35, 33, 3, 33, 2, 33, 1, 43, 3, 2, "arrayReverseSort", 1, 2, "print", 1, 35, 32, ",",
33, 1, 33, 2, 33, 3, 43, 3, 2, "arrayStringConcat", 2, 2, "print", 1, 35, 32, "-----", 2, "print", 1, 35, 33, 1, 33, 2,
33, 3, 33, 4, 43, 4, 36, 2, 2, "print", 1, 35, 33, 5, 36, 2, 2, "arrayPushBack", 2, 35, 36, 2, 2, "print", 1, 35, 33, 0,
36, 2, 2, "arrayPushFront", 2, 35, 36, 2, 2, "print", 1, 35, 36, 2, 2, "arrayPopBack", 1, 35, 36, 2, 2, "print", 1, 35,
36, 2, 2, "arrayPopFront", 1, 35, 36, 2, 2, "print", 1, 35, 36, 2, 2, "arraySort", 1, 35, 36, 2, 2, "print", 1, 35, 36,
2, 2, "arrayReverse", 1, 35, 36, 2, 2, "print", 1, 35, 36, 2, 2, "arrayReverseSort", 1, 35, 36, 2, 2, "print", 1, 35,
35, 35, 35]
5 changes: 5 additions & 0 deletions hogvm/__tests__/__snapshots__/arrays.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ null
5
4
------
1
4
[1, 2, 3]
[1, 4, [1, 2, 8]]
------
[1, 2, 3, 4]
[0, 1, 2, 3]
[1, 2]
Expand Down
18 changes: 9 additions & 9 deletions hogvm/__tests__/__snapshots__/loops.hoge
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
36, 0, 15, 40, 15, 36, 0, 2, "print", 1, 35, 33, 1, 36, 0, 6, 37, 0, 39, -22, 35, 32, "i", 1, 1, 2, "print", 1, 35, 32,
"-- test emptier for loop --", 2, "print", 1, 35, 33, 0, 33, 3, 36, 0, 15, 40, 15, 32, "woo", 2, "print", 1, 35, 33, 1,
36, 0, 6, 37, 0, 39, -22, 32, "hoo", 2, "print", 1, 35, 35, 32, "-- for in loop with arrays --", 2, "print", 1, 35, 33,
1, 33, 2, 33, 3, 43, 3, 36, 0, 36, 1, 2, "values", 1, 33, 0, 36, 2, 2, "length", 1, 31, 36, 4, 36, 3, 15, 40, 22, 36, 2,
1, 33, 2, 33, 3, 43, 3, 36, 0, 36, 1, 2, "values", 1, 33, 1, 36, 2, 2, "length", 1, 31, 36, 4, 36, 3, 16, 40, 22, 36, 2,
36, 3, 45, 37, 5, 36, 5, 2, "print", 1, 35, 36, 3, 33, 1, 6, 37, 3, 39, -29, 35, 35, 35, 35, 35, 35, 32,
"-- for in loop with arrays and keys --", 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 43, 3, 36, 0, 36, 1, 2, "keys", 1, 36,
1, 2, "values", 1, 33, 0, 36, 3, 2, "length", 1, 31, 31, 36, 5, 36, 4, 15, 40, 31, 36, 2, 36, 4, 45, 37, 6, 36, 3, 36,
1, 2, "values", 1, 33, 1, 36, 3, 2, "length", 1, 31, 31, 36, 5, 36, 4, 16, 40, 31, 36, 2, 36, 4, 45, 37, 6, 36, 3, 36,
4, 45, 37, 7, 36, 7, 36, 6, 2, "print", 2, 35, 36, 4, 33, 1, 6, 37, 4, 39, -38, 35, 35, 35, 35, 35, 35, 35, 35, 32,
"-- for in loop with tuples --", 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 44, 3, 36, 0, 36, 1, 2, "values", 1, 33, 0, 36,
2, 2, "length", 1, 31, 36, 4, 36, 3, 15, 40, 22, 36, 2, 36, 3, 45, 37, 5, 36, 5, 2, "print", 1, 35, 36, 3, 33, 1, 6, 37,
"-- for in loop with tuples --", 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 44, 3, 36, 0, 36, 1, 2, "values", 1, 33, 1, 36,
2, 2, "length", 1, 31, 36, 4, 36, 3, 16, 40, 22, 36, 2, 36, 3, 45, 37, 5, 36, 5, 2, "print", 1, 35, 36, 3, 33, 1, 6, 37,
3, 39, -29, 35, 35, 35, 35, 35, 35, 32, "-- for in loop with tuples and keys --", 2, "print", 1, 35, 33, 1, 33, 2, 33,
3, 44, 3, 36, 0, 36, 1, 2, "keys", 1, 36, 1, 2, "values", 1, 33, 0, 36, 3, 2, "length", 1, 31, 31, 36, 5, 36, 4, 15, 40,
3, 44, 3, 36, 0, 36, 1, 2, "keys", 1, 36, 1, 2, "values", 1, 33, 1, 36, 3, 2, "length", 1, 31, 31, 36, 5, 36, 4, 16, 40,
31, 36, 2, 36, 4, 45, 37, 6, 36, 3, 36, 4, 45, 37, 7, 36, 7, 36, 6, 2, "print", 2, 35, 36, 4, 33, 1, 6, 37, 4, 39, -38,
35, 35, 35, 35, 35, 35, 35, 35, 32, "-- for in loop with dicts --", 2, "print", 1, 35, 32, "first", 32, "v1", 32,
"second", 32, "v2", 32, "third", 32, "v3", 42, 3, 36, 0, 36, 1, 2, "values", 1, 33, 0, 36, 2, 2, "length", 1, 31, 36, 4,
36, 3, 15, 40, 22, 36, 2, 36, 3, 45, 37, 5, 36, 5, 2, "print", 1, 35, 36, 3, 33, 1, 6, 37, 3, 39, -29, 35, 35, 35, 35,
"second", 32, "v2", 32, "third", 32, "v3", 42, 3, 36, 0, 36, 1, 2, "values", 1, 33, 1, 36, 2, 2, "length", 1, 31, 36, 4,
36, 3, 16, 40, 22, 36, 2, 36, 3, 45, 37, 5, 36, 5, 2, "print", 1, 35, 36, 3, 33, 1, 6, 37, 3, 39, -29, 35, 35, 35, 35,
35, 35, 32, "-- for in loop with dicts and keys --", 2, "print", 1, 35, 32, "first", 32, "v1", 32, "second", 32, "v2",
32, "third", 32, "v3", 42, 3, 36, 0, 36, 1, 2, "keys", 1, 36, 1, 2, "values", 1, 33, 0, 36, 3, 2, "length", 1, 31, 31,
36, 5, 36, 4, 15, 40, 31, 36, 2, 36, 4, 45, 37, 6, 36, 3, 36, 4, 45, 37, 7, 36, 7, 36, 6, 2, "print", 2, 35, 36, 4, 33,
32, "third", 32, "v3", 42, 3, 36, 0, 36, 1, 2, "keys", 1, 36, 1, 2, "values", 1, 33, 1, 36, 3, 2, "length", 1, 31, 31,
36, 5, 36, 4, 16, 40, 31, 36, 2, 36, 4, 45, 37, 6, 36, 3, 36, 4, 45, 37, 7, 36, 7, 36, 6, 2, "print", 2, 35, 36, 4, 33,
1, 6, 37, 4, 39, -38, 35, 35, 35, 35, 35, 35, 35, 35]
28 changes: 14 additions & 14 deletions hogvm/__tests__/__snapshots__/properties.hoge
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
["_h", 33, 1, 33, 2, 32, "d", 33, 1, 33, 3, 33, 42, 33, 6, 44, 4, 42, 1, 43, 3, 36, 0, 33, 2, 45, 32, "d", 45, 33, 1,
45, 2, "print", 1, 35, 35, 33, 1, 33, 2, 32, "d", 33, 1, 33, 3, 33, 42, 33, 6, 44, 4, 42, 1, 43, 3, 36, 0, 33, 2, 45,
32, "d", 45, 33, 2, 45, 2, "print", 1, 35, 35, 33, 1, 33, 2, 32, "d", 33, 1, 33, 3, 33, 42, 33, 6, 44, 4, 42, 1, 43, 3,
36, 0, 33, 2, 45, 32, "d", 45, 33, 3, 45, 2, "print", 1, 35, 35, 32, "d", 33, 1, 33, 3, 33, 42, 33, 6, 44, 4, 42, 1, 36,
0, 32, "d", 45, 33, 1, 45, 2, "print", 1, 35, 35, 33, 1, 33, 2, 32, "d", 33, 1, 33, 3, 33, 42, 33, 3, 43, 4, 42, 1, 43,
3, 36, 0, 33, 2, 45, 32, "d", 45, 33, 2, 33, 3, 46, 36, 0, 33, 2, 45, 32, "d", 45, 33, 2, 45, 2, "print", 1, 35, 35, 33,
1, 33, 2, 32, "d", 33, 1, 33, 3, 33, 42, 33, 3, 43, 4, 42, 1, 43, 3, 36, 0, 33, 2, 45, 32, "d", 45, 33, 2, 33, 3, 46,
36, 0, 33, 2, 45, 32, "d", 45, 33, 2, 45, 2, "print", 1, 35, 35, 33, 1, 33, 2, 32, "d", 33, 1, 33, 3, 33, 42, 33, 3, 43,
4, 42, 1, 43, 3, 36, 0, 33, 2, 45, 32, "c", 33, 666, 43, 1, 46, 36, 0, 33, 2, 45, 2, "print", 1, 35, 35, 33, 1, 33, 2,
32, "d", 33, 1, 33, 3, 33, 42, 33, 3, 43, 4, 42, 1, 43, 3, 36, 0, 33, 2, 45, 32, "d", 45, 33, 2, 33, 3, 46, 36, 0, 33,
2, 45, 32, "d", 45, 2, "print", 1, 35, 35, 33, 1, 33, 2, 32, "d", 33, 1, 33, 3, 33, 42, 33, 3, 43, 4, 42, 1, 43, 3, 36,
0, 33, 2, 45, 32, "d", 32, "a", 32, "b", 32, "c", 32, "d", 43, 4, 46, 36, 0, 33, 2, 45, 32, "d", 45, 33, 2, 45, 2,
"print", 1, 35, 35, 33, 1, 33, 2, 32, "d", 33, 1, 33, 3, 33, 42, 33, 3, 43, 4, 42, 1, 43, 3, 32, "d", 36, 0, 33, 2, 45,
36, 1, 32, "a", 32, "b", 32, "c", 32, "d", 43, 4, 46, 36, 0, 33, 2, 45, 32, "d", 45, 33, 2, 45, 2, "print", 1, 35, 35,
["_h", 33, 1, 33, 2, 32, "d", 33, 1, 33, 3, 33, 42, 33, 6, 44, 4, 42, 1, 43, 3, 36, 0, 33, 3, 45, 32, "d", 45, 33, 2,
45, 2, "print", 1, 35, 35, 33, 1, 33, 2, 32, "d", 33, 1, 33, 3, 33, 42, 33, 6, 44, 4, 42, 1, 43, 3, 36, 0, 33, 3, 45,
32, "d", 45, 33, 3, 45, 2, "print", 1, 35, 35, 33, 1, 33, 2, 32, "d", 33, 1, 33, 3, 33, 42, 33, 6, 44, 4, 42, 1, 43, 3,
36, 0, 33, 3, 45, 32, "d", 45, 33, 4, 45, 2, "print", 1, 35, 35, 32, "d", 33, 1, 33, 3, 33, 42, 33, 6, 44, 4, 42, 1, 36,
0, 32, "d", 45, 33, 2, 45, 2, "print", 1, 35, 35, 33, 1, 33, 2, 32, "d", 33, 1, 33, 3, 33, 42, 33, 3, 43, 4, 42, 1, 43,
3, 36, 0, 33, 3, 45, 32, "d", 45, 33, 3, 33, 3, 46, 36, 0, 33, 3, 45, 32, "d", 45, 33, 3, 45, 2, "print", 1, 35, 35, 33,
1, 33, 2, 32, "d", 33, 1, 33, 3, 33, 42, 33, 3, 43, 4, 42, 1, 43, 3, 36, 0, 33, 3, 45, 32, "d", 45, 33, 3, 33, 3, 46,
36, 0, 33, 3, 45, 32, "d", 45, 33, 3, 45, 2, "print", 1, 35, 35, 33, 1, 33, 2, 32, "d", 33, 1, 33, 3, 33, 42, 33, 3, 43,
4, 42, 1, 43, 3, 36, 0, 33, 3, 45, 32, "c", 33, 666, 43, 1, 46, 36, 0, 33, 3, 45, 2, "print", 1, 35, 35, 33, 1, 33, 2,
32, "d", 33, 1, 33, 3, 33, 42, 33, 3, 43, 4, 42, 1, 43, 3, 36, 0, 33, 3, 45, 32, "d", 45, 33, 3, 33, 3, 46, 36, 0, 33,
3, 45, 32, "d", 45, 2, "print", 1, 35, 35, 33, 1, 33, 2, 32, "d", 33, 1, 33, 3, 33, 42, 33, 3, 43, 4, 42, 1, 43, 3, 36,
0, 33, 3, 45, 32, "d", 32, "a", 32, "b", 32, "c", 32, "d", 43, 4, 46, 36, 0, 33, 3, 45, 32, "d", 45, 33, 3, 45, 2,
"print", 1, 35, 35, 33, 1, 33, 2, 32, "d", 33, 1, 33, 3, 33, 42, 33, 3, 43, 4, 42, 1, 43, 3, 32, "d", 36, 0, 33, 3, 45,
36, 1, 32, "a", 32, "b", 32, "c", 32, "d", 43, 4, 46, 36, 0, 33, 3, 45, 32, "d", 45, 33, 3, 45, 2, "print", 1, 35, 35,
35, 32, "event", 32, "$pageview", 32, "properties", 32, "$browser", 32, "Chrome", 32, "$os", 32, "Windows", 42, 2, 42,
2, 36, 0, 32, "properties", 45, 32, "$browser", 32, "Firefox", 46, 36, 0, 2, "print", 1, 35, 35, 32, "event", 32,
"$pageview", 32, "properties", 32, "$browser", 32, "Chrome", 32, "$os", 32, "Windows", 42, 2, 42, 2, 36, 0, 32,
Expand Down
16 changes: 8 additions & 8 deletions hogvm/__tests__/__snapshots__/tuples.hoge
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
["_h", 2, "tuple", 0, 2, "print", 1, 35, 33, 1, 44, 1, 2, "print", 1, 35, 33, 1, 33, 2, 44, 2, 2, "print", 1, 35, 33, 1,
33, 2, 44, 2, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 44, 3, 2, "print", 1, 35, 33, 1, 32, "2", 33, 3, 44, 3, 2,
"print", 1, 35, 33, 1, 33, 2, 33, 3, 44, 2, 33, 4, 44, 3, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 44, 2, 44, 2,
33, 5, 44, 3, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 44, 3, 36, 0, 33, 1, 45, 2, "print", 1, 35, 36, 0, 33, 1, 48, 2,
"print", 1, 35, 36, 0, 33, 7, 48, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 44, 2, 44, 2, 33, 5, 44, 3, 33, 1, 45,
33, 1, 45, 33, 1, 45, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 44, 2, 44, 2, 33, 5, 44, 3, 33, 1, 48, 33, 1, 48,
33, 1, 48, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 44, 2, 44, 2, 33, 5, 44, 3, 33, 1, 48, 33, 1, 48, 33, 1, 48,
2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 44, 2, 44, 2, 33, 5, 44, 3, 33, 3, 48, 33, 6, 48, 33, 1, 48, 2, "print",
1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 44, 2, 44, 2, 33, 5, 44, 3, 33, 3, 48, 33, 6, 48, 33, 1, 48, 2, "print", 1, 35, 33,
1, 33, 2, 33, 3, 33, 4, 44, 2, 44, 2, 33, 5, 44, 3, 33, 1, 45, 33, 1, 45, 33, 1, 45, 2, "print", 1, 35, 33, 1, 33, 1,
33, 2, 33, 3, 33, 4, 44, 2, 44, 2, 33, 5, 44, 3, 33, 1, 45, 33, 1, 45, 33, 1, 45, 6, 2, "print", 1, 35, 35]
33, 5, 44, 3, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 44, 3, 36, 0, 33, 2, 45, 2, "print", 1, 35, 36, 0, 33, 2, 48, 2,
"print", 1, 35, 36, 0, 33, 8, 48, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 44, 2, 44, 2, 33, 5, 44, 3, 33, 2, 45,
33, 2, 45, 33, 2, 45, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 44, 2, 44, 2, 33, 5, 44, 3, 33, 2, 48, 33, 2, 48,
33, 2, 48, 2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 44, 2, 44, 2, 33, 5, 44, 3, 33, 2, 48, 33, 2, 48, 33, 2, 48,
2, "print", 1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 44, 2, 44, 2, 33, 5, 44, 3, 33, 4, 48, 33, 7, 48, 33, 2, 48, 2, "print",
1, 35, 33, 1, 33, 2, 33, 3, 33, 4, 44, 2, 44, 2, 33, 5, 44, 3, 33, 4, 48, 33, 7, 48, 33, 2, 48, 2, "print", 1, 35, 33,
1, 33, 2, 33, 3, 33, 4, 44, 2, 44, 2, 33, 5, 44, 3, 33, 2, 45, 33, 2, 45, 33, 2, 45, 2, "print", 1, 35, 33, 1, 33, 1,
33, 2, 33, 3, 33, 4, 44, 2, 44, 2, 33, 5, 44, 3, 33, 2, 45, 33, 2, 45, 33, 2, 45, 6, 2, "print", 1, 35, 35]
35 changes: 22 additions & 13 deletions hogvm/__tests__/arrays.hog
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,28 @@ print([1, [2, 3], 4])
print([1, [2, [3, 4]], 5])

let a := [1, 2, 3]
print(a[1])
print(a?.[1])
print(a?.1)
print(a?.[6])
print(a?.6)
print([1, 2, 3][1], )
print([1, [2, [3, 4], ], 5][1][1][1])
print([1, [2, [3, 4], ], 5]?.1?.1?.1)
print([1, [2, [3, 4], ], 5]?.[1]?.[1]?.[1])
print([1, [2, [3, 4], ], 5]?.6?.3?.1)
print([1, [2, [3, 4], ], 5]?.[6]?.[3]?.[1])
print([1, [2, [3, 4]], 5][1][1][1] + 1)
print([1, [2, [3, 4, ], ], 5, ].1.1.1)
print(a[2])
print(a?.[2])
print(a?.2)
print(a?.[7])
print(a?.7)
print([1, 2, 3][2], )
print([1, [2, [3, 4], ], 5][2][2][2])
print([1, [2, [3, 4], ], 5]?.2?.2?.2)
print([1, [2, [3, 4], ], 5]?.[2]?.[2]?.[2])
print([1, [2, [3, 4], ], 5]?.7?.4?.2)
print([1, [2, [3, 4], ], 5]?.[7]?.[4]?.[2])
print([1, [2, [3, 4]], 5][2][2][2] + 1)
print([1, [2, [3, 4, ], ], 5, ].2.2.2)

print('------')
let b := [1, 2, [1,2,3]]
b[2] := 4
print(b[1])
print(b[2])
print(b[3])
b[3][3] := 8
print(b)

print('------')

Expand Down
32 changes: 16 additions & 16 deletions hogvm/__tests__/properties.hog
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
{
let r := [1, 2, {'d': (1, 3, 42, 6)}]
print(r.2.d.1)
print(r.3.d.2)
}
{
let r := [1, 2, {'d': (1, 3, 42, 6)}]
print(r[2].d[2])
print(r[3].d[3])
}
{
let r := [1, 2, {'d': (1, 3, 42, 6)}]
print(r.2['d'][3])
print(r.3['d'][4])
}
{
let r := {'d': (1, 3, 42, 6)}
print(r.d.1)
print(r.d.2)
}
{
let r := [1, 2, {'d': [1, 3, 42, 3]}]
r.2.d.2 := 3
print(r.2.d.2)
r.3.d.3 := 3
print(r.3.d.3)
}
{
let r := [1, 2, {'d': [1, 3, 42, 3]}]
r[2].d[2] := 3
print(r[2].d[2])
r[3].d[3] := 3
print(r[3].d[3])
}
{
let r := [1, 2, {'d': [1, 3, 42, 3]}]
r[2].c := [666]
print(r[2])
r[3].c := [666]
print(r[3])
}
{
let r := [1, 2, {'d': [1, 3, 42, 3]}]
r[2].d[2] := 3
print(r[2].d)
r[3].d[3] := 3
print(r[3].d)
}
{
let r := [1, 2, {'d': [1, 3, 42, 3]}]
r.2['d'] := ['a', 'b', 'c', 'd']
print(r[2].d[2])
r.3['d'] := ['a', 'b', 'c', 'd']
print(r[3].d[3])
}
{
let r := [1, 2, {'d': [1, 3, 42, 3]}]
let g := 'd'
r.2[g] := ['a', 'b', 'c', 'd']
print(r[2].d[2])
r.3[g] := ['a', 'b', 'c', 'd']
print(r[3].d[3])
}
{
let event := {
Expand Down
20 changes: 10 additions & 10 deletions hogvm/__tests__/tuples.hog
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ print((1, '2', 3))
print((1, (2, 3), 4))
print((1, (2, (3, 4)), 5))
let a := (1, 2, 3)
print(a[1])
print(a?.1)
print(a?.7)
print((1, (2, (3, 4)), 5)[1][1][1])
print((1, (2, (3, 4)), 5)?.1?.1?.1)
print((1, (2, (3, 4)), 5)?.[1]?.[1]?.[1])
print((1, (2, (3, 4)), 5)?.3?.6?.1)
print((1, (2, (3, 4)), 5)?.[3]?.[6]?.[1])
print((1, (2, (3, 4, ), ), 5, ).1.1.1)
print((1, (2, (3, 4)), 5)[1][1][1] + 1)
print(a[2])
print(a?.2)
print(a?.8)
print((1, (2, (3, 4)), 5)[2][2][2])
print((1, (2, (3, 4)), 5)?.2?.2?.2)
print((1, (2, (3, 4)), 5)?.[2]?.[2]?.[2])
print((1, (2, (3, 4)), 5)?.4?.7?.2)
print((1, (2, (3, 4)), 5)?.[4]?.[7]?.[2])
print((1, (2, (3, 4, ), ), 5, ).2.2.2)
print((1, (2, (3, 4)), 5)[2][2][2] + 1)
1 change: 1 addition & 0 deletions hogvm/asd.hog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return [1, 2, 3][0]
1 change: 1 addition & 0 deletions hogvm/asd.hoge
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["_h", 33, 1, 33, 2, 33, 3, 43, 3, 33, 0, 45, 38]
Loading

0 comments on commit e494d0e

Please sign in to comment.