Conversation
ingydotnet
left a comment
There was a problem hiding this comment.
Good work so far. Mostly just have suggestions for keeping this codebase more in sync with the others.
| _data = _ast["data"]; | ||
| } | ||
|
|
||
| json Runtime::exec_expr(json fragment) { |
There was a problem hiding this comment.
The variable 'fragment' should be called 'expr' to match all the other implementations. Let's try to use the same names as much as possible across code bases. If a name conflicts for some reason I typically add an '_' to the end or some other predetermined unique-ifying method.
It's important for maintainers to be able to look at all the code bases and expect similar names, style and layout.
There will be times when people need to add a feature across 20 langs at once, and it should be relatively straightforward.
|
|
||
| json Runtime::exec_dot(json::array_t fragment) { | ||
| json context = {}; // result of last call | ||
|
|
There was a problem hiding this comment.
This line has trailing whitespace. I have a vim plugin that highlights it in red :)
Maybe we can add some kind of git check hook to prevent things like this being committed/pushed.
| namespace testml { | ||
|
|
||
| namespace { | ||
| bool is_all_lowercase(std::string const& s) { |
There was a problem hiding this comment.
Functions like this should go into a testml/util.cpp.
| return _currentBlock["point"][name]; | ||
| } | ||
|
|
||
| json Runtime::exec_dot(json::array_t fragment) { |
There was a problem hiding this comment.
fragment should be 'calls'
| return value[0].is_string() && value[0] == "=>"; | ||
| } | ||
|
|
||
| void Runtime::run() { |
There was a problem hiding this comment.
This function should be called 'test'. Also try to put the methods in the same order as the coffee and others. All the others are in sync in this way.
| for (auto& statement : _ast["code"]) { | ||
| exec_expr(statement); | ||
| } | ||
| testml_done(); |
There was a problem hiding this comment.
This method should be 'testml_end'. I know it's just naming, but let's start out keeping things in sync. Makes it easier for me and others to jump in and help.
| @@ -0,0 +1,29 @@ | |||
| #include "wrapper.hpp" | |||
There was a problem hiding this comment.
Why can't the wrapper methods go inside the runtime class? ie Why do we need a separate class here?
There was a problem hiding this comment.
It's not a separate class. These functions will supposedly be reused by the Bridge"-r" and the Stdlib class, that's why it's separated into its own file.
There was a problem hiding this comment.
I'm not certain that the bridge classes will (or should) know about and use testml runtime internals, but we can wait and see.
There was a problem hiding this comment.
@vendethiel now that we forged a common understanding on IRC, I get where you are going.
In TestML lingo a 'method' call like .foo or .Bar is called a 'callable'. .foo is a user defined bridge class callable (because it is lower case) and .Bar is a stdlib callable. Given that the testml::Bridge (base class for user defined TestMLBridge class) and testml::StdLib both need the wrapper stuff I think that wrapper should be a testml::Callable class and both testml::Bridge and testml::StdLib should inherit from it.
| TestML_Run_TAP::run(file); | ||
| // tap.run(); | ||
| testml::Bridge bridge; | ||
| bridge.bind("add", +[](int a, int b) { |
There was a problem hiding this comment.
These functions (supposedly user defined) need to be in test/testml-bridge.cpp. That's where a user will add the C++ methods need to make the tests run.
|
|
||
| using json = nlohmann::json; | ||
|
|
||
| json Bridge::call(std::string const& name, std::vector<json> const& args) { |
There was a problem hiding this comment.
I don't think the call method belongs in the bridge base class. This implies that a user defined bridge method would want to call this method directly. Maybe this method should be called can and it returns the bridge method pointer of the requested method, if found.
|
@vendethiel can you |
b47ad45 to
e568fdd
Compare
bc2d9c7 to
870b2a2
Compare
|
@vendethiel you should join #testml again. I'm in a nearby TZ for a while... |
e3477a2 to
870b2a2
Compare
Needed to run: make `test-runtime-cpp` from root dir.
|
C++ might be better implemented by generating C++ code from the Lingy AST. That's how I did Bash support for testml. Walking a JSON structure seemed like @vendethiel been looking for you on #testml Would like to discuss this approach with you. |
|
I've been connected a few times a week, rebased the PR late 2018. |
No description provided.