Skip to content

Commit

Permalink
added testing examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lmarzen committed Jan 2, 2024
1 parent 459daf7 commit aaf98ed
Show file tree
Hide file tree
Showing 20 changed files with 2,130 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lexers/testdata/promela/calc.actual
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// reverse polish

mtype = { operator, value }

chan f = [12] of { mtype, int }

proctype calc(chan you)
{ int s, lft, rgt
chan me = [0] of { int }

if
:: f?operator(s)
run calc(me); me?lft
run calc(me); me?rgt
if
:: s == '+' -> you!(lft+rgt)
fi
:: f?value(s) -> you!s
fi
}
151 changes: 151 additions & 0 deletions lexers/testdata/promela/calc.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
[
{"type":"CommentSingle","value":"// reverse polish\n"},
{"type":"TextWhitespace","value":"\n"},
{"type":"KeywordDeclaration","value":"mtype"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"="},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"operator"},
{"type":"Punctuation","value":","},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"value"},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"}"},
{"type":"TextWhitespace","value":"\n\n"},
{"type":"KeywordDeclaration","value":"chan"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"f"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"="},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"["},
{"type":"LiteralNumberInteger","value":"12"},
{"type":"Punctuation","value":"]"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"of"},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"TextWhitespace","value":" "},
{"type":"KeywordDeclaration","value":"mtype"},
{"type":"Punctuation","value":","},
{"type":"TextWhitespace","value":" "},
{"type":"KeywordType","value":"int"},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"}"},
{"type":"TextWhitespace","value":"\n\n"},
{"type":"KeywordDeclaration","value":"proctype"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"calc"},
{"type":"Punctuation","value":"("},
{"type":"KeywordDeclaration","value":"chan"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"you"},
{"type":"Punctuation","value":")"},
{"type":"TextWhitespace","value":"\n"},
{"type":"Punctuation","value":"{"},
{"type":"TextWhitespace","value":"\t"},
{"type":"KeywordType","value":"int"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"s"},
{"type":"Punctuation","value":","},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"lft"},
{"type":"Punctuation","value":","},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"rgt"},
{"type":"TextWhitespace","value":"\n\t"},
{"type":"KeywordDeclaration","value":"chan"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"me"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"="},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"["},
{"type":"LiteralNumberInteger","value":"0"},
{"type":"Punctuation","value":"]"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"of"},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"TextWhitespace","value":" "},
{"type":"KeywordType","value":"int"},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"}"},
{"type":"TextWhitespace","value":"\n\n\t"},
{"type":"Keyword","value":"if"},
{"type":"TextWhitespace","value":"\n\t"},
{"type":"Operator","value":"::"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"f"},
{"type":"Operator","value":"?"},
{"type":"Name","value":"operator"},
{"type":"Punctuation","value":"("},
{"type":"Name","value":"s"},
{"type":"Punctuation","value":")"},
{"type":"TextWhitespace","value":"\n\t\t"},
{"type":"OperatorWord","value":"run"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"calc"},
{"type":"Punctuation","value":"("},
{"type":"Name","value":"me"},
{"type":"Punctuation","value":");"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"me"},
{"type":"Operator","value":"?"},
{"type":"Name","value":"lft"},
{"type":"TextWhitespace","value":"\n\t\t"},
{"type":"OperatorWord","value":"run"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"calc"},
{"type":"Punctuation","value":"("},
{"type":"Name","value":"me"},
{"type":"Punctuation","value":");"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"me"},
{"type":"Operator","value":"?"},
{"type":"Name","value":"rgt"},
{"type":"TextWhitespace","value":"\n\t\t"},
{"type":"Keyword","value":"if"},
{"type":"TextWhitespace","value":"\n\t\t"},
{"type":"Operator","value":"::"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"s"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"=="},
{"type":"TextWhitespace","value":" "},
{"type":"LiteralStringChar","value":"'+'"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"-\u003e"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"you"},
{"type":"Operator","value":"!"},
{"type":"Punctuation","value":"("},
{"type":"Name","value":"lft"},
{"type":"Operator","value":"+"},
{"type":"Name","value":"rgt"},
{"type":"Punctuation","value":")"},
{"type":"TextWhitespace","value":"\n\t\t"},
{"type":"Keyword","value":"fi"},
{"type":"TextWhitespace","value":"\n\t"},
{"type":"Operator","value":"::"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"f"},
{"type":"Operator","value":"?"},
{"type":"Name","value":"value"},
{"type":"Punctuation","value":"("},
{"type":"Name","value":"s"},
{"type":"Punctuation","value":")"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"-\u003e"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"you"},
{"type":"Operator","value":"!"},
{"type":"Name","value":"s"},
{"type":"TextWhitespace","value":"\n\t"},
{"type":"Keyword","value":"fi"},
{"type":"TextWhitespace","value":"\n"},
{"type":"Punctuation","value":"}"},
{"type":"TextWhitespace","value":"\n"}
]
3 changes: 3 additions & 0 deletions lexers/testdata/promela/do.actual
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
init {
a ? b -> a ! b;
}
23 changes: 23 additions & 0 deletions lexers/testdata/promela/do.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{"type":"KeywordDeclaration","value":"init"},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"TextWhitespace","value":"\n "},
{"type":"Name","value":"a"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"?"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"b"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"-\u003e"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"a"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"!"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"b"},
{"type":"Punctuation","value":";"},
{"type":"TextWhitespace","value":"\n"},
{"type":"Punctuation","value":"}"},
{"type":"TextWhitespace","value":"\n"}
]
4 changes: 4 additions & 0 deletions lexers/testdata/promela/dotted-assign.actual
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
init {
intercepted.key = data.key
r.b[a] = a * 4 + 7;
}
38 changes: 38 additions & 0 deletions lexers/testdata/promela/dotted-assign.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
{"type":"KeywordDeclaration","value":"init"},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"TextWhitespace","value":"\n "},
{"type":"Name","value":"intercepted"},
{"type":"Operator","value":"."},
{"type":"NameAttribute","value":"key"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"="},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"data"},
{"type":"Operator","value":"."},
{"type":"NameAttribute","value":"key"},
{"type":"TextWhitespace","value":"\n "},
{"type":"Name","value":"r"},
{"type":"Operator","value":"."},
{"type":"NameAttribute","value":"b"},
{"type":"Punctuation","value":"["},
{"type":"Name","value":"a"},
{"type":"Punctuation","value":"]"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"="},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"a"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"*"},
{"type":"TextWhitespace","value":" "},
{"type":"LiteralNumberInteger","value":"4"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"+"},
{"type":"TextWhitespace","value":" "},
{"type":"LiteralNumberInteger","value":"7"},
{"type":"Punctuation","value":";"},
{"type":"TextWhitespace","value":"\n"},
{"type":"Punctuation","value":"}"},
{"type":"TextWhitespace","value":"\n"}
]
6 changes: 6 additions & 0 deletions lexers/testdata/promela/if.actual
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
init {
if
:: skip;
fi;
skip
}
20 changes: 20 additions & 0 deletions lexers/testdata/promela/if.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{"type":"KeywordDeclaration","value":"init"},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"TextWhitespace","value":"\n "},
{"type":"Keyword","value":"if"},
{"type":"TextWhitespace","value":" \n "},
{"type":"Operator","value":"::"},
{"type":"TextWhitespace","value":" "},
{"type":"Keyword","value":"skip"},
{"type":"Punctuation","value":";"},
{"type":"TextWhitespace","value":"\n "},
{"type":"Keyword","value":"fi"},
{"type":"Punctuation","value":";"},
{"type":"TextWhitespace","value":"\n "},
{"type":"Keyword","value":"skip"},
{"type":"TextWhitespace","value":"\n"},
{"type":"Punctuation","value":"}"},
{"type":"TextWhitespace","value":"\n"}
]
4 changes: 4 additions & 0 deletions lexers/testdata/promela/intruder.actual
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Crypt x;
init {
Crypt x;
}
18 changes: 18 additions & 0 deletions lexers/testdata/promela/intruder.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{"type":"Name","value":"Crypt"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"x"},
{"type":"Punctuation","value":";"},
{"type":"TextWhitespace","value":"\n"},
{"type":"KeywordDeclaration","value":"init"},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"TextWhitespace","value":"\n "},
{"type":"Name","value":"Crypt"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"x"},
{"type":"Punctuation","value":";"},
{"type":"TextWhitespace","value":"\n"},
{"type":"Punctuation","value":"}"},
{"type":"TextWhitespace","value":"\n"}
]
1 change: 1 addition & 0 deletions lexers/testdata/promela/ltl.actual
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ltl alwayserr { [] ((statusa == err) || (statusb == err)) }
30 changes: 30 additions & 0 deletions lexers/testdata/promela/ltl.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{"type":"KeywordDeclaration","value":"ltl"},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"alwayserr"},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"[]"},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"(("},
{"type":"Name","value":"statusa"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"=="},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"err"},
{"type":"Punctuation","value":")"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"||"},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"("},
{"type":"Name","value":"statusb"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"=="},
{"type":"TextWhitespace","value":" "},
{"type":"Name","value":"err"},
{"type":"Punctuation","value":"))"},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"}"},
{"type":"TextWhitespace","value":"\n"}
]
4 changes: 4 additions & 0 deletions lexers/testdata/promela/msg.actual
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

init {
1 == 1 -> 3
}
19 changes: 19 additions & 0 deletions lexers/testdata/promela/msg.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{"type":"TextWhitespace","value":"\n"},
{"type":"KeywordDeclaration","value":"init"},
{"type":"TextWhitespace","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"TextWhitespace","value":"\n "},
{"type":"LiteralNumberInteger","value":"1"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"=="},
{"type":"TextWhitespace","value":" "},
{"type":"LiteralNumberInteger","value":"1"},
{"type":"TextWhitespace","value":" "},
{"type":"Operator","value":"-\u003e"},
{"type":"TextWhitespace","value":" "},
{"type":"LiteralNumberInteger","value":"3"},
{"type":"TextWhitespace","value":"\n"},
{"type":"Punctuation","value":"}"},
{"type":"TextWhitespace","value":"\n"}
]
Loading

0 comments on commit aaf98ed

Please sign in to comment.