Skip to content
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

Python-style indentation in v6, edge cases not working initial findings - now fixed #763

Closed
kensoh opened this issue Mar 22, 2020 · 8 comments
Labels

Comments

@kensoh
Copy link
Member

kensoh commented Mar 22, 2020

Hi @siowyisheng I finish writing the positive test cases for v6 and added tests for using ocr and exist(). Found following edge case not working. Whenever there is nested loops, nested if etc.

for m from 1 to 3
    for n from 1 to 3
        echo `m`,`n`

Above code will throw below error -

ERROR - for nested conditions, loops, popup, frame, set { and } explicitly
ERROR - add { before this line and add } accordingly - for n from 1 to 3
ERROR - automation aborted due to above

This is by design because it is syntactically hard or perhaps impossible to automatically infer when users try to do this without using brackets in pre-v6. However, in v6, somehow by the time parsing reaches there, it seems to be not interpreted with the brackets {} inserted, thus triggering the error.

@kensoh kensoh added the bug label Mar 22, 2020
@kensoh
Copy link
Member Author

kensoh commented Mar 22, 2020

If you try to comment off the following lines in tagui_parse.php, script will compile but will throw error as expected because it was not given the context of where the brackets are in output script to form a syntactically correct JS script.

if (($previous_line_is_condition == true) and ($current_line_is_condition == true))
die("ERROR - for nested conditions, loops, popup, frame, set { and } explicitly\n".
"ERROR - add { before this line and add } accordingly - ".$padded_raw_flow_line);
SyntaxError: Unexpected token '}'

  phantomjs://code/a.tag.js:1459 in injectJs
  phantomjs://code/bootstrap.js:456

@kensoh
Copy link
Member Author

kensoh commented Mar 22, 2020

In the meantime, I've parked the positive test case below, under this is resolve then I test again -

https://github.com/kelaberetiv/TagUI/blob/positive_test/src/test/positive_test.tag

@kensoh
Copy link
Member Author

kensoh commented Mar 22, 2020

Below is another example with error, if the 3 lines in tagui_parse.php are commented off. They shouldn't be commented off, the Python style indentation should be inserting brackets before that is triggered. Otherwise syntactically incorrect JS will be created.

for n from 1 to 20
    if (a==1)
        for p from 21 to 40
            echo `n` - `p`

@kensoh kensoh changed the title Python-style indentation in v6, edge cases found not working Python-style indentation in v6, edge cases not working initial findings Mar 22, 2020
kensoh added a commit that referenced this issue Mar 28, 2020
@kensoh
Copy link
Member Author

kensoh commented Mar 28, 2020

Hi @siowyisheng raised PR #769 with following comments -


Hi @siowyisheng I traced through the code. The solution is a simple fix to simply remove pre v6 functionality of auto-appending brackets for code such as below. Since the assumption is not to have backward compatibility, then the following block of code should have indentation given by user already instead of assuming indenting once on user's behalf.

for n from 1 to 10
echo `n`

This fix is tested to be working for -

for m from 1 to 3
    for n from 1 to 3
        echo `m`,`n`

and

for n from 1 to 20
    if (a==1)
        for p from 21 to 40
            echo `n` - `p`

For your review if this change works for the earlier test cases you used for this feature.

siowyisheng added a commit that referenced this issue Mar 30, 2020
@kensoh
Copy link
Member Author

kensoh commented Mar 30, 2020

Great, in the meantime, users can get this fix from below zip, to overwrite existing v6 installation -

https://github.com/kelaberetiv/TagUI/archive/master.zip

@kensoh kensoh closed this as completed Mar 31, 2020
@kensoh kensoh reopened this Dec 4, 2020
@kensoh
Copy link
Member Author

kensoh commented Dec 4, 2020

Reopening this issue because the fix is done, but not yet in the packaged zips in the latest release.

@kensoh
Copy link
Member Author

kensoh commented Dec 4, 2020

Users can download the latest copy of the code from here and unzip to overwrite your existing installation (please drag the folders under tagui\src to overwrite your existing installation) - https://github.com/kelaberetiv/TagUI/archive/master.zip

In the next release, this will become part of the packaged zip files.

@kensoh kensoh changed the title Python-style indentation in v6, edge cases not working initial findings Python-style indentation in v6, edge cases not working initial findings - fixed Dec 4, 2020
@kensoh kensoh changed the title Python-style indentation in v6, edge cases not working initial findings - fixed Python-style indentation in v6, edge cases not working initial findings - now fixed Dec 4, 2020
@kensoh
Copy link
Member Author

kensoh commented Dec 19, 2020

Closing issue since the latest packaged release TagUI v6.14 is out.

Release notes - https://github.com/kelaberetiv/TagUI/releases/tag/v6.14.0
To download v6.14 - https://tagui.readthedocs.io/en/latest/setup.html
Documentation - https://tagui.readthedocs.io/en/latest/index.html

@kensoh kensoh closed this as completed Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant