Skip to content

Commit

Permalink
feat(cdp): Added kinesis template (#23635)
Browse files Browse the repository at this point in the history
Co-authored-by: Marius Andra <[email protected]>
  • Loading branch information
benjackwhite and mariusandra authored Jul 16, 2024
1 parent 3c266b2 commit cbf1f0c
Show file tree
Hide file tree
Showing 28 changed files with 632 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ function HogFunctionInputSchemaControls({ value, onChange, onDone }: HogFunction
/>
<div className="flex-1" />
<LemonButton status="danger" icon={<IconTrash />} size="small" onClick={() => onChange(null)} />
<LemonButton size="small" onClick={() => onDone()}>
<LemonButton type="secondary" size="small" onClick={() => onDone()}>
Done
</LemonButton>
</div>
Expand Down
12 changes: 11 additions & 1 deletion hogvm/__tests__/__snapshots__/arrays.hoge
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,14 @@
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, 35]
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]
18 changes: 18 additions & 0 deletions hogvm/__tests__/__snapshots__/arrays.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,21 @@ null
null
5
4
------
[1, 2, 3, 4]
[0, 1, 2, 3]
[1, 2]
[2, 3]
[1, 2, 3]
[3, 2, 1]
[3, 2, 1]
1,2,3
-----
[1, 2, 3, 4]
[1, 2, 3, 4]
[1, 2, 3, 4]
[1, 2, 3, 4]
[1, 2, 3, 4]
[1, 2, 3, 4]
[1, 2, 3, 4]
[1, 2, 3, 4]
4 changes: 4 additions & 0 deletions hogvm/__tests__/__snapshots__/crypto.hoge
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
["_h", 32, "this is a secure string", 36, 0, 32, "string:", 2, "print", 2, 35, 36, 0, 2, "md5Hex", 1, 32,
"md5Hex(string):", 2, "print", 2, 35, 36, 0, 2, "sha256Hex", 1, 32, "sha256Hex(string):", 2, "print", 2, 35, 32, "1",
32, "string", 32, "more", 32, "keys", 43, 4, 36, 1, 32, "data:", 2, "print", 2, 35, 36, 1, 2, "sha256HmacChainHex", 1,
32, "sha256HmacChainHex(data):", 2, "print", 2, 35, 35, 35]
5 changes: 5 additions & 0 deletions hogvm/__tests__/__snapshots__/crypto.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
string: this is a secure string
md5Hex(string): e7b466647ea215dbe59b00c756560911
sha256Hex(string): 5216c0931310b31737ef30353830c234901283544e934f54eb75f622cfb86c9d
data: ['1', 'string', 'more', 'keys']
sha256HmacChainHex(data): 826820d7eeca97f26ca18096be85fed346f6fd9cc18d64e72c935bea3450dbd9
60 changes: 30 additions & 30 deletions hogvm/__tests__/__snapshots__/dateFormat.hoge
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
["_h", 34, 1234377543.123456, 2, "fromUnixTimestamp", 1, 32, "%Y-%m-%d %H:%i:%S", 36, 0, 2, "formatDateTime", 2, 2,
"print", 1, 35, 32, "Europe/Brussels", 32, "%Y-%m-%d %H:%i:%S", 36, 0, 2, "formatDateTime", 3, 2, "print", 1, 35, 32,
"America/New_York", 32, "%Y-%m-%d %H:%i:%S", 36, 0, 2, "formatDateTime", 3, 2, "print", 1, 35, 32, "-----", 2, "print",
1, 35, 32, "%a", 36, 0, 2, "formatDateTime", 2, 32, "%a: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%b", 36, 0, 2,
"formatDateTime", 2, 32, "%b: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%c", 36, 0, 2, "formatDateTime", 2, 32, "%c: ",
2, "concat", 2, 2, "print", 1, 35, 32, "%C", 36, 0, 2, "formatDateTime", 2, 32, "%C: ", 2, "concat", 2, 2, "print", 1,
35, 32, "%d", 36, 0, 2, "formatDateTime", 2, 32, "%d: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%D", 36, 0, 2,
"formatDateTime", 2, 32, "%D: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%e", 36, 0, 2, "formatDateTime", 2, 32, "%e: ",
2, "concat", 2, 2, "print", 1, 35, 32, "%F", 36, 0, 2, "formatDateTime", 2, 32, "%F: ", 2, "concat", 2, 2, "print", 1,
35, 32, "%g", 36, 0, 2, "formatDateTime", 2, 32, "%g: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%G", 36, 0, 2,
"formatDateTime", 2, 32, "%G: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%h", 36, 0, 2, "formatDateTime", 2, 32, "%h: ",
2, "concat", 2, 2, "print", 1, 35, 32, "%H", 36, 0, 2, "formatDateTime", 2, 32, "%H: ", 2, "concat", 2, 2, "print", 1,
35, 32, "%i", 36, 0, 2, "formatDateTime", 2, 32, "%i: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%I", 36, 0, 2,
"formatDateTime", 2, 32, "%I: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%j", 36, 0, 2, "formatDateTime", 2, 32, "%j: ",
2, "concat", 2, 2, "print", 1, 35, 32, "%k", 36, 0, 2, "formatDateTime", 2, 32, "%k: ", 2, "concat", 2, 2, "print", 1,
35, 32, "%l", 36, 0, 2, "formatDateTime", 2, 32, "%l: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%m", 36, 0, 2,
"formatDateTime", 2, 32, "%m: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%M", 36, 0, 2, "formatDateTime", 2, 32, "%M: ",
2, "concat", 2, 2, "print", 1, 35, 32, "%n", 36, 0, 2, "formatDateTime", 2, 32, "%n: ", 2, "concat", 2, 2, "print", 1,
35, 32, "%p", 36, 0, 2, "formatDateTime", 2, 32, "%p: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%r", 36, 0, 2,
"formatDateTime", 2, 32, "%r: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%R", 36, 0, 2, "formatDateTime", 2, 32, "%R: ",
2, "concat", 2, 2, "print", 1, 35, 32, "%s", 36, 0, 2, "formatDateTime", 2, 32, "%s: ", 2, "concat", 2, 2, "print", 1,
35, 32, "%S", 36, 0, 2, "formatDateTime", 2, 32, "%S: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%t", 36, 0, 2,
"formatDateTime", 2, 32, "%t: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%T", 36, 0, 2, "formatDateTime", 2, 32, "%T: ",
2, "concat", 2, 2, "print", 1, 35, 32, "%u", 36, 0, 2, "formatDateTime", 2, 32, "%u: ", 2, "concat", 2, 2, "print", 1,
35, 32, "%V", 36, 0, 2, "formatDateTime", 2, 32, "%V: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%w", 36, 0, 2,
"formatDateTime", 2, 32, "%w: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%W", 36, 0, 2, "formatDateTime", 2, 32, "%W: ",
2, "concat", 2, 2, "print", 1, 35, 32, "%y", 36, 0, 2, "formatDateTime", 2, 32, "%y: ", 2, "concat", 2, 2, "print", 1,
35, 32, "%Y", 36, 0, 2, "formatDateTime", 2, 32, "%Y: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%z", 36, 0, 2,
"formatDateTime", 2, 32, "%z: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%%", 36, 0, 2, "formatDateTime", 2, 32, "%%: ",
2, "concat", 2, 2, "print", 1, 35, 32, "-----", 2, "print", 1, 35, 32, "one banana", 36, 0, 2, "formatDateTime", 2, 2,
"print", 1, 35, 32, "%Y no way %m is this %d a %H real %i time %S", 36, 0, 2, "formatDateTime", 2, 2, "print", 1, 35,
35]
"America/New_York", 32, "%Y-%m-%d %H:%i:%S", 36, 0, 2, "formatDateTime", 3, 2, "print", 1, 35, 32, "%Y%m%dT%H%i%sZ", 36,
0, 2, "formatDateTime", 2, 2, "print", 1, 35, 32, "-----", 2, "print", 1, 35, 32, "%a", 36, 0, 2, "formatDateTime", 2,
32, "%a: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%b", 36, 0, 2, "formatDateTime", 2, 32, "%b: ", 2, "concat", 2, 2,
"print", 1, 35, 32, "%c", 36, 0, 2, "formatDateTime", 2, 32, "%c: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%C", 36, 0,
2, "formatDateTime", 2, 32, "%C: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%d", 36, 0, 2, "formatDateTime", 2, 32,
"%d: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%D", 36, 0, 2, "formatDateTime", 2, 32, "%D: ", 2, "concat", 2, 2,
"print", 1, 35, 32, "%e", 36, 0, 2, "formatDateTime", 2, 32, "%e: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%F", 36, 0,
2, "formatDateTime", 2, 32, "%F: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%g", 36, 0, 2, "formatDateTime", 2, 32,
"%g: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%G", 36, 0, 2, "formatDateTime", 2, 32, "%G: ", 2, "concat", 2, 2,
"print", 1, 35, 32, "%h", 36, 0, 2, "formatDateTime", 2, 32, "%h: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%H", 36, 0,
2, "formatDateTime", 2, 32, "%H: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%i", 36, 0, 2, "formatDateTime", 2, 32,
"%i: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%I", 36, 0, 2, "formatDateTime", 2, 32, "%I: ", 2, "concat", 2, 2,
"print", 1, 35, 32, "%j", 36, 0, 2, "formatDateTime", 2, 32, "%j: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%k", 36, 0,
2, "formatDateTime", 2, 32, "%k: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%l", 36, 0, 2, "formatDateTime", 2, 32,
"%l: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%m", 36, 0, 2, "formatDateTime", 2, 32, "%m: ", 2, "concat", 2, 2,
"print", 1, 35, 32, "%M", 36, 0, 2, "formatDateTime", 2, 32, "%M: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%n", 36, 0,
2, "formatDateTime", 2, 32, "%n: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%p", 36, 0, 2, "formatDateTime", 2, 32,
"%p: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%r", 36, 0, 2, "formatDateTime", 2, 32, "%r: ", 2, "concat", 2, 2,
"print", 1, 35, 32, "%R", 36, 0, 2, "formatDateTime", 2, 32, "%R: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%s", 36, 0,
2, "formatDateTime", 2, 32, "%s: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%S", 36, 0, 2, "formatDateTime", 2, 32,
"%S: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%t", 36, 0, 2, "formatDateTime", 2, 32, "%t: ", 2, "concat", 2, 2,
"print", 1, 35, 32, "%T", 36, 0, 2, "formatDateTime", 2, 32, "%T: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%u", 36, 0,
2, "formatDateTime", 2, 32, "%u: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%V", 36, 0, 2, "formatDateTime", 2, 32,
"%V: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%w", 36, 0, 2, "formatDateTime", 2, 32, "%w: ", 2, "concat", 2, 2,
"print", 1, 35, 32, "%W", 36, 0, 2, "formatDateTime", 2, 32, "%W: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%y", 36, 0,
2, "formatDateTime", 2, 32, "%y: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%Y", 36, 0, 2, "formatDateTime", 2, 32,
"%Y: ", 2, "concat", 2, 2, "print", 1, 35, 32, "%z", 36, 0, 2, "formatDateTime", 2, 32, "%z: ", 2, "concat", 2, 2,
"print", 1, 35, 32, "%%", 36, 0, 2, "formatDateTime", 2, 32, "%%: ", 2, "concat", 2, 2, "print", 1, 35, 32, "-----", 2,
"print", 1, 35, 32, "one banana", 36, 0, 2, "formatDateTime", 2, 2, "print", 1, 35, 32,
"%Y no way %m is this %d a %H real %i time %S", 36, 0, 2, "formatDateTime", 2, 2, "print", 1, 35, 35]
1 change: 1 addition & 0 deletions hogvm/__tests__/__snapshots__/dateFormat.stdout
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
2009-02-11 18:39:03
2009-02-11 19:39:03
2009-02-11 13:39:03
20090211T183903Z
-----
%a: Wed
%b: Feb
Expand Down
37 changes: 17 additions & 20 deletions hogvm/__tests__/__snapshots__/loops.hoge
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +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, 31, 31, 31, 31, 31, 31, 36, 0, 37, 1, 36, 1, 2, "values", 1, 37, 3, 33, 0, 37, 4, 36, 3, 2,
"length", 1, 37, 5, 36, 5, 36, 4, 15, 40, 22, 36, 3, 36, 4, 45, 37, 6, 36, 6, 2, "print", 1, 35, 36, 4, 33, 1, 6, 37, 4,
39, -29, 35, 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, 31, 31, 31, 31, 31, 31, 31, 36, 0, 37, 1, 36, 1, 2, "keys", 1, 37, 2, 36, 1, 2, "values", 1, 37, 3, 33, 0, 37,
4, 36, 3, 2, "length", 1, 37, 5, 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, 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, 31, 31, 31, 31, 31, 31, 36, 0, 37, 1,
36, 1, 2, "values", 1, 37, 3, 33, 0, 37, 4, 36, 3, 2, "length", 1, 37, 5, 36, 5, 36, 4, 15, 40, 22, 36, 3, 36, 4, 45,
37, 6, 36, 6, 2, "print", 1, 35, 36, 4, 33, 1, 6, 37, 4, 39, -29, 35, 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, 31, 31, 31, 31, 31, 31, 31, 36,
0, 37, 1, 36, 1, 2, "keys", 1, 37, 2, 36, 1, 2, "values", 1, 37, 3, 33, 0, 37, 4, 36, 3, 2, "length", 1, 37, 5, 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, 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, 31, 31, 31, 31, 31, 31, 36, 0, 37, 1, 36, 1, 2, "values", 1,
37, 3, 33, 0, 37, 4, 36, 3, 2, "length", 1, 37, 5, 36, 5, 36, 4, 15, 40, 22, 36, 3, 36, 4, 45, 37, 6, 36, 6, 2, "print",
1, 35, 36, 4, 33, 1, 6, 37, 4, 39, -29, 35, 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, 31, 31, 31, 31, 31, 31, 31,
36, 0, 37, 1, 36, 1, 2, "keys", 1, 37, 2, 36, 1, 2, "values", 1, 37, 3, 33, 0, 37, 4, 36, 3, 2, "length", 1, 37, 5, 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, 1,
6, 37, 4, 39, -38, 35, 35, 35, 35, 35, 35, 35, 35]
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,
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,
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,
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,
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,
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,
1, 6, 37, 4, 39, -38, 35, 35, 35, 35, 35, 35, 35, 35]
7 changes: 7 additions & 0 deletions hogvm/__tests__/__snapshots__/strings.hoge
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
["_h", 32, " hello world ", 2, "trim", 1, 2, "print", 1, 35, 32, " hello world ", 2, "trimLeft", 1, 2, "print", 1,
35, 32, " hello world ", 2, "trimRight", 1, 2, "print", 1, 35, 32, "x", 32, "xxxx hello world xx", 2, "trim", 2, 2,
"print", 1, 35, 32, "x", 32, "xxxx hello world xx", 2, "trimLeft", 2, 2, "print", 1, 35, 32, "x", 32,
"xxxx hello world xx", 2, "trimRight", 2, 2, "print", 1, 35, 32, "hello world and more", 32, " ", 2, "splitByString",
2, 2, "print", 1, 35, 33, 1, 32, "hello world and more", 32, " ", 2, "splitByString", 3, 2, "print", 1, 35, 33, 2, 32,
"hello world and more", 32, " ", 2, "splitByString", 3, 2, "print", 1, 35, 33, 10, 32, "hello world and more", 32, " ",
2, "splitByString", 3, 2, "print", 1, 35]
10 changes: 10 additions & 0 deletions hogvm/__tests__/__snapshots__/strings.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
hello world
hello world
hello world
hello world
hello world xx
xxxx hello world
['hello', 'world', 'and', 'more']
['hello']
['hello', 'world']
['hello', 'world', 'and', 'more']
29 changes: 29 additions & 0 deletions hogvm/__tests__/arrays.hog
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,32 @@ 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('------')

