-
Notifications
You must be signed in to change notification settings - Fork 163
feat: add updated fuzzer from tact-check repository #2340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Right now there is the problem in one of the tests in the fuzzer - compilation.spec.ts: As i understand, the problem is with provioding loc to all the AST items. Before the last commit i used dummySrcInfo from compilator code for all 'loc' fields, and now i tried to replace it with my own dummySrcInfoPrintable (./fuzzer/src/utils.ts, 236 line) with non-empty line interval, but error still persists. As i doesn't provide a source code and compile ast tree directly, in the place of the error (./src/grammar/src-info.ts, 186 line) the 'str' - source code itself - is empty, so the interval is empty too. But how can it not be? |
Hello. Try to define your
Note that the first parameter to |
… added stdlib read back, but it's not working yet
…t type with equal name in one scope
fuzzer/src/generators/constant.ts
Outdated
import type { | ||
ConstantDecl as AstConstantDecl, | ||
ConstantDef as AstConstantDef, | ||
ConstantAttribute as AstConstantAttribute, | ||
Expression as AstExpression, | ||
} from "../../../src/ast/ast"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import type { | |
ConstantDecl as AstConstantDecl, | |
ConstantDef as AstConstantDef, | |
ConstantAttribute as AstConstantAttribute, | |
Expression as AstExpression, | |
} from "../../../src/ast/ast"; | |
import type * as Ast from "../ast/ast"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, it looks good. There are some minor details like the use of optional arguments in functions and the use of classes, but I think this is acceptable, since this code is for testing.
What I am more interested in is how good the generators are; for example, the ones for expressions. What is the distribution of the generated expressions? To tackle this question, for the moment let us focus on the expression generators.
We need to add a statistics function, probably in the expression.spec.ts
file. The statistics function should count the frequencies of structurally different trees produced by the generators. By that I mean the following:
- Given an AST
T
generated by the expression generator, traverseT
in preorder and only keep thekind
field of each node (for function calls also keep the name of the function). For example, if the AST is:
{kind: "static_call", function: "do_something", ......}
| |
The children are --> | |
its arguments | |
| |
{kind: "number", value: 5n, ...} {kind: "string", value: "foo", ...}
Then, after keeping only the kind
field and function names, and traversing in preorder, we get the list:
"static_call_do_something", "number", "string"
- Join the string list into a single string (use a special symbol as separator, like @):
"static_call_do_something@number@string"
-
Keep a map with the counts for the produced strings.
-
Additionally, register the size of each produced tree (i.e., how many nodes it has), and its height (i.e., maximum distance from the root of the tree to a leaf node).
-
After producing, say 50,000 trees (or more). Dump all those counts into a file, so that we can then produce plots from the data. It would also be nice if we can produce the plots automatically, but let us postpone that for later, what matters right now is the counts.
…nerate null as a literal value
No description provided.