Skip to content

Commit

Permalink
test: one more sanity check
Browse files Browse the repository at this point in the history
The important test with arbitrary words/instructions containing `}` in
them was needed
  • Loading branch information
novusnota committed Sep 22, 2024
1 parent 69f8acf commit 31706d2
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 1 deletion.
70 changes: 69 additions & 1 deletion src/grammar/__snapshots__/grammar.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3399,7 +3399,7 @@ exports[`grammar should parse expr-with-var 1`] = `

exports[`grammar should parse items-asm-funs 1`] = `
{
"id": 61,
"id": 67,
"imports": [],
"items": [
{
Expand Down Expand Up @@ -3932,6 +3932,74 @@ incinc
"ret": [],
},
},
{
"attributes": [],
"id": 66,
"instructions": [
"<{",
"TRY:<{",
"0",
"PUSHINT",
"ADD",
"DROP",
"-1",
"PUSHINT",
"}>CATCH<{",
"2DROP",
"0",
"PUSHINT",
"}>",
"}>CONT",
"1",
"1",
"CALLXARGS",
],
"kind": "asm_function_def",
"loc": asm fun isIntAnInt(x: Int): Int {
<{
TRY:<{
0 PUSHINT ADD DROP -1 PUSHINT
}>CATCH<{
2DROP 0 PUSHINT
}>
}>CONT 1 1 CALLXARGS
},
"name": {
"id": 61,
"kind": "id",
"loc": isIntAnInt,
"text": "isIntAnInt",
},
"params": [
{
"id": 65,
"kind": "typed_parameter",
"loc": x: Int,
"name": {
"id": 63,
"kind": "id",
"loc": x,
"text": "x",
},
"type": {
"id": 64,
"kind": "type_id",
"loc": Int,
"text": "Int",
},
},
],
"return": {
"id": 62,
"kind": "type_id",
"loc": Int,
"text": "Int",
},
"shuffle": {
"args": [],
"ret": [],
},
},
],
"kind": "module",
}
Expand Down
14 changes: 14 additions & 0 deletions src/grammar/test/items-asm-funs.tact
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,19 @@ asm fun createWord() {
{ INC }
}

/// Tests list and binding to a new regular word
asm fun createAndUseWord1(): Int {
{ INC } : incinc
41 incinc
}

/// Tests weird formatting
asm fun createAndUseWord2(): Int { { INC
}
: incinc 41 incinc
}

/// Tests weird formatting
asm fun createAndUseWord3(): Int {
{
INC
Expand All @@ -53,3 +56,14 @@ incinc
41
incinc
}

/// Tests words with } inside of them
asm fun isIntAnInt(x: Int): Int {
<{
TRY:<{
0 PUSHINT ADD DROP -1 PUSHINT
}>CATCH<{
2DROP 0 PUSHINT
}>
}>CONT 1 1 CALLXARGS
}

0 comments on commit 31706d2

Please sign in to comment.