print(arrayPushBack([1,2,3], 4))
print(arrayPushFront([1,2,3], 0))
print(arrayPopBack([1,2,3]))
print(arrayPopFront([1,2,3]))
print(arraySort([3,2,1]))
print(arrayReverse([1,2,3]))
print(arrayReverseSort([3,2,1]))
print(arrayStringConcat([1,2,3], ','))

print('-----')
let arr := [1,2,3,4] // we don't modify arr
print(arr)
arrayPushBack(arr, 5)
print(arr)
arrayPushFront(arr, 0)
print(arr)
arrayPopBack(arr)
print(arr)
arrayPopFront(arr)
print(arr)
arraySort(arr)
print(arr)
arrayReverse(arr)
print(arr)
arrayReverseSort(arr)
print(arr)
8 changes: 8 additions & 0 deletions hogvm/__tests__/crypto.hog
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
let string := 'this is a secure string'
print('string:', string)
print('md5Hex(string):', md5Hex(string))
print('sha256Hex(string):', sha256Hex(string))

let data := ['1', 'string', 'more', 'keys']
print('data:', data)
print('sha256HmacChainHex(data):', sha256HmacChainHex(data))
1 change: 1 addition & 0 deletions hogvm/__tests__/dateFormat.hog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ let dt := fromUnixTimestamp(1234377543.123456)
print(formatDateTime(dt, '%Y-%m-%d %H:%i:%S'))
print(formatDateTime(dt, '%Y-%m-%d %H:%i:%S', 'Europe/Brussels'))
print(formatDateTime(dt, '%Y-%m-%d %H:%i:%S', 'America/New_York'))
print(formatDateTime(dt, '%Y%m%dT%H%i%sZ'))

print('-----')
print('%a: ' || formatDateTime(dt, '%a'))
Expand Down
10 changes: 10 additions & 0 deletions hogvm/__tests__/strings.hog
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
print(trim(' hello world '))
print(trimLeft(' hello world '))
print(trimRight(' hello world '))
print(trim('xxxx hello world xx', 'x'))
print(trimLeft('xxxx hello world xx', 'x'))
print(trimRight('xxxx hello world xx', 'x'))
print(splitByString(' ', 'hello world and more'))
print(splitByString(' ', 'hello world and more', 1))
print(splitByString(' ', 'hello world and more', 2))
print(splitByString(' ', 'hello world and more', 10))
26 changes: 16 additions & 10 deletions hogvm/python/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,18 +208,24 @@ def check_timeout():
push_stack({})
case Operation.ARRAY:
count = next_token()
elems = stack[-count:]
stack = stack[:-count]
mem_used -= sum(mem_stack[-count:])
mem_stack = mem_stack[:-count]
push_stack(elems)
if count > 0:
elems = stack[-count:]
stack = stack[:-count]
mem_used -= sum(mem_stack[-count:])
mem_stack = mem_stack[:-count]
push_stack(elems)
else:
push_stack([])
case Operation.TUPLE:
count = next_token()
elems = stack[-count:]
stack = stack[:-count]
mem_used -= sum(mem_stack[-count:])
mem_stack = mem_stack[:-count]
push_stack(tuple(elems))
if count > 0:
elems = stack[-count:]
stack = stack[:-count]
mem_used -= sum(mem_stack[-count:])
mem_stack = mem_stack[:-count]
push_stack(tuple(elems))
else:
push_stack(())
case Operation.JUMP:
count = next_token()
ip += count
Expand Down
Loading

0 comments on commit cbf1f0c

Please sign in to comment